use of dyvilx.tools.compiler.ast.imports.ImportDeclaration in project Dyvil by Dyvil.
the class ImportDirectiveParser method parse.
@Override
public void parse(IParserManager pm, IToken token) {
final int type = token.type();
switch(this.mode) {
case KEYWORD:
switch(type) {
case GenSrcSymbols.USING:
this.mask = KindedImport.USING_DECLARATION;
// Fallthrough
case GenSrcSymbols.IMPORT:
this.declaration = new ImportDeclaration(token.raw());
if (this.template == null) {
pm.report(token, "import.context");
}
this.mode = OPEN_PAREN;
return;
}
throw new Error();
case OPEN_PAREN:
if (type != BaseSymbols.OPEN_PARENTHESIS) {
pm.report(token, "import.open_paren");
pm.popParser(true);
return;
}
pm.pushParser(new ImportParser(this.declaration, this.mask));
this.mode = CLOSE_PAREN;
return;
case CLOSE_PAREN:
switch(type) {
case BaseSymbols.CLOSE_PARENTHESIS:
if (this.template != null && this.declaration.getImport() != null) {
this.template.addImport(this.declaration);
}
pm.popParser();
return;
case Tokens.EOF:
pm.report(token, "import.close_paren");
pm.popParser();
return;
}
pm.report(token, "import.close_paren");
return;
}
}
use of dyvilx.tools.compiler.ast.imports.ImportDeclaration in project Dyvil by Dyvil.
the class HeaderContext method getImplicitMatches.
@Override
public void getImplicitMatches(MatchList<IMethod> list, IValue value, IType targetType) {
// See comment in getMethodMatches for rationale
this.header.getImplicitMatches(list, value, targetType);
if (list.hasCandidate()) {
return;
}
final ImportDeclaration[] imports = this.header.importDeclarations;
for (int i = 0; i < this.header.importCount; i++) {
final IImportContext importContext = imports[i].getContext();
final MatchList<IMethod> subList = list.emptyCopy();
importContext.getImplicitMatches(subList, value, targetType);
list.addAll(subList);
}
}
use of dyvilx.tools.compiler.ast.imports.ImportDeclaration in project Dyvil by Dyvil.
the class ExternalHeader method resolveImports.
private void resolveImports() {
this.resolved |= IMPORTS;
for (int i = 0; i < this.importCount; i++) {
final ImportDeclaration declaration = this.importDeclarations[i];
declaration.resolveTypes(null, this);
declaration.resolve(null, this);
}
}
use of dyvilx.tools.compiler.ast.imports.ImportDeclaration in project Dyvil by Dyvil.
the class HeaderContext method read.
@Override
public void read(DataInput in) throws IOException {
this.headerDeclaration = new HeaderDeclaration(this);
this.headerDeclaration.read(in);
this.name = this.headerDeclaration.getName();
// Import Declarations
int imports = in.readShort();
for (int i = 0; i < imports; i++) {
ImportDeclaration id = new ImportDeclaration(null);
id.read(in);
this.addImport(id);
}
int operators = in.readShort();
for (int i = 0; i < operators; i++) {
Operator op = Operator.read(in);
this.addOperator(op);
}
int typeAliases = in.readShort();
for (int i = 0; i < typeAliases; i++) {
TypeAlias ta = new TypeAlias();
ta.read(in);
this.addTypeAlias(ta);
}
}
use of dyvilx.tools.compiler.ast.imports.ImportDeclaration in project Dyvil by Dyvil.
the class HeaderContext method getMethodMatches.
@Override
public void getMethodMatches(MatchList<IMethod> list, IValue receiver, Name name, ArgumentList arguments) {
// For ordinary headers, this is a no-op, since they (currently) cannot host any free-standing functions
// The REPL however can, so we need this call
this.header.getMethodMatches(list, receiver, name, arguments);
if (list.hasCandidate()) {
return;
}
final ImportDeclaration[] imports = this.header.importDeclarations;
for (int i = 0; i < this.header.importCount; i++) {
final IImportContext importContext = imports[i].getContext();
final MatchList<IMethod> subList = list.emptyCopy();
importContext.getMethodMatches(subList, receiver, name, arguments);
list.addAll(subList);
}
}
Aggregations