Search in sources :

Example 1 with Expr

use of net.jangaroo.jooc.ast.Expr in project jangaroo-tools by CoreMedia.

the class JsCodeGenerator method generateSuperConstructorCallCode.

private void generateSuperConstructorCallCode(ClassDeclaration classDeclaration, ParenthesizedExpr<CommaSeparatedList<Expr>> args) throws IOException {
    String superClassQName = classDeclaration.getSuperTypeDeclaration().getQualifiedNameStr();
    if ("Error".equals(superClassQName)) {
        // built-in Error constructor called as function unfortunately always creates a new Error object, so we have to use emulation provided by Jangaroo Runtime:
        out.write("joo.Error");
    } else {
        Ide superClassIde = classDeclaration.getSuperType().getIde();
        out.writeSymbolWhitespace(superClassIde.getSymbol());
        IdeDeclaration superClassDeclaration = superClassIde.getDeclaration();
        String packageName = superClassDeclaration.getPackageDeclaration().getQualifiedNameStr();
        String qName = superClassDeclaration.getName();
        if (packageName.length() > 0) {
            String packageAuxVar = compilationUnit.getAuxVarForPackage(packageName);
            qName = CompilerUtils.qName(packageAuxVar, qName);
        }
        out.write(qName);
    }
    out.writeToken(".call");
    if (args == null) {
        out.writeToken("(this)");
    } else {
        out.writeSymbol(args.getLParen());
        out.writeToken("this");
        CommaSeparatedList<Expr> arguments = args.getExpr();
        if (arguments != null) {
            if (arguments.getHead() != null) {
                out.writeToken(",");
            }
            arguments.visit(this);
        }
        out.writeSymbol(args.getRParen());
    }
}
Also used : IdeDeclaration(net.jangaroo.jooc.ast.IdeDeclaration) TypedIdeDeclaration(net.jangaroo.jooc.ast.TypedIdeDeclaration) IdeExpr(net.jangaroo.jooc.ast.IdeExpr) ParenthesizedExpr(net.jangaroo.jooc.ast.ParenthesizedExpr) DotExpr(net.jangaroo.jooc.ast.DotExpr) AssignmentOpExpr(net.jangaroo.jooc.ast.AssignmentOpExpr) Expr(net.jangaroo.jooc.ast.Expr) FunctionExpr(net.jangaroo.jooc.ast.FunctionExpr) ArrayIndexExpr(net.jangaroo.jooc.ast.ArrayIndexExpr) InfixOpExpr(net.jangaroo.jooc.ast.InfixOpExpr) NewExpr(net.jangaroo.jooc.ast.NewExpr) AsExpr(net.jangaroo.jooc.ast.AsExpr) ApplyExpr(net.jangaroo.jooc.ast.ApplyExpr) Ide(net.jangaroo.jooc.ast.Ide) NamespacedIde(net.jangaroo.jooc.ast.NamespacedIde) QualifiedIde(net.jangaroo.jooc.ast.QualifiedIde)

Aggregations

ApplyExpr (net.jangaroo.jooc.ast.ApplyExpr)1 ArrayIndexExpr (net.jangaroo.jooc.ast.ArrayIndexExpr)1 AsExpr (net.jangaroo.jooc.ast.AsExpr)1 AssignmentOpExpr (net.jangaroo.jooc.ast.AssignmentOpExpr)1 DotExpr (net.jangaroo.jooc.ast.DotExpr)1 Expr (net.jangaroo.jooc.ast.Expr)1 FunctionExpr (net.jangaroo.jooc.ast.FunctionExpr)1 Ide (net.jangaroo.jooc.ast.Ide)1 IdeDeclaration (net.jangaroo.jooc.ast.IdeDeclaration)1 IdeExpr (net.jangaroo.jooc.ast.IdeExpr)1 InfixOpExpr (net.jangaroo.jooc.ast.InfixOpExpr)1 NamespacedIde (net.jangaroo.jooc.ast.NamespacedIde)1 NewExpr (net.jangaroo.jooc.ast.NewExpr)1 ParenthesizedExpr (net.jangaroo.jooc.ast.ParenthesizedExpr)1 QualifiedIde (net.jangaroo.jooc.ast.QualifiedIde)1 TypedIdeDeclaration (net.jangaroo.jooc.ast.TypedIdeDeclaration)1