public override void Generate(ModuleContext context) { context.BeginLoop(); var bindIndex = new BindExpression(indexExp, beginExp); bindIndex.Generate(context); context.Add(new ByteCode { opCode = ByteCode.OpCode.Clear }); var beginLabel = new LabelExpression(context.NewUID(), indexExp.debugInfo); beginLabel.Generate(context); var jumpBegin = new LuaLabel(context.vm, beginLabel.value, beginLabel.index); condExp.Generate(context); var endLabel = new LabelExpression(context.NewUID(), indexExp.debugInfo); var jumpEnd = new LuaLabel(context.vm, endLabel.value, endLabel.index); context.Add(new ByteCode { opCode = ByteCode.OpCode.JumpIf, opArg = jumpEnd }); context.Add(new ByteCode { opCode = ByteCode.OpCode.Clear }); moduleExp.Generate(context); changeExp.Generate(context); context.Add(new ByteCode { opCode = ByteCode.OpCode.Jump, opArg = jumpBegin }); endLabel.Generate(context); jumpEnd.index = endLabel.index; context.EndLoop(jumpEnd); }
public override void Generate(ModuleContext context) { var funcExp = new FunctionAExpression(context.NewUID(), argsList, moduleExp); var propExp = new PropertyExpression(targetExp, ParserHelper.Word2String(nameExp)); var bindExp = new BindExpression(propExp, funcExp); bindExp.Generate(context); }