use of dyvilx.tools.compiler.ast.classes.CodeClass in project Dyvil by Dyvil.
the class Template method parse.
@Override
public void parse() {
// class NAME { }
final CodeClass theClass = new CodeClass(null, this.name, AttributeList.of(Modifiers.PUBLIC));
final ClassBody classBody = new ClassBody(theClass);
theClass.setBody(classBody);
this.addClass(theClass);
this.templateClass = theClass;
// func generate(spec, writer) -> void = { ... }
final CodeMethod genMethod = new CodeMethod(theClass, Name.fromRaw("generate"), Types.VOID, AttributeList.of(Modifiers.PUBLIC | Modifiers.OVERRIDE));
final StatementList directives = new StatementList();
genMethod.setValue(directives);
classBody.addMethod(genMethod);
this.genMethod = genMethod;
// func main(args) -> void
final CodeMethod mainMethod = new CodeMethod(theClass, Name.fromRaw("main"), Types.VOID, AttributeList.of(Modifiers.PUBLIC | Modifiers.STATIC));
classBody.addMethod(mainMethod);
this.mainMethod = mainMethod;
// Parse
new ParserManager(DyvilSymbols.INSTANCE, this.tokens.iterator(), this.markers).parse(new BlockParser(this, directives));
}
use of dyvilx.tools.compiler.ast.classes.CodeClass in project Dyvil by Dyvil.
the class REPLContext method startEvaluation.
// Evaluation
public void startEvaluation(String text) {
final String className = CLASS_PREFIX + this.classIndex++;
this.currentClass = new CodeClass(this, Name.fromRaw(className));
this.currentClass.setBody(new ClassBody(this.currentClass));
this.currentSource = new TextSource(text);
}
Aggregations