public static void CreateItems(APropertyDecl decl, List<MethodDescription> methods, out VariableDescription variable) { if (decl.GetName().Text == "") variable = null; else variable = new VariableDescription(decl); TextPoint getterStart, setterStart; getterStart = setterStart = TextPoint.FromCompilerCoords(decl.GetName()); if (decl.GetSetter() != null && decl.GetGetter() != null) { if (Util.TokenLessThan(((AABlock)decl.GetSetter()).GetToken(), ((AABlock)decl.GetGetter()).GetToken())) getterStart = TextPoint.FromCompilerCoords(((AABlock)decl.GetSetter()).GetToken()); else setterStart = TextPoint.FromCompilerCoords(((AABlock)decl.GetGetter()).GetToken()); } if (decl.GetGetter() != null) methods.Add(new MethodDescription(getterStart, decl.GetType(), (AABlock)decl.GetGetter(), decl.GetType())); if (decl.GetSetter() != null) methods.Add(new MethodDescription(setterStart, new AVoidType(new TVoid("void")), (AABlock)decl.GetSetter(), decl.GetType())); }
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 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); }
private void CheckPropertyAccessibility(APropertyDecl property, bool needSetter, Token token) { ErrorCollection.Error subError = new ErrorCollection.Error(property.GetName(), Util.GetAncestor<AASourceFile>(property), LocRM.GetString("ErrorText62")); if (!needSetter && property.GetGetter() == null) errors.Add(new ErrorCollection.Error(token, Util.GetAncestor<AASourceFile>(token), LocRM.GetString("ErrorText75"), false, subError)); if (needSetter && property.GetSetter() == null) errors.Add(new ErrorCollection.Error(token, Util.GetAncestor<AASourceFile>(token), LocRM.GetString("ErrorText75"), false, subError)); }
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 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()); }