Beispiel #1
0
        public virtual void CDecl(CIntermediateLang cil)
        {
            if (LllCompiler.SymTable.LookupSymbol(MangledName) != null)
            {
                var func    = LllCompiler.SymTable.LookupFunction(MangledName);
                var funcAst = func.Extra as AstFunc;
                if (funcAst != null)
                {
                    CILFunction = funcAst.CILFunction;
                }
                return;
            }
            var cName = NameGenerator.UniqName("func", Name);

            LllCompiler.SymTable.AddSymbolAtGlobalScope(new LllFunction(cName, this));
            if (!IsGeneric)
            {
                var retType = ReturnType.ToLllType();
                CILFunction = cil.CreateFunction(
                    SourceInfo,
                    retType.CName,
                    retType.PointerDepth,
                    cName,
                    Params.Select(p => p.ToCILVariableDecl(cil)).ToList());
            }
        }
        public CILFunction CreateFunction(SourceInfo si, string returnType, int returnPointerDepth, string name,
                                          List <CILVariableDecl> @params)
        {
            var retType = SymTable.LookupType(returnType);
            var func    = new CILFunction(si, name, retType, returnPointerDepth, @params, false);

            AddFunction(func);
            return(func);
        }
        public CILFunction DeclareFunction(SourceInfo si, string returnType, int returnPointerDepth, string name,
                                           List <CILVariableDecl> @params, bool isVarArgs)
        {
            var retType = SymTable.LookupType(returnType);
            var func    = new CILFunction(si, name, retType, returnPointerDepth, @params, isVarArgs);

            SymTable.DeclareFunction(func);
            return(func);
        }
 public void AddFunction(CILFunction function)
 {
     SymTable.DeclareFunction(function);
     _functions.Add(function.Name, function);
 }
Beispiel #5
0
 public void DeclareFunction(CILFunction function)
 {
     DeclareSym(function.Name, function);
 }