コード例 #1
0
        public override void CheckSemantic(IASTContext context)
        {
            if (Instance != null)
            {
                Instance.CheckSemantic(context);
                Function = context.GetFunctionDeclaration(Instance.NetType, Name);
            }
            else
            {
                Function = context.GetFunctionDeclaration(Name);
            }

            if (Function == null)
            {
                throw new RecognitionException($"Function {Name} not found in context", Col, Row);
            }

            Type    = Function.ReturnType;
            NetType = Function.ReturnNetType;

            foreach (var parameter in Parameters)
            {
                parameter.CheckSemantic(context);
            }

            if (!Function.CheckParamterTypes(Parameters))
            {
                throw new RecognitionException($"Function {Name} parameters does not match", Col, Row);
            }
        }
コード例 #2
0
        public void AddFunction(string name, Delegate function)
        {
            FunctionDeclaration f = new FunctionDeclaration(name, function.Method)
            {
                Target = function.Target
            };

            functions.Add(f.Name, f);
        }
コード例 #3
0
        public override void CheckSemantic(IASTContext context)
        {
            if (Instance != null)
            {
                Instance.CheckSemantic(context);
                Function = context.GetFunctionDeclaration(Instance.NetType, Name);
            }
            else
            {
                Function = context.GetFunctionDeclaration(Name);
            }

            if (Function == null)
            {
                throw new RecognitionException($"Function {Name} not found in context", Col, Row);
            }

            Type    = Function.ReturnType;
            NetType = Function.ReturnNetType;

            if (Function.IsQueryMethod)
            {
                var genArg = Instance.NetType.GetGenericArguments();
                _parameter = System.Linq.Expressions.Expression.Parameter(genArg[0]);

                context = new QueryASTContext
                {
                    ModelType = genArg[0],
                    Parameter = _parameter
                };
            }

            foreach (var parameter in Parameters)
            {
                parameter.CheckSemantic(context);
            }

            if (!Function.IsQueryMethod && !Function.CheckParamterTypes(Parameters))
            {
                throw new RecognitionException($"Function {Name} parameters does not match", Col, Row);
            }
        }
コード例 #4
0
        public void AddFunction(string name, MethodInfo method)
        {
            FunctionDeclaration f = new FunctionDeclaration(name, method);

            functions.Add(f.Name, f);
        }