Example #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);
        }
Example #2
0
        public static LexicalState ReadLexicalState(BinaryReader reader)
        {
            var state = new LexicalState();

            state.Scope = reader.ReadInt32();
            state.Hints = reader.ReadInt32();
            state.Package = ReadString(reader);
            state.Warnings = ReadString(reader);

            return state;
        }