public override void CaseAPropertyDecl(APropertyDecl node) { InAPropertyDecl(node); if (node.GetSetter() != null) { node.GetSetter().Apply(this); } if (node.GetGetter() != null) { node.GetGetter().Apply(this); } if (node.GetName() != null) { node.GetName().Apply(this); } if (node.GetType() != null) { node.GetType().Apply(this); } if (node.GetStatic() != null) { node.GetStatic().Apply(this); } if (node.GetVisibilityModifier() != null) { node.GetVisibilityModifier().Apply(this); } OutAPropertyDecl(node); }
public override void OutAPropertyDecl(APropertyDecl node) { if (node.GetGetter() != null) { CheckReturns returnChecker = new CheckReturns(); node.GetGetter().Apply(returnChecker); if (!returnChecker.Returned) { errors.Add(new ErrorCollection.Error(node.GetName(), currentSourceFile, LocRM.GetString("ErrorText158"))); } } //If the return type or the type of any formals is a private struct, and the method is a public context, give an error { //Is public context if (node.GetVisibilityModifier() is APublicVisibilityModifier) { PType type = node.GetType(); int i = 0; FindPrivateTypes finder = new FindPrivateTypes(data); type.Apply(finder); if (finder.PrivateTypes.Count > 0) { List<ErrorCollection.Error> subErrors = new List<ErrorCollection.Error>(); List<PDecl> usedDecls = new List<PDecl>(); foreach (ANamedType namedType in finder.PrivateTypes) { if (data.StructTypeLinks.ContainsKey(namedType)) { AStructDecl decl = data.StructTypeLinks[namedType]; if (usedDecls.Contains(decl)) continue; usedDecls.Add(decl); subErrors.Add(new ErrorCollection.Error(decl.GetName(), LocRM.GetString("ErrorText64"))); } else if (data.DelegateTypeLinks.ContainsKey(namedType)) { AMethodDecl decl = data.DelegateTypeLinks[namedType]; if (usedDecls.Contains(decl)) continue; usedDecls.Add(decl); subErrors.Add(new ErrorCollection.Error(decl.GetName(), LocRM.GetString("ErrorText154"))); } } errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText155"), false, subErrors.ToArray())); } } } base.OutAPropertyDecl(node); }
public override void OutAPropertyDecl(APropertyDecl node) { //If it's protected, it must be in a struct if (!Util.HasAncestor<AStructDecl>(node)) { if (node.GetVisibilityModifier() is AProtectedVisibilityModifier) errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText184"))); } base.OutAPropertyDecl(node); }
public VariableDescription(APropertyDecl property) { Name = property.GetName().Text; IsArrayProperty = Name == "array property"; if (IsArrayProperty) Name = ""; Type = Util.TypeToString(property.GetType()); PlacementPrefix = "Property"; VariableType = VariableTypes.Field; Const = false; IsStatic = property.GetStatic() != null; Visibility = property.GetVisibilityModifier(); realType = (PType)property.GetType().Clone(); Line = property.GetName().Line; Position = TextPoint.FromCompilerCoords(property.GetName()); }