mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 16:28:04 +00:00
fixed nested IDs showing this. along their name
This commit is contained in:
parent
871447b9df
commit
379bfe7201
@ -15,6 +15,26 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class Compiler {
|
public class Compiler {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
generateAST("""
|
||||||
|
public class ClassWithConstructorWithParameters {
|
||||||
|
int x;
|
||||||
|
public ClassWithConstructorWithParameters(int startValue, int repetitions) {
|
||||||
|
this.x = startValue;
|
||||||
|
while (repetitions > 0) {
|
||||||
|
int innerRepetitions;
|
||||||
|
innerRepetitions = this.x;
|
||||||
|
while (innerRepetitions > 0) {
|
||||||
|
this.x = this.x * this.x;
|
||||||
|
innerRepetitions -= 1;
|
||||||
|
}
|
||||||
|
repetitions -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
public static Class generateAST(String fromSource) {
|
public static Class generateAST(String fromSource) {
|
||||||
CharStream input = CharStreams.fromString(fromSource);
|
CharStream input = CharStreams.fromString(fromSource);
|
||||||
DecafLexer lexer = new DecafLexer(input);
|
DecafLexer lexer = new DecafLexer(input);
|
||||||
@ -63,7 +83,7 @@ public class Compiler {
|
|||||||
CodeGenUtils.writeClassfile(bytes, classname);
|
CodeGenUtils.writeClassfile(bytes, classname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
generateByteCodeFileFromFile("src/main/resources/JavaTestfiles/ClassWithConstructor.java", "ClassWithConstructor");
|
// generateByteCodeFileFromFile("src/main/resources/JavaTestfiles/ClassWithConstructor.java", "ClassWithConstructor");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
|
|||||||
List<DecafParser.RecipientContext> recipientList = ctx.fieldVarAccess().recipient();
|
List<DecafParser.RecipientContext> recipientList = ctx.fieldVarAccess().recipient();
|
||||||
recipient = generateRecursiveOwnerChain(recipientList, null);
|
recipient = generateRecursiveOwnerChain(recipientList, null);
|
||||||
}
|
}
|
||||||
return new FieldVarAccess(isField, recipient, ctx.getText());
|
return new FieldVarAccess(isField, recipient, ctx.fieldVarAccess().id().IDENTIFIER().getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Expression generateConstant(DecafParser.LiteralContext ctx) {
|
public static Expression generateConstant(DecafParser.LiteralContext ctx) {
|
||||||
|
Loading…
Reference in New Issue
Block a user