示例#1
0
        internal static PexObjectVariableData Create(PexParseMeta parse)
        {
            var ret = new PexObjectVariableData();

            ret.VariableType = (VariableType)parse.Reader.ReadUInt8();
            switch (ret.VariableType)
            {
            case VariableType.Null:
                break;

            case VariableType.Identifier:
            case VariableType.String:
                ret.StringValue = parse.ReadString();
                break;

            case VariableType.Integer:
                ret.IntValue = parse.Reader.ReadInt32();
                break;

            case VariableType.Float:
                ret.FloatValue = parse.Reader.ReadFloat();
                break;

            case VariableType.Bool:
                //TODO: use ReadByte instead?
                ret.BoolValue = parse.Reader.ReadBoolean();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(ret);
        }
示例#2
0
        internal static PexObjectVariable Create(PexParseMeta parse)
        {
            var ret = new PexObjectVariable();

            ret.Name         = parse.ReadString();
            ret.TypeName     = parse.ReadString();
            ret.RawUserFlags = parse.Reader.ReadUInt32();

            ret.VariableData = PexObjectVariableData.Create(parse);
            return(ret);
        }
示例#3
0
        internal static PexObjectStructInfoMember Create(PexParseMeta parse)
        {
            var ret = new PexObjectStructInfoMember();

            ret.Name         = parse.ReadString();
            ret.TypeName     = parse.ReadString();
            ret.RawUserFlags = parse.Reader.ReadUInt32();
            ret.Value        = PexObjectVariableData.Create(parse);
            ret.IsConst      = parse.Reader.ReadBoolean();
            ret.DocString    = parse.ReadString();
            return(ret);
        }
示例#4
0
        internal static PexObjectFunctionInstruction Create(PexParseMeta parse)
        {
            var ret = new PexObjectFunctionInstruction();

            ret.OpCode = (InstructionOpcode)parse.Reader.ReadUInt8();

            var arguments = InstructionOpCodeArguments.GetArguments(ret.OpCode);

            foreach (var current in arguments)
            {
                var argument = PexObjectVariableData.Create(parse);
                ret.Arguments.Add(argument);

                switch (current)
                {
                case '*' when argument.VariableType != VariableType.Integer || !argument.IntValue.HasValue:
                    throw new InvalidDataException($"Variable-Length Arguments require an Integer Argument! Argument is {argument.VariableType}");

                case '*':
                {
                    for (var i = 0; i < argument.IntValue.Value; i++)
                    {
                        var anotherArgument = PexObjectVariableData.Create(parse);
                        ret.Arguments.Add(anotherArgument);
                    }

                    break;
                }

                //TODO: figure out what do to with this

                /*
                 * u apparently means unsigned integer and indicates that the integer value we get should be
                 * interpreted as an unsigned integer.
                 */
                case 'u' when argument.VariableType != VariableType.Integer:
                    throw new InvalidDataException($"Argument is unsigned integer but Variable Type is not integer: {argument.VariableType}");
                }
            }
            return(ret);
        }