Search in sources :

Example 1 with SymbolTable

use of com.oracle.truffle.llvm.parser.model.SymbolTable in project sulong by graalvm.

the class FunctionStart method parseArguments.

static void parseArguments(IRScope scope, SymbolImpl callTarget, Instruction inst, SymbolImpl[] target, int[] src) {
    if (src.length == 0) {
        return;
    }
    final Type[] paramTypes;
    if (callTarget instanceof FunctionDefinition) {
        paramTypes = ((FunctionDefinition) (callTarget)).getType().getArgumentTypes();
    } else if (callTarget instanceof FunctionDeclaration) {
        paramTypes = ((FunctionDeclaration) (callTarget)).getType().getArgumentTypes();
    } else {
        paramTypes = Type.EMPTY_ARRAY;
    }
    final SymbolTable symbols = scope.getSymbols();
    for (int i = Math.min(paramTypes.length, src.length) - 1; i >= 0; i--) {
        if (paramTypes[i] == MetaType.METADATA) {
            target[i] = MetadataSymbol.create(scope.getMetadata(), src[i]);
        } else {
            target[i] = symbols.getForwardReferenced(src[i], inst);
        }
    }
    // parse varargs
    for (int i = paramTypes.length; i < src.length; i++) {
        target[i] = symbols.getForwardReferenced(src[i], inst);
    }
}
Also used : FunctionDeclaration(com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration) Type(com.oracle.truffle.llvm.runtime.types.Type) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) SymbolTable(com.oracle.truffle.llvm.parser.model.SymbolTable) FunctionDefinition(com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)

Aggregations

SymbolTable (com.oracle.truffle.llvm.parser.model.SymbolTable)1 FunctionDeclaration (com.oracle.truffle.llvm.parser.model.functions.FunctionDeclaration)1 FunctionDefinition (com.oracle.truffle.llvm.parser.model.functions.FunctionDefinition)1 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)1 Type (com.oracle.truffle.llvm.runtime.types.Type)1