internal override Statement Analyze(FunctionDecl node, Analyzer analyzer) { // functions in incomplete (not emitted) class can't be emitted function.Declaration.IsInsideIncompleteClass = analyzer.IsInsideIncompleteClass(); var attributes = node.Attributes; if (attributes != null) { attributes.Analyze(analyzer, this); } // function is analyzed even if it is unreachable in order to discover more errors at compile-time: function.Declaration.IsUnreachable = analyzer.IsThisCodeUnreachable(); if (function.Declaration.IsUnreachable) { analyzer.ReportUnreachableCode(node.Span); } analyzer.EnterFunctionDeclaration(function); TypeSignatureCompiler.Analyze(node.TypeSignature, analyzer); SignatureCompiler.Analyze(node.Signature, analyzer); function.Validate(analyzer.ErrorSink); node.Body.Analyze(analyzer); // validate function and its body: function.ValidateBody(analyzer.ErrorSink); /* * if (docComment != null) * AnalyzeDocComment(analyzer); */ analyzer.LeaveFunctionDeclaration(); if (function.Declaration.IsUnreachable) { return(EmptyStmt.Unreachable); } else { // add entry point if applicable: analyzer.SetEntryPoint(function, node.Span); return(node); } }
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)); }