Search in sources :

Example 16 with ParamDecl

use of org.abs_models.frontend.ast.ParamDecl in project abstools by abstools.

the class ErlUtil method functionHeaderParamsAsList.

public static final void functionHeaderParamsAsList(CodeStream ecs, String funName, String firstParameter, org.abs_models.frontend.ast.List<ParamDecl> args, Mask mask) {
    StringBuilder b = new StringBuilder("[");
    boolean first = true;
    for (ParamDecl p : args) {
        if (!first)
            b.append(',');
        else
            first = false;
        b.append("P_" + p.getName());
    }
    if (args.getNumChild() > 0) {
        b.append(',');
    }
    b.append("Stack]");
    functionHeader(ecs, funName, mask, firstParameter, b.toString());
}
Also used : ParamDecl(org.abs_models.frontend.ast.ParamDecl)

Example 17 with ParamDecl

use of org.abs_models.frontend.ast.ParamDecl in project abstools by abstools.

the class ErlUtil method functionHeader.

// Not used when garbage collector pause points are added to functions
// Consider removing
public static final void functionHeader(CodeStream ecs, String funName, org.abs_models.frontend.ast.List<ParamDecl> args) {
    List<String> a = new ArrayList<>(args.getNumChild());
    for (ParamDecl p : args) a.add(p.getName());
    functionHeader(ecs, funName, a, Mask.all);
}
Also used : ParamDecl(org.abs_models.frontend.ast.ParamDecl) ArrayList(java.util.ArrayList)

Example 18 with ParamDecl

use of org.abs_models.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("}");
}
Also used : FieldDecl(org.abs_models.frontend.ast.FieldDecl) ParamDecl(org.abs_models.frontend.ast.ParamDecl) ABSValue(org.abs_models.backend.java.lib.types.ABSValue)

Example 19 with ParamDecl

use of org.abs_models.frontend.ast.ParamDecl in project abstools by abstools.

the class TypeCheckerTest method classParamsMethodShadowsField.

@Test
public void classParamsMethodShadowsField() {
    Model m = assertParse("class C(Bool b) { Bool m(Bool b) { return b; } }");
    ModuleDecl u = m.lookupModule("UnitTest");
    ClassDecl c = (ClassDecl) u.lookup(new KindedName(KindedName.Kind.CLASS, "C"));
    MethodImpl me = c.lookupMethod("m");
    ReturnStmt r = (ReturnStmt) me.getBlock().getStmt(0);
    VarOrFieldUse vu = (VarOrFieldUse) r.getRetExp();
    ParamDecl d = (ParamDecl) vu.getDecl();
    assertThat(d.getParent().getParent(), instanceOf(MethodSig.class));
    assertThat(vu.getClass().getName(), vu, instanceOf(VarUse.class));
}
Also used : MethodSig(org.abs_models.frontend.ast.MethodSig) ClassDecl(org.abs_models.frontend.ast.ClassDecl) MethodImpl(org.abs_models.frontend.ast.MethodImpl) ParamDecl(org.abs_models.frontend.ast.ParamDecl) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) KindedName(org.abs_models.frontend.typechecker.KindedName) VarUse(org.abs_models.frontend.ast.VarUse) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) VarOrFieldUse(org.abs_models.frontend.ast.VarOrFieldUse) ABSTest(org.abs_models.ABSTest) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Aggregations

ParamDecl (org.abs_models.frontend.ast.ParamDecl)19 FieldDecl (org.abs_models.frontend.ast.FieldDecl)6 MethodImpl (org.abs_models.frontend.ast.MethodImpl)5 MethodSig (org.abs_models.frontend.ast.MethodSig)5 VarUse (org.abs_models.frontend.ast.VarUse)5 FrontendTest (org.abs_models.frontend.FrontendTest)4 Model (org.abs_models.frontend.ast.Model)4 ReturnStmt (org.abs_models.frontend.ast.ReturnStmt)4 VarOrFieldUse (org.abs_models.frontend.ast.VarOrFieldUse)4 Test (org.junit.Test)4 ABSTest (org.abs_models.ABSTest)3 ClassDecl (org.abs_models.frontend.ast.ClassDecl)3 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)3 KindedName (org.abs_models.frontend.typechecker.KindedName)3 TypedVarOrFieldDecl (org.abs_models.frontend.ast.TypedVarOrFieldDecl)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ABSDynamicClass (org.abs_models.backend.java.lib.runtime.ABSDynamicClass)1 ABSField (org.abs_models.backend.java.lib.runtime.ABSField)1 ABSValue (org.abs_models.backend.java.lib.types.ABSValue)1