fixed error
This commit is contained in:
parent
1441e34078
commit
a8638fe70c
@ -4,6 +4,7 @@ import ast.ClassNode;
|
||||
import ast.member.FieldNode;
|
||||
import ast.member.MemberNode;
|
||||
import ast.member.MethodNode;
|
||||
import ast.type.BaseTypeNode;
|
||||
import bytecode.visitor.ClassVisitor;
|
||||
import java.io.File;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
@ -39,7 +40,9 @@ public class ClassCodeGen implements ClassVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(FieldNode fieldNode) {
|
||||
classWriter.visitField(mapper.mapAccesTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(fieldNode.type.enumTypeNode), null, null );
|
||||
if(fieldNode.type instanceof BaseTypeNode baseTypeNode){
|
||||
classWriter.visitField(mapper.mapAccesTypeToOpcode(fieldNode.accessTypeNode), fieldNode.identifier, mapper.getTypeChar(baseTypeNode.enumType), null, null );
|
||||
}
|
||||
classWriter.visitEnd();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
package bytecode;
|
||||
|
||||
import ast.type.AccessTypeNode;
|
||||
import ast.type.EnumAccessTypeNode;
|
||||
import ast.type.EnumTypeNode;
|
||||
import ast.type.TypeNode;
|
||||
import ast.type.*;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
public class Mapper {
|
||||
@ -17,9 +14,9 @@ public class Mapper {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String generateMethodDescriptor(TypeNode typeNode) {
|
||||
public String generateMethodDescriptor(BaseTypeNode baseTypeNode) {
|
||||
String descriptor = "()";
|
||||
descriptor += getTypeChar(typeNode.enumTypeNode);
|
||||
descriptor += getTypeChar(baseTypeNode.enumType);
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package bytecode;
|
||||
|
||||
import ast.member.ConstructorNode;
|
||||
import ast.member.MethodNode;
|
||||
import ast.type.BaseTypeNode;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
|
||||
@ -27,12 +28,13 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(MethodNode methodNode) {
|
||||
MethodVisitor method = classWriter.visitMethod(mapper.mapAccesTypeToOpcode(methodNode.visibility),
|
||||
methodNode.identifier,
|
||||
mapper.generateMethodDescriptor(methodNode.type),
|
||||
null,
|
||||
null);
|
||||
|
||||
method.visitEnd();
|
||||
if(methodNode.type instanceof BaseTypeNode baseTypeNode){
|
||||
MethodVisitor method = classWriter.visitMethod(mapper.mapAccesTypeToOpcode(methodNode.visibility),
|
||||
methodNode.identifier,
|
||||
mapper.generateMethodDescriptor(baseTypeNode),
|
||||
null,
|
||||
null);
|
||||
method.visitEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user