protected override void VisitMethodCallSyntax(MethodCallSyntax pNode) { base.VisitMethodCallSyntax(pNode); //We only care about methods that aren't in the current module if (_module != null || Namespace != null) { System.Diagnostics.Debug.Assert(_module != null || _unit.HasReference(Namespace)); //Get the referenced module var mod = Namespace == null ? _module : _unit.GetReference(Namespace); //Find the method foreach (var m in mod.Module.Methods) { if (IsCalledMethod(m, pNode)) { var rn = new ReferencedNode(m, mod.Cache); if (!MethodNodes.Contains(rn)) { MethodNodes.Add(rn); //Get any type/methods that this method references var mrv = new ModuleReferenceVisitor(mod.Cache, _context, mod); mrv.MethodNodes.Add(rn); mrv.Visit(m); MethodNodes.AddRange(mrv.MethodNodes); TypeNodes.AddRange(mrv.TypeNodes); } } } } }
protected override void VisitTypeSyntax(TypeSyntax pNode) { //TODO i need to have <T> after methods so we can define our generic types and propagate them foreach (var a in pNode.GenericArguments) { Visit(a); } var result = _unit.FromString(pNode, out SmallType type); switch (result) { //case Compiler.FindResult.NotFound: // CompilerErrors.UndeclaredType(name, pNode.Span); // break; case Compiler.FindResult.IncorrectScope: CompilerErrors.TypeNotInScope(SyntaxHelper.GetFullTypeName(pNode), pNode.Span); break; } if (type.IsGenericType) { type = _unit.MakeConcreteType(type, SyntaxHelper.SelectNodeTypes(pNode.GenericArguments)); } pNode.SetType(type); if (pNode.Namespace != null && !_unit.HasReference(pNode.Namespace.Value)) { CompilerErrors.NamespaceNotDefined(pNode.Namespace, pNode.Span); } }
private bool ValidateType(NamespaceSyntax pNamespace, string pType, SyntaxNode pNode) { //Validate that all namespaces exists //Validate that the trait type exists if (pNamespace != null && !_unit.HasReference(pNamespace.Value)) { CompilerErrors.NamespaceNotDefined(pNamespace, pNode.Span); return(false); } else if (!_unit.IsTypeDefined(pNamespace, pType)) { CompilerErrors.UndeclaredType(pType, pNode.Span); return(false); } return(true); }