Esempio n. 1
0
        public ExprRecResult Recognize(CodeString Code, CodeString Function, CodeString[] Params,
                                       CodeString[] GenericParams, PluginRoot Plugin, ref ExpressionNode Out)
        {
            var State     = Plugin.State;
            var Container = Plugin.Container;

            int Func;

            if (Function.IsEqual("incbin_ptr"))
            {
                Func = 0;
            }
            else if (Function.IsEqual("incbin_size"))
            {
                Func = 1;
            }
            else
            {
                return(ExprRecResult.Unknown);
            }

            if (GenericParams != null && GenericParams.Length != 0)
            {
                State.Messages.Add(MessageId.NonGenericIdentifier, Function);
                return(ExprRecResult.Failed);
            }

            if (Params.Length != 1)
            {
                State.Messages.Add(MessageId.ParamCount, Code);
                return(ExprRecResult.Failed);
            }

            var IncBin = GetIncBin(Params[0], Plugin);

            if (IncBin == null)
            {
                return(ExprRecResult.Failed);
            }

            if (Func == 0)
            {
                Out = new DataPointerNode(Code, IncBin);
            }
            else if (Func == 1)
            {
                var Type = Container.GlobalContainer.CommonIds.UIntPtr;
                Out = new ConstExpressionNode(Type, new IntegerValue(IncBin.Length), Code);
            }
            else
            {
                throw new ApplicationException();
            }

            return(ExprRecResult.Succeeded);
        }
Esempio n. 2
0
        public ExprRecResult Recognize(CodeString Code, CodeString Function, CodeString[] Params,
                                       CodeString[] GenericParams, PluginRoot Plugin, ref ExpressionNode Out)
        {
            var State = Plugin.State;

            if (Function.IsEqual("id_desc_ptr"))
            {
                if (GenericParams != null && GenericParams.Length != 0)
                {
                    State.Messages.Add(MessageId.NonGenericIdentifier, Function);
                    return(ExprRecResult.Failed);
                }

                if (Params.Length != 1)
                {
                    State.Messages.Add(MessageId.ParamCount, Code);
                    return(ExprRecResult.Failed);
                }

                var Container = Plugin.Container;
                var Id        = Container.RecognizeIdentifier(Params[0]);
                if (Id == null)
                {
                    return(ExprRecResult.Failed);
                }

                Out = new DataPointerNode(Code, Id);
                return(ExprRecResult.Succeeded);
            }

            if (Function.IsEqual("assembly_desc_ptr"))
            {
                var Global = Plugin.Container.GlobalContainer;
                if (GenericParams != null && GenericParams.Length != 0)
                {
                    State.Messages.Add(MessageId.NonGenericIdentifier, Function);
                    return(ExprRecResult.Failed);
                }

                if (Params.Length == 0)
                {
                    Out = new DataPointerNode(Code, Global.OutputAssembly);
                    return(ExprRecResult.Succeeded);
                }
                else
                {
                    if (Params.Length != 1)
                    {
                        State.Messages.Add(MessageId.ParamCount, Code);
                        return(ExprRecResult.Failed);
                    }

                    string String;
                    if (!Constants.RecognizeString(Params[0], Plugin, out String))
                    {
                        return(ExprRecResult.Failed);
                    }

                    var Assembly = Global.GetAssembly(String);
                    if (Assembly == null)
                    {
                        State.Messages.Add(MessageId.UnknownId, Params[0]);
                        return(ExprRecResult.Failed);
                    }

                    Out = new DataPointerNode(Code, Assembly);
                    return(ExprRecResult.Succeeded);
                }
            }

            return(ExprRecResult.Unknown);
        }