Search in sources :

Example 6 with Ide

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

the class DeclarationScope method addImport.

@Override
public void addImport(final ImportDirective importDirective) {
    Ide ide = importDirective.getIde();
    String name = ide.getName();
    Ide packageIde = ide.getQualifier();
    String packageName = "";
    final CompilationUnit compilationUnit = getCompilationUnit();
    if (packageIde != null) {
        packageName = packageIde.getQualifiedNameStr();
        packages.add(packageName);
    }
    if (AS3Type.ANY.toString().equals(name)) {
        final List<String> packageIdes = compilationUnit.getCompiler().getPackageIdes(packageName);
        for (String typeToImport : packageIdes) {
            ImportDirective implicitImport = new ImportDirective(packageIde, typeToImport);
            implicitImport.scope(this);
        }
    } else {
        if (importsByName.containsKey(name)) {
            final List<ImportDirective> directiveList = importsByName.get(name);
            if (isImportAlreadyAdded(directiveList, importDirective)) {
                return;
            }
            directiveList.add(importDirective);
        } else {
            List<ImportDirective> list = new LinkedList<ImportDirective>();
            list.add(importDirective);
            importsByName.put(name, list);
        }
        if (ides.containsKey(name)) {
            // name clash with value ide - error according to adobe
            throw new CompilerError(importDirective.getIde().getSymbol(), "attempt to redefine identifier " + name + " by import");
        }
        // define the fully qualified name if not (might be the same string for top level imports):
        final String qualifiedName = ide.getQualifiedNameStr();
        importsByQualifiedName.put(qualifiedName, importDirective);
    }
}
Also used : CompilationUnit(net.jangaroo.jooc.ast.CompilationUnit) ImportDirective(net.jangaroo.jooc.ast.ImportDirective) QualifiedIde(net.jangaroo.jooc.ast.QualifiedIde) Ide(net.jangaroo.jooc.ast.Ide) LinkedList(java.util.LinkedList)

Example 7 with Ide

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

the class DeclarationScope method findFreeAuxVar.

@Override
public Ide findFreeAuxVar() {
    int i = 1;
    while (true) {
        String auxVarName = "$" + i;
        Ide auxVar = new Ide(new JooSymbol(auxVarName));
        if (lookupDeclaration(auxVar) == null) {
            return auxVar;
        }
        ++i;
    }
}
Also used : QualifiedIde(net.jangaroo.jooc.ast.QualifiedIde) Ide(net.jangaroo.jooc.ast.Ide)

Example 8 with Ide

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

the class DeclarationScope method createAuxVar.

@Override
public Ide createAuxVar(Scope lookupScope) {
    Ide auxVar = findFreeAuxVar();
    new VariableDeclaration(null, auxVar, null).scope(this);
    return auxVar;
}
Also used : VariableDeclaration(net.jangaroo.jooc.ast.VariableDeclaration) QualifiedIde(net.jangaroo.jooc.ast.QualifiedIde) Ide(net.jangaroo.jooc.ast.Ide)

Aggregations

Ide (net.jangaroo.jooc.ast.Ide)8 QualifiedIde (net.jangaroo.jooc.ast.QualifiedIde)7 VariableDeclaration (net.jangaroo.jooc.ast.VariableDeclaration)4 IdeDeclaration (net.jangaroo.jooc.ast.IdeDeclaration)3 NamespacedIde (net.jangaroo.jooc.ast.NamespacedIde)3 ImportDirective (net.jangaroo.jooc.ast.ImportDirective)2 TypedIdeDeclaration (net.jangaroo.jooc.ast.TypedIdeDeclaration)2 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 CodeGenerator (net.jangaroo.jooc.CodeGenerator)1 JooSymbol (net.jangaroo.jooc.JooSymbol)1 JsWriter (net.jangaroo.jooc.JsWriter)1 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 BlockStatement (net.jangaroo.jooc.ast.BlockStatement)1 Catch (net.jangaroo.jooc.ast.Catch)1 CompilationUnit (net.jangaroo.jooc.ast.CompilationUnit)1 Directive (net.jangaroo.jooc.ast.Directive)1