public override void VisitVariableDeclarationStatement(VariableDeclarationStatement variableDeclarationStatement) { foreach (var variable in variableDeclarationStatement.Variables) { VariableNames.Add(variable.Name); var lrr = (LocalResolveResult)Emitter.Resolver.ResolveNode(variable); Variables.Add(lrr.Variable); } base.VisitVariableDeclarationStatement(variableDeclarationStatement); }
public override void VisitCatchClause(CatchClause catchClause) { if (!ExcludeReadOnly && catchClause.VariableNameToken != null && !catchClause.VariableNameToken.IsNull) { VariableNames.Add(catchClause.VariableName); var lrr = (LocalResolveResult)Emitter.Resolver.ResolveNode(catchClause.VariableNameToken); Variables.Add(lrr.Variable); } base.VisitCatchClause(catchClause); }
public override void VisitForeachStatement(ForeachStatement foreachStatement) { if (foreachStatement.VariableNameToken != null && !foreachStatement.VariableNameToken.IsNull) { VariableNames.Add(foreachStatement.VariableName); var rr = (ForEachResolveResult)Emitter.Resolver.ResolveNode(foreachStatement); Variables.Add(rr.ElementVariable); } base.VisitForeachStatement(foreachStatement); }
public void Visit(ExprNode exprNode) { if (!(exprNode is ExprVariableNode)) { return; } HasVariables = true; var variableNode = (ExprVariableNode)exprNode; if (VariableNames == null) { VariableNames = new HashSet <string>(); } VariableNames.Add(variableNode.VariableName); }
public void AddVariable(string variableName, string variableType) { string [] types = { "string", "String", "int", "double", "float", "bool", "long" }; bool isTypeRecognised = false; foreach (string type in types) { if (type.Equals(variableType)) { isTypeRecognised = true; break; } } if (!isTypeRecognised) { throw new ObjectTypeDeclarationException("Type is not recognised"); } VariableNames.Add(variableName); VariableTypes.Add(variableType); }
public void Analyze(AstNode node) { if (node is ForStatement) { node = ((ForStatement)node).EmbeddedStatement; } VariableNames.Clear(); if (node is ForeachStatement && !ExcludeReadOnly) { var foreachStatement = (ForeachStatement)node; if (foreachStatement.VariableNameToken != null && !foreachStatement.VariableNameToken.IsNull) { VariableNames.Add(foreachStatement.VariableName); var rr = (ForEachResolveResult)Emitter.Resolver.ResolveNode(foreachStatement); Variables.Add(rr.ElementVariable); } } node.AcceptVisitor(this); }