Exemple #1
0
 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);
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #6
0
        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);
        }