use of abs.frontend.ast.ParamDecl in project abstools by abstools.
the class JavaGeneratorHelper method generateParams.
public static void generateParams(PrintStream stream, String firstArg, List<ParamDecl> params) {
stream.print("(");
boolean first = true;
if (firstArg != null) {
stream.print(firstArg);
first = false;
}
for (ParamDecl d : params) {
if (!first)
stream.print(", ");
// stream.print("final ");
d.generateJava(stream);
first = false;
}
stream.print(")");
}
use of abs.frontend.ast.ParamDecl in project abstools by abstools.
the class ClassDeclGenerator method generateGetFieldValueMethod.
private void generateGetFieldValueMethod() {
stream.println("protected final " + ABSValue.class.getName() + " getFieldValue(java.lang.String __ABS_fieldName) throws java.lang.NoSuchFieldException {");
for (ParamDecl p : decl.getParams()) {
stream.println("if (\"" + p.getName() + "\".equals(__ABS_fieldName)) return " + JavaBackend.getVariableName(p.getName()) + ";");
}
for (FieldDecl f : decl.getFields()) {
stream.println("if (\"" + f.getName() + "\".equals(__ABS_fieldName)) return " + JavaBackend.getVariableName(f.getName()) + ";");
}
stream.println("return super.getFieldValue(__ABS_fieldName);");
stream.println("}");
}
use of abs.frontend.ast.ParamDecl in project abstools by abstools.
the class ClassDeclGenerator method generateConstructor.
private void generateConstructor() {
// constructor
stream.print("public " + className);
JavaGeneratorHelper.generateParams(stream, decl.getParams());
stream.println(" {");
for (ParamDecl p : decl.getParams()) {
stream.println("this." + JavaBackend.getVariableName(p.getName()) + " = " + JavaBackend.getVariableName(p.getName()) + ";");
}
stream.println("getCOG().objectCreated(this);");
stream.println("}");
stream.println("protected final void __ABS_init() {");
for (FieldDecl f : decl.getFields()) {
if (f.hasInitExp()) {
stream.print("this.");
stream.print(JavaBackend.getVariableName(f.getName()));
stream.print(" = ");
f.getInitExp().generateJava(stream);
stream.print(";");
}
}
if (decl.hasInitBlock()) {
decl.getInitBlock().generateJava(stream);
}
stream.println("getCOG().objectInitialized(this);");
stream.println("}");
}
use of abs.frontend.ast.ParamDecl in project abstools by abstools.
the class ClassDeclGenerator method generateFields.
private void generateFields() {
for (ParamDecl p : decl.getParams()) {
stream.print("private ");
p.generateJava(stream);
stream.println(";");
}
for (FieldDecl f : decl.getFields()) {
f.generateJava(stream);
}
}
use of abs.frontend.ast.ParamDecl in project abstools by abstools.
the class DeltaForGetSetFieldsBuilder method addGetter.
AddMethodModifier addGetter(Exp returnValue, String fieldName, Access returnType) {
MethodSig sig = new MethodSig(testCaseNameBuilder.getterMethodName(fieldName), new abs.frontend.ast.List<Annotation>(), returnType, new abs.frontend.ast.List<ParamDecl>());
Block block = new Block();
ReturnStmt rs = new ReturnStmt();
rs.setRetExp(new FieldUse(fieldName));
block.addStmtNoTransform(rs);
MethodImpl method = new MethodImpl(sig, block, false);
AddMethodModifier modifier = new AddMethodModifier(method);
return modifier;
}
Aggregations