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) { 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) { 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) { using (bc.EnterSource(m_Ref)) { if (m_Expression != null) { m_Expression.Compile(bc); bc.Emit_Ret(1); } else { bc.Emit_Ret(0); } } }
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); } }
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); } } }