Exemplo n.º 1
0
            public override Evaluation Analyze(LambdaFunctionExpr node, Analyzer analyzer, ExInfoFromParent info)
            {
                // construct fake signature containing both - use params and regular params
                var allparams = new List <FormalParam>(node.Signature.FormalParams);

                if (node.UseParams != null)
                {
                    allparams.InsertRange(0, node.UseParams);
                }
                var signature = new Signature(false, allparams);

                //
                function = new PhpLambdaFunction(signature, analyzer.SourceUnit, node.Span);
                function.WriteUp(new TypeSignature(FormalTypeParam.EmptyList).ToPhpRoutineSignature(function));

                SignatureCompiler.AnalyzeMembers(signature, analyzer, function);

                //attributes.Analyze(analyzer, this);

                // ensure 'use' parameters in parent scope:
                if (node.UseParams != null)
                {
                    foreach (var p in node.UseParams)
                    {
                        analyzer.CurrentVarTable.Set(p.Name, p.PassedByRef);
                    }
                }

                // function is analyzed even if it is unreachable in order to discover more errors at compile-time:
                analyzer.EnterFunctionDeclaration(function);

                //typeSignature.Analyze(analyzer);
                SignatureCompiler.Analyze(signature, analyzer);

                node.Body.Analyze(analyzer);

                // validate function and its body:
                function.ValidateBody(analyzer.ErrorSink);

                analyzer.LeaveFunctionDeclaration();

                return(new Evaluation(node));
            }
Exemplo n.º 2
0
            void IDeclarationNode.AnalyzeMembers(Analyzer /*!*/ analyzer)
            {
                var attributes = node.Attributes;

                if (attributes != null)
                {
                    attributes.AnalyzeMembers(analyzer, function.Declaration.Scope);
                }

                TypeSignatureCompiler.AnalyzeMembers(node.TypeSignature, analyzer, function.Declaration.Scope);
                SignatureCompiler.AnalyzeMembers(node.Signature, analyzer, function);

                // member-analyze the other versions:
                if (function.Version.Next != null)
                {
                    function.Version.Next.Declaration.Node.AnalyzeMembers(analyzer);
                }

                function.Declaration.Node = null;
            }