예제 #1
0
        public Subroutine(Runtime runtime, P5Scalar args)
        {
            var arg = args.DereferenceHash(runtime);

            Flags = arg.GetItem(runtime, "flags").AsInteger(runtime);
            Outer = (Subroutine)NetGlue.UnwrapValue(arg.GetItem(runtime, "outer"), typeof(Subroutine));

            var name = arg.GetItem(runtime, "name") as P5Scalar;
            Name = name.IsDefined(runtime) ? name.AsString(runtime) : null;
            if (arg.ExistsKey(runtime, "regex_string"))
                OriginalRegex = arg.GetItem(runtime, "regex_string").AsString(runtime);
            Inner = new List<Subroutine>();
            BasicBlocks = new List<BasicBlock>();
            Lexicals = new List<LexicalInfo>();
            Scopes = new List<Scope>();
            LexicalStates = new List<LexicalState>();

            if (arg.ExistsKey(runtime, "prototype"))
            {
                var proto = arg.GetItem(runtime, "prototype") as P5Scalar;
                if (proto.IsDefined(runtime))
                    Prototype = NetGlue.UnwrapArray<int>(runtime, proto);
            }

            var ls = new LexicalState();

            ls.Scope = 0;
            ls.Hints = 0;
            ls.Package = "main";
            ls.Warnings = null;

            LexicalStates.Add(ls);
        }
예제 #2
0
        public Scope(Runtime runtime, P5Scalar args)
        {
            var arg = args.DereferenceHash(runtime);

            Opcodes = new List<List<Opcode>>();

            Outer = arg.GetItem(runtime, "outer").AsInteger(runtime);
            Id = arg.GetItem(runtime, "id").AsInteger(runtime);
            Flags = arg.GetItem(runtime, "flags").AsInteger(runtime);
            Context = arg.GetItem(runtime, "context").AsInteger(runtime);
            // TODO reference to basic block
            Exception = (BasicBlock)NetGlue.UnwrapValue(arg.GetItem(runtime, "exception"), typeof(BasicBlock));
            LexicalState = arg.GetItem(runtime, "lexical_state").AsInteger(runtime);

            SetPos(runtime, arg.GetItem(runtime, "pos_s"), out Start);
            SetPos(runtime, arg.GetItem(runtime, "pos_e"), out End);
        }
예제 #3
0
        public LexicalInfo(Runtime runtime, P5Scalar args)
        {
            var arg = args.DereferenceHash(runtime);

            Index = arg.GetItem(runtime, "index").AsInteger(runtime);
            OuterIndex = arg.GetItem(runtime, "outer_index").AsInteger(runtime);
            Name = arg.GetItem(runtime, "name").AsString(runtime);
            Slot = (Opcode.Sigil)arg.GetItem(runtime, "sigil").AsInteger(runtime);
            Level = arg.GetItem(runtime, "level").AsInteger(runtime);
            InPad = arg.GetItem(runtime, "in_pad").AsBoolean(runtime);
        }
예제 #4
0
        public LexicalState(Runtime runtime, P5Scalar args)
        {
            var arg = args.DereferenceHash(runtime);

            Scope = arg.GetItem(runtime, "scope").AsInteger(runtime);
            Hints = arg.GetItem(runtime, "hints").AsInteger(runtime);
            Package = arg.GetItem(runtime, "package").AsString(runtime);
            Warnings = arg.GetItem(runtime, "warnings").AsString(runtime);
        }
예제 #5
0
        // TODO change it to P5Hash when auto-dereference is implemented,
        //      and maybe use a plain .Net map
        public void start_code_generation(P5Scalar args)
        {
            var argmap = args.DereferenceHash(parser_runtime);

            file_name = argmap.GetItem(parser_runtime, "file_name").AsString(parser_runtime);

            pending = new List<P5Scalar>();

            P5Array arglist_create_main =
                new P5Array(parser_runtime,
                            intermediate,
                            new P5Scalar(parser_runtime),
                            new P5Scalar(parser_runtime, false));
            arglist_create_main.CallMethod(parser_runtime, Opcode.ContextValues.SCALAR, "create_main");
        }