private static void AnalyzeStatement(VB.Statement s, AnalysisScope scope) { if (s is VB.MethodDeclaration) { string methodName = ((VB.MethodDeclaration)s).Name.Name.ToLower(); scope.FunctionTable.Add(methodName); ParameterExpression method = Expression.Parameter(typeof(object)); scope.Names[methodName] = method; } else if (s is VB.LocalDeclarationStatement) { AnalyzeDeclarationExpr((VB.LocalDeclarationStatement)s, scope); } else if (s is VB.IfBlockStatement) { AnalyzeIfBlockStatement((VB.IfBlockStatement)s, scope); } else if (s is VB.SelectBlockStatement) { AnalyzeSelectBlockStatement((VB.SelectBlockStatement)s, scope); } else if (s is VB.BlockStatement) { AnalyzeBlockStatement((VB.BlockStatement)s, scope); } }
public void GetVariablesInScope(List <string> names, List <ParameterExpression> parameters) { AnalysisScope scope = this; while (!scope.IsModule) { foreach (string name in _names.Keys) { names.Add(name); parameters.Add(_names[name]); } scope = scope.Parent; } //Now we are dealing with module scope. We want to exclude lambda variables Set <string> functionTable = FunctionTable; foreach (string name in _names.Keys) { if (!functionTable.Contains(name)) { names.Add(name); parameters.Add(_names[name]); } } }
public static void AnalyzeBlockStatement(VB.BlockStatement block, AnalysisScope scope) { if (block.Statements != null) { foreach (VB.Statement stmt in block.Statements) { AnalyzeStatement(stmt, scope); } } }
public static void AnalyzeFile(Dlrsoft.VBScript.Parser.ScriptBlock block, AnalysisScope scope) { Debug.Assert(scope.IsModule); if (block.Statements != null) { foreach (VB.Statement s in block.Statements) { AnalyzeStatement(s, scope); } } }
private static void AnalyzeIfBlockStatement(VB.IfBlockStatement block, AnalysisScope scope) { AnalyzeBlockStatement(block, scope); if (block.ElseIfBlockStatements != null && block.ElseIfBlockStatements.Count > 0) { foreach (VB.ElseIfBlockStatement elseif in block.ElseIfBlockStatements) { AnalyzeBlockStatement(elseif, scope); } } if (block.ElseBlockStatement != null) { AnalyzeBlockStatement(block.ElseBlockStatement, scope); } }
public AnalysisScope(AnalysisScope parent, string name, VBScript runtime, ParameterExpression runtimeParam, ParameterExpression moduleParam, ISourceMapper mapper) { _parent = parent; _name = name; _runtime = runtime; _runtimeParam = runtimeParam; _moduleParam = moduleParam; _mapper = mapper; if (_moduleParam != null) { _functionTable = new Set <string>(StringComparer.InvariantCultureIgnoreCase); _errors = new List <VBScriptSyntaxError>(); _docInfos = new Dictionary <string, SymbolDocumentInfo>(); } _names = new Dictionary <string, ParameterExpression>(); }
public AnalysisScope(AnalysisScope parent, string name) : this(parent, name, null, null, null, null) { }
private static void AnalyzeDeclarationExpr(VB.LocalDeclarationStatement stmt, AnalysisScope scope) { bool isConst = false; if (stmt.Modifiers != null) { if (stmt.Modifiers.ModifierTypes == VB.ModifierTypes.Const) { isConst = true; } } foreach (VB.VariableDeclarator d in stmt.VariableDeclarators) { foreach (VB.VariableName v in d.VariableNames) { string name = v.Name.Name.ToLower(); ParameterExpression p = Expression.Parameter(typeof(object), name); scope.Names.Add(name, p); } } }
private static void AnalyzeSelectBlockStatement(VB.SelectBlockStatement block, AnalysisScope scope) { AnalyzeBlockStatement(block, scope); if (block.CaseBlockStatements != null && block.CaseBlockStatements.Count > 0) { foreach (VB.CaseBlockStatement caseStmt in block.CaseBlockStatements) { AnalyzeBlockStatement(caseStmt, scope); } } if (block.CaseElseBlockStatement != null) { AnalyzeBlockStatement(block.CaseElseBlockStatement, scope); } }