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