Exemplo n.º 1
0
        public void process(P5Scalar tree)
        {
            var use_stash = parser_runtime.SymbolTable.GetPackage(parser_runtime, "Language::P::ParseTree::Use", false);
            var sub_stash = parser_runtime.SymbolTable.GetPackage(parser_runtime, "Language::P::ParseTree::NamedSubroutine", false);
            var lex_stash = parser_runtime.SymbolTable.GetPackage(parser_runtime, "Language::P::ParseTree::LexicalState", false);

            if (tree.BlessedReferenceStash(parser_runtime).IsDerivedFrom(parser_runtime, use_stash))
            {
                var code = _to_ir("generate_use", tree);
                var subs = NetGlue.UnwrapArray<Subroutine>(parser_runtime, code);

                foreach (var sub in subs)
                    mod_generator.Generate(sub);

                return;
            }

            if (tree.BlessedReferenceStash(parser_runtime).IsDerivedFrom(parser_runtime, sub_stash))
            {
                var code = _to_ir("generate_subroutine", tree);
                var subs = NetGlue.UnwrapArray<Subroutine>(parser_runtime, code);

                foreach (var sub in subs)
                    mod_generator.Generate(sub);

                return;
            }

            if (tree.BlessedReferenceStash(parser_runtime).IsDerivedFrom(parser_runtime, lex_stash))
            {
                P5Array arglist_changed =
                    new P5Array(parser_runtime, tree);
                int changed = arglist_changed.CallMethod(parser_runtime, Opcode.ContextValues.SCALAR, "changed").AsInteger(parser_runtime);

                if ((changed & Opcode.CHANGED_PACKAGE) != 0)
                {
                    P5Array arglist_package =
                        new P5Array(parser_runtime, tree);
                    string pack = arglist_package.CallMethod(parser_runtime, Opcode.ContextValues.SCALAR, "package").AsString(parser_runtime);

                    runtime.SymbolTable.GetPackage(runtime, pack, true);
                }
            }

            pending.Add(tree.Clone(parser_runtime, 0) as P5Scalar);
        }