Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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;
        }
Example #4
0
        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;
        }
Example #5
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);
            }
        }