protected override void VisitVariableDecleration(VariableDeclerationNode node) { BuildString.Append(' '); BuildString.Append(node.DeclerationType); if (node.Declerations.ChildCount == 1) { SingleVariableDeclerationNode decleration = node.Declerations.First(); BuildString.Append(' '); BuildString.Append(decleration.Identifier); if (decleration.DefaultValue != null) { Visit(decleration.DefaultValue); } } else { foreach (SingleVariableDeclerationNode decleration in node.Declerations) { Indent(); BuildString.Append(decleration.Identifier); if (decleration.DefaultValue != null) { Visit(decleration.DefaultValue); } Dedent(); } } }
public BlockScope CollectIdentifiers(BlockNode block) { DeclaringScope declaringScope = DeclaringScope.MethodLike; if (block.Parent is ClassTypeDeclerationNode) { declaringScope = DeclaringScope.ClassLike; } ListDictionary <string, TypeInformation> scope = new ListDictionary <string, TypeInformation>(); foreach (var child in block) { if (child.Type == NodeType.VariableDecleration) { VariableDeclerationNode variableNode = (VariableDeclerationNode)child; foreach (var decleration in variableNode.Declerations) { string name = decleration.Identifier.Name; scope.Add(name, new TypeInformation( variableNode.DeclerationType.ActualType, variableNode.ProtectionLevel, decleration.Interval.a, declaringScope)); } } else if (child.Type == NodeType.MethodDecleration) { MethodDeclerationNode methodNode = (MethodDeclerationNode)child; string name = methodNode.Identifier.Value; scope.Add(name, new TypeInformation( methodNode.MethodSignature.ActualType, methodNode.ProtectionLevel, methodNode.Interval.a, declaringScope)); } } ConcurrentDictionary <string, TypeInformation[]> newscope = new ConcurrentDictionary <string, TypeInformation[]>(_scopeDictionary); foreach (KeyValuePair <string, List <TypeInformation> > pair in scope) { newscope.TryAdd(pair.Key, pair.Value.ToArray()); } return(new BlockScope(newscope, _classes)); }
protected override CrawlSyntaxNode VisitVariableDecleration(VariableDeclerationNode variableDecleration) { var node = (VariableDeclerationNode)base.VisitVariableDecleration(variableDecleration); //The type of each of the SingleVariableDeclarationNodes. List <CrawlType> singleVarDclTypes = node.Declerations .Select(x => x.Identifier.ResultType).ToList(); foreach (CrawlType type in singleVarDclTypes) { //If type given to variable doesn't match declaration type, return node with declaration type set to error intead. if (!type.Equals(node.DeclerationType.ActualType)) { TypeNode declarationError = node.DeclerationType.WithActualType(CrawlType.ErrorType); return(node.WithDeclerationType(declarationError)); } } return(node); }