コード例 #1
0
        public override void Generate(ScriptLoader owner)
        {
            LookaheadStack <INodeEnumerator> nodes  = this.nodes;
            LookaheadStack <uint>            states = this.states;

            int    proc_state = 0;
            object proc_arg   = null;

            INodeEnumerator   ne   = m_enumerator;
            IExceptionHandler ehnd = m_handler;

loop:
            uint state = states.PopOrDefault();

            while (ne.MoveNext())
            {
                INode node = ne.Current;
                if (node.ChildCount == 0)
                {
                    bool goNext;
                    do
                    {
                        goNext = OnGenerate(node.GetToken(), state, ref proc_state, ref proc_arg);

                        if (ehnd.FailCount > 0)
                        {
                            ne.Dispose();
                            while (nodes.Count > 0)
                            {
                                nodes.Pop().Dispose();
                            }

                            return;
                        }
                        else if (proc_state != 0)
                        {
                            proc_arg = OnRequested(ref state, ref proc_state, proc_arg);
                        }

                        // 다음으로 넘어가지 않는다
                        // 반복
                    } while (!goNext);
                }
                else
                {
                    nodes.Push(ne);
                    ne = node.GetEnumerator();
                }
            }

            ne.Dispose();
            if (nodes.Count > 0)
            {
                ne = nodes.Pop();
                goto loop;
            }

            // 끝내기 전에 마무리지어야 한다
        }
コード例 #2
0
        public static void AddExprState(LookaheadStack <uint> states, uint start, uint end)
        {
            states.Push(end);

            states.Push(0);
            //states.Push(CodeGeneratorStates.STATE_METHODBODY);

            states.Push(start);
        }
コード例 #3
0
        private ILCodeGenerator(IExceptionHandler handler, INode parsedNode) : base(handler, parsedNode)
        {
            stackTypes = new InternalTypeStack(64);

            codes = new List <CILCode>(32);

            absmeths = new List <int>();
            absflds  = new List <int>();

            methods    = new Dictionary <ILMethodSignature, ILMethodBuildState>();
            fields     = new Dictionary <HashedString, FieldBuilder>();
            locOrParam = new Dictionary <HashedString, ScopeVarInfo>();

            states = new LookaheadStack <uint>(16);
            nodes  = new LookaheadStack <INodeEnumerator>(16);

            labelMgr = new LabelManager();
        }
 public static void InnerState(this LookaheadStack <uint> inst, uint root, uint inner)
 {
     inst.Push(root);
     inst.Push(inner);
 }