public override void Compile(Execution.VM.ByteCode bc) { if (m_Statements != null) { foreach (Statement s in m_Statements) { s.Compile(bc); } } }
public override void Compile(Execution.VM.ByteCode bc) { using (bc.EnterSource(m_Do)) bc.Emit_Enter(m_StackFrame); m_Block.Compile(bc); using (bc.EnterSource(m_End)) bc.Emit_Leave(m_StackFrame); }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Clean(m_StackFrame); Address = bc.GetJumpPointForLastInstruction(); foreach (var gotostat in m_Gotos) { gotostat.SetAddress(this.Address); } }
public override void Compile(Execution.VM.ByteCode bc) { foreach (var exp in expressions) { exp.Compile(bc); } if (expressions.Count > 1) { bc.Emit_MkTuple(expressions.Count); } }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_BeginFn(m_StackFrame, "<chunk-root>"); bc.Emit_Args(m_VarArgs); bc.Emit_Literal(DynValue.NewTable(m_GlobalEnv)); bc.Emit_Store(m_Env, 0, 0); bc.Emit_Pop(); m_Block.Compile(bc); bc.Emit_Ret(0); }
public override void Compile(Execution.VM.ByteCode bc) { if (m_Statements != null) { foreach (Statement s in m_Statements) { if (!(s is NullStatement)) { bc.Emit_Debug(s.TreeNode.GetText()); s.Compile(bc); } } } }
public override void Compile(Execution.VM.ByteCode bc) { using (bc.EnterSource(m_Ref)) { if (m_Expression != null) { m_Expression.Compile(bc); bc.Emit_Ret(1); } else { bc.Emit_Ret(0); } } }
private int SetMethod(Execution.VM.ByteCode bc) { int cnt = 0; cnt += bc.Emit_Load(m_FuncSymbol); foreach (string str in m_TableAccessors) { bc.Emit_Index(DynValue.NewString(str), true); cnt += 1; } bc.Emit_IndexSet(0, 0, DynValue.NewString(m_MethodName), true); return(1 + cnt); }
public override void Compile(Execution.VM.ByteCode bc) { m_Exp1.Compile(bc); if (m_Exps != null) { for (int i = 0; i < m_Ops.Count; i++) { CompileOp(bc, m_Ops[i], m_Exps[i]); } } { CompileOp(bc, m_Operator, m_Exp2); } }
public override void Compile(Execution.VM.ByteCode bc) { List <Instruction> endJumps = new List <Instruction>(); Instruction lastIfJmp = null; foreach (var ifblock in m_Ifs) { using (bc.EnterSource(ifblock.Source)) { if (lastIfJmp != null) { lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); } ifblock.Exp.Compile(bc); lastIfJmp = bc.Emit_Jump(OpCode.Jf, -1); bc.Emit_Enter(ifblock.StackFrame); ifblock.Block.Compile(bc); } using (bc.EnterSource(m_End)) bc.Emit_Leave(ifblock.StackFrame); endJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); } lastIfJmp.NumVal = bc.GetJumpPointForNextInstruction(); if (m_Else != null) { using (bc.EnterSource(m_ElseRef)) { bc.Emit_Enter(m_ElseStackFrame); m_Else.Compile(bc); } using (bc.EnterSource(m_End)) bc.Emit_Leave(m_ElseStackFrame); } foreach (var endjmp in endJumps) { endjmp.NumVal = bc.GetJumpPointForNextInstruction(); } }
public override void Compile(Execution.VM.ByteCode bc) { Instruction meta = bc.Emit_Meta("<chunk-root>", OpCodeMetadataType.ChunkEntrypoint); int metaip = bc.GetJumpPointForLastInstruction(); bc.Emit_BeginFn(m_StackFrame); bc.Emit_Args(m_VarArgs); bc.Emit_Load(SymbolRef.Upvalue(WellKnownSymbols.ENV, 0)); bc.Emit_Store(m_Env, 0, 0); bc.Emit_Pop(); m_Block.Compile(bc); bc.Emit_Ret(0); meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; }
public override void Compile(Execution.VM.ByteCode bc) { List <int> endJumps = new List <int>(); int lastIfJmp = -1; foreach (var ifblock in m_Ifs) { using (bc.EnterSource(ifblock.Source)) { if (lastIfJmp != -1) { bc.SetNumVal(lastIfJmp, bc.GetJumpPointForNextInstruction()); } ifblock.Exp.CompilePossibleLiteral(bc); lastIfJmp = bc.Emit_Jump(OpCode.Jf, -1); bc.Emit_Enter(ifblock.StackFrame); ifblock.Block.Compile(bc); } using (bc.EnterSource(m_End)) bc.Emit_Leave(ifblock.StackFrame); endJumps.Add(bc.Emit_Jump(OpCode.Jump, -1)); } bc.SetNumVal(lastIfJmp, bc.GetJumpPointForNextInstruction()); if (m_Else != null) { using (bc.EnterSource(m_Else.Source)) { bc.Emit_Enter(m_Else.StackFrame); m_Else.Block.Compile(bc); } using (bc.EnterSource(m_End)) bc.Emit_Leave(m_Else.StackFrame); } foreach (var endjmp in endJumps) { bc.SetNumVal(endjmp, bc.GetJumpPointForNextInstruction()); } }
public override void Compile(Execution.VM.ByteCode bc) { Instruction meta = bc.Emit_FuncMeta("<chunk-root>"); int metaip = bc.GetJumpPointForLastInstruction(); bc.Emit_BeginFn(m_StackFrame); bc.Emit_Args(m_VarArgs); bc.Emit_Literal(DynValue.NewTable(m_GlobalEnv)); bc.Emit_Store(m_Env, 0, 0); bc.Emit_Pop(); m_Block.Compile(bc); bc.Emit_Ret(0); meta.NumVal = bc.GetJumpPointForLastInstruction() - metaip; }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_NewTable(m_Shared); foreach (var kvp in m_CtorArgs) { kvp.Key.Compile(bc); kvp.Value.Compile(bc); bc.Emit_TblInitN(); } for (int i = 0; i < m_PositionalValues.Count; i++) { m_PositionalValues[i].Compile(bc); bc.Emit_TblInitI(i == m_PositionalValues.Count - 1); } }
public override void Compile(Execution.VM.ByteCode bc) { using (bc.EnterSource(m_Ref)) { foreach (var exp in m_RValues) { exp.Compile(bc); } for (int i = 0; i < m_LValues.Length; i++) { m_LValues[i].CompileAssignment(bc, Math.Max(m_RValues.Length - 1 - i, 0), // index of r-value i - Math.Min(i, m_RValues.Length - 1)); // index in last tuple } bc.Emit_Pop(m_RValues.Length); } }
private int SetMethod(Execution.VM.ByteCode bc) { int cnt = 0; cnt += bc.Emit_Load(m_FuncSymbol); foreach (string str in m_TableAccessors) { bc.Emit_Literal(DynValue.NewString(str)); bc.Emit_Index(); cnt += 2; } bc.Emit_Literal(DynValue.NewString(m_MethodName)); bc.Emit_IndexSet(0, 0); return 2 + cnt; }
public override void Compile(Execution.VM.ByteCode bc) { using (bc.EnterSource(m_SourceRef)) { if (m_Local) { bc.Emit_Literal(DynValue.Nil); bc.Emit_Store(m_FuncSymbol, 0, 0); m_FuncDef.Compile(bc, () => SetFunction(bc, 2), m_FriendlyName); } else if (m_MethodName == null) { m_FuncDef.Compile(bc, () => SetFunction(bc, 1), m_FriendlyName); } else { m_FuncDef.Compile(bc, () => SetMethod(bc), m_FriendlyName); } } }
public override void Compile(Execution.VM.ByteCode bc) { throw new InvalidOperationException(); }
public override void Compile(Execution.VM.ByteCode bc) { throw new NotImplementedException(); }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Literal(m_Value); }
public void CompileAssignment(Execution.VM.ByteCode bc, int stackofs, int tupleidx) { bc.Emit_Store(m_Ref, stackofs, tupleidx); }
public override void Compile(Execution.VM.ByteCode bc) { bc.Emit_Load(m_Ref); }
private int SetFunction(Execution.VM.ByteCode bc, int numPop) { int num = bc.Emit_Store(m_FuncSymbol, 0, 0); bc.Emit_Pop(numPop); return num + 1; }
public override void Compile(Execution.VM.ByteCode bc) { expression.Compile(bc); bc.Emit_Scalar(); }
public override void Compile(Execution.VM.ByteCode bc) { }