コード例 #1
0
ファイル: ParserHelper.cs プロジェクト: guojianbin/ELua
        public static KeyValuePair <WordExpression, DefineExpression> Wrapper(Expression expression, string name)
        {
            var itemKey   = new WordExpression(name, expression.debugInfo);
            var itemValue = new DefineExpression(itemKey, expression);

            return(new KeyValuePair <WordExpression, DefineExpression>(itemKey, itemValue));
        }
コード例 #2
0
        public override void Generate(ModuleContext context)
        {
            var funcExp = new WordExpression(context.NewUID(), debugInfo);
            var statExp = new WordExpression(context.NewUID(), debugInfo);
            var varExp  = new WordExpression(context.NewUID(), debugInfo);
            var initExp = new DefineNExpression(new List <Expression> {
                funcExp, statExp, varExp
            }, items2List);
            var whileExp = new LoopExpression(moduleExp);
            var retExp   = new WordExpression(context.NewUID(), debugInfo);
            var retDef   = new DefineExpression(retExp, new CallExpression(funcExp, new RightList1Expression(new List <Expression> {
                statExp, varExp
            })));
            var callExp = new UnpackExpression(retExp);
            var nextExp = new BindNExpression(new LeftList2Expression(items1List), new RightList2Expression(new List <Expression> {
                callExp
            }));
            var rebindExp = new BindExpression(varExp, items1List[0]);
            var breakExp  = new BreakExpression();
            var exitExp   = new IfExpression(new EqualExpression(varExp, new NilExpression()), new ModuleExpression(new List <Expression> {
                breakExp
            }));

            moduleExp.itemsList.InsertRange(0, new Expression[] { retDef, nextExp, rebindExp, exitExp });
            initExp.Generate(context);
            whileExp.Generate(context);
        }
コード例 #3
0
 public FunctionNExpression(List <Expression> list, int position, int len)
 {
     isStatement = true;
     type        = Type.Function;
     debugInfo   = list[position].debugInfo;
     nameExp     = (WordExpression)list[position + 1];
     argsList    = ((WordList1Expression)list[position + 3]).ToParams();
     moduleExp   = list[position + 5];
 }