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);
}
}
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;
}
}
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;
}
Aggregations