use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.SubroutineDescriptor in project TrufflePascal by Aspect26.
the class NodeFactory method createSubroutineCall.
public ExpressionNode createSubroutineCall(Token identifierToken, List<ExpressionNode> params) {
String identifier = this.getIdentifierFromToken(identifierToken);
return this.doLookup(identifier, (LexicalScope foundInScope, String foundIdentifier) -> {
if (foundInScope.isSubroutine(foundIdentifier)) {
SubroutineDescriptor subroutineDescriptor = foundInScope.getSubroutineDescriptor(foundIdentifier, params);
subroutineDescriptor.verifyArguments(params);
return this.createInvokeNode(foundIdentifier, subroutineDescriptor, foundInScope, params);
} else {
throw new LexicalException(foundIdentifier + " is not a subroutine.");
}
});
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.SubroutineDescriptor in project TrufflePascal by Aspect26.
the class LexicalScope method isReferenceParameter.
boolean isReferenceParameter(String identifier, int parameterIndex) throws LexicalException {
TypeDescriptor subroutineDescriptor = this.localIdentifiers.getIdentifierDescriptor(identifier);
if (!(subroutineDescriptor instanceof SubroutineDescriptor)) {
throw new LexicalException("Not a subroutine: " + identifier);
}
SubroutineDescriptor descriptor = (SubroutineDescriptor) subroutineDescriptor;
return descriptor.isReferenceParameter(parameterIndex);
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.SubroutineDescriptor in project TrufflePascal by Aspect26.
the class BuiltinUnitAbstr method importTo.
@Override
public void importTo(UnitLexicalScope lexicalScope) {
List<UnitSubroutineData> unitFunctions = this.getIdentifiers();
for (UnitSubroutineData unitFunction : unitFunctions) {
String identifier = unitFunction.identifier.toLowerCase();
SubroutineDescriptor descriptor = unitFunction.descriptor;
// register to identifiers table and function registry
lexicalScope.registerBuiltinSubroutine(identifier, descriptor);
}
lexicalScope.markAllIdentifiersPublic();
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.SubroutineDescriptor in project TrufflePascal by Aspect26.
the class LexicalScope method isSubroutineParameter.
boolean isSubroutineParameter(String identifier, int parameterIndex) throws LexicalException {
TypeDescriptor subroutineDescriptor = this.localIdentifiers.getIdentifierDescriptor(identifier);
if (!(subroutineDescriptor instanceof SubroutineDescriptor)) {
throw new LexicalException("Not a subroutine: " + identifier);
}
SubroutineDescriptor descriptor = (SubroutineDescriptor) subroutineDescriptor;
return descriptor.isSubroutineParameter(parameterIndex);
}
Aggregations