Skip to content

Commit

Permalink
Support for class fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusmelke committed May 17, 2016
1 parent 148abfb commit 5013957
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
Expand Up @@ -34,7 +34,7 @@ public static String byteCodeName( String javaName )
return javaName.replaceAll( "\\.", "\\/" );
}

public static String type( TypeReference reference )
public static String typeName( TypeReference reference )
{
StringBuilder builder = new StringBuilder();
internalType( builder, reference, false );
Expand Down
Expand Up @@ -45,6 +45,7 @@
import static org.neo4j.codegen.ByteCodeUtils.desc;
import static org.neo4j.codegen.ByteCodeUtils.exceptions;
import static org.neo4j.codegen.ByteCodeUtils.signature;
import static org.neo4j.codegen.ByteCodeUtils.typeName;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ACC_SUPER;
Expand Down Expand Up @@ -88,7 +89,7 @@ public void field( FieldReference field, Expression value )
staticFields.put( field, value );
}
FieldVisitor fieldVisitor = classWriter
.visitField( field.modifiers(), "string", "Ljava/lang/String;", signature( field.type() ), null );
.visitField( field.modifiers(), field.name(), typeName( field.type() ), signature( field.type() ), null );
fieldVisitor.visitEnd();
}

Expand Down
Expand Up @@ -29,7 +29,7 @@
import static org.neo4j.codegen.ByteCodeUtils.desc;
import static org.neo4j.codegen.ByteCodeUtils.exceptions;
import static org.neo4j.codegen.ByteCodeUtils.signature;
import static org.neo4j.codegen.ByteCodeUtils.type;
import static org.neo4j.codegen.ByteCodeUtils.typeName;
import static org.neo4j.codegen.MethodDeclaration.method;
import static org.neo4j.codegen.Parameter.param;
import static org.neo4j.codegen.TypeReference.extending;
Expand All @@ -45,7 +45,7 @@ public void shouldTranslateIntToByteCode()
TypeReference reference = typeReference( int.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "I" ) );
Expand All @@ -58,7 +58,7 @@ public void shouldTranslateShortToByteCode()
TypeReference reference = typeReference( short.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "S" ) );
Expand All @@ -71,7 +71,7 @@ public void shouldTranslateCharToByteCode()
TypeReference reference = typeReference( char.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "C" ) );
Expand All @@ -84,7 +84,7 @@ public void shouldTranslateLongToByteCode()
TypeReference reference = typeReference( long.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "J" ) );
Expand All @@ -97,7 +97,7 @@ public void shouldTranslateFloatToByteCode()
TypeReference reference = typeReference( float.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "F" ) );
Expand All @@ -110,7 +110,7 @@ public void shouldTranslateDoubleToByteCode()
TypeReference reference = typeReference( double.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "D" ) );
Expand All @@ -123,7 +123,7 @@ public void shouldTranslateBooleanToByteCode()
TypeReference reference = typeReference( boolean.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "Z" ) );
Expand All @@ -136,7 +136,7 @@ public void shouldTranslateVoidToByteCode()
TypeReference reference = typeReference( void.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "V" ) );
Expand All @@ -149,7 +149,7 @@ public void shouldTranslateReferenceTypeToByteCode()
TypeReference reference = typeReference( String.class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "Ljava/lang/String;" ) );
Expand All @@ -162,7 +162,7 @@ public void shouldTranslateArrayTypeToByteCode()
TypeReference reference = typeReference( boolean[].class );

// WHEN
String byteCodeName = type( reference );
String byteCodeName = typeName( reference );

// THEN
assertThat( byteCodeName, equalTo( "[Z" ) );
Expand Down

0 comments on commit 5013957

Please sign in to comment.