Beispiel #1
0
        private OperatorSymbol unary(Tag tag, TypeTag argType, TypeTag result, LLVMOpcode opcode = default)
        {
            FuncType funcType = new FuncType(
                CollectionUtils.singletonList <Type>(symtab.typeForTag(argType)),
                symtab.typeForTag(result)
                );

            return(new OperatorSymbol(operatorNames[tag.operatorIndex()], symtab.noSymbol, funcType, opcode));
        }
Beispiel #2
0
        private OperatorSymbol binary(Tag tag, TypeTag left, TypeTag right, TypeTag result, LLVMOpcode opcode,
                                      int predicate = 0)
        {
            FuncType funcType = new FuncType(
                new Type[] { symtab.typeForTag(left), symtab.typeForTag(right) },
                symtab.typeForTag(result)
                );

            return(new OperatorSymbol(operatorNames[tag.operatorIndex()], symtab.noSymbol, funcType, opcode,
                                      predicate));
        }
Beispiel #3
0
        private Symbol.FuncSymbol builtin(string name, Type resType, IList <Type> args, bool isVarArg = false)
        {
            FuncType ftype = new FuncType(args, resType, isVarArg);

            Symbol.FuncSymbol ms = new Symbol.FuncSymbol(name, topLevelSymbol, ftype);
            ftype.symbol = ms;
            ms.isVararg  = isVarArg;

            ms.parameters = new List <Symbol.VarSymbol>(args.Count);
            foreach (Type type in args)
            {
                ms.parameters.Add(new Symbol.VarSymbol(Symbol.Kind.PARAM, "arg", type, ms));
            }

            builtins.Add(ms);
            return(ms);
        }
Beispiel #4
0
            private FuncSymbol makeFuncSymbol(FuncDef func, WritableScope enclScope)
            {
                FuncSymbol fsym = new FuncSymbol(func.name, enclScope.owner, null);

                func.symbol = fsym;

                fsym.owner = enclScope.owner;

                // create scope for func parameters and local variables
                WritableScope funcScope = enclScope.subScope(fsym);

                fsym.scope = funcScope;

                fsym.parameters = new List <VarSymbol>(func.parameters.Count);
                FuncType ftype = signature(func.returnType, func.parameters, funcScope);

                ftype.symbol = fsym;
                fsym.type    = ftype;
                return(fsym);
            }
Beispiel #5
0
 public virtual T visitFuncType(FuncType funcType) => visit(funcType);