コード例 #1
0
ファイル: OILCan.cs プロジェクト: kohoutech/Dynamo
        public Module load()
        {
            Module module = null;

            try
            {
                globalSymbols = new Dictionary <string, Declaration>();
                localSymbols  = new Dictionary <string, Declaration>();

                oilcan = EnamlData.loadFromFile(filename);

                string oilVersion = oilcan.getStringValue("OILCan.version", "");
                string modname    = oilcan.getStringValue("module.name", "");

                module = new Module(modname);

                List <String> funcs = oilcan.getPathKeys("module.funcs");
                foreach (String funcname in funcs)
                {
                    FuncDefNode func = loadFuncDef("module.funcs." + funcname);
                    module.funcs.Add(func);
                    globalSymbols[funcname] = func;
                }
            }
            catch (ENAMLException e)
            {
                return(null);
            }

            return(module);
        }
コード例 #2
0
ファイル: OILCan.cs プロジェクト: kohoutech/Dynamo
        //- writing declarations ------------------------------------

        public void saveFuncDef(int fnum, FuncDefNode func)
        {
            string fname = "module.funcs." + func.OILname;

            oilcan.setStringValue(fname + ".name", func.name);
            saveTypeDecl(fname + ".return-type", func.returnType);

            string pname = fname + ".params.";
            int    pnum  = 0;

            foreach (ParamDeclNode param in func.paramList)
            {
                saveParamDecl(pname + param.OILname, param);
                pnum++;
            }

            string lname = fname + ".locals.";
            int    lnum  = 0;

            foreach (VarDeclNode local in func.locals)
            {
                saveVarDecl(lname + local.OILname, local);
                lnum++;
            }

            string bname = fname + ".body";

            saveStatementList(bname, func.body);
        }
コード例 #3
0
ファイル: OILCan.cs プロジェクト: kohoutech/Dynamo
        //- reading declarations ------------------------------------

        public FuncDefNode loadFuncDef(String path)
        {
            localSymbols.Clear();
            FuncDefNode func = new FuncDefNode();

            func.name       = oilcan.getStringValue(path + ".name", "");
            func.returnType = loadTypeDecl(path + ".return-type");

            List <String> paramnames = oilcan.getPathKeys(path + ".params");

            foreach (String pname in paramnames)
            {
                ParamDeclNode p = loadParamDecl(path + ".params." + pname);
                func.paramList.Add(p);
                localSymbols[pname] = p;
            }

            List <String> localnames = oilcan.getPathKeys(path + ".locals");

            foreach (String lname in localnames)
            {
                VarDeclNode l = loadVarDecl(path + ".locals." + lname);
                func.locals.Add(l);
                localSymbols[lname] = l;
            }

            func.body = loadStatementList(path + ".body");

            return(func);
        }
コード例 #4
0
ファイル: OILCan.cs プロジェクト: kohoutech/Dynamo
        public void generateFunctionNames(FuncDefNode func)
        {
            for (int pnum = 0; pnum < func.paramList.Count; pnum++)
            {
                func.paramList[pnum].OILname = "p" + pnum.ToString();
            }

            for (int lnum = 0; lnum < func.locals.Count; lnum++)
            {
                func.locals[lnum].OILname = "l" + lnum.ToString();
            }
        }