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 virtual void OutAPropertyDecl(APropertyDecl node) { DefaultOut(node); }
public virtual void InAPropertyDecl(APropertyDecl node) { DefaultIn(node); }
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 virtual void CaseAPropertyDecl(APropertyDecl node) { DefaultCase(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 override void CaseAThisArrayPropertyDecl(AThisArrayPropertyDecl node) { if (!Util.HasAncestor<AStructDecl>(node)) { /*if (node.GetVisibilityModifier() is AProtectedVisibilityModifier) errors.Add(new ErrorCollection.Error(node.GetToken(), "Only fields inside structs or classes can be marked as protected."));*/ if (!Util.HasAncestor<AEnrichmentDecl>(node)) errors.Add(new ErrorCollection.Error(node.GetToken(), LocRM.GetString("ErrorText185"))); } APropertyDecl replacer = new APropertyDecl(node.GetVisibilityModifier(), null, node.GetType(), new TIdentifier("", node.GetToken().Line, node.GetToken().Pos), node.GetGetter(), node.GetSetter()); List<AALocalDecl> locals = new List<AALocalDecl>(); if (replacer.GetGetter() != null) { AABlock block = (AABlock) replacer.GetGetter(); AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, (PType) node.GetArgType().Clone(), (TIdentifier) node.GetArgName().Clone(), null); block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local)); locals.Add(local); } if (replacer.GetSetter() != null) { AABlock block = (AABlock)replacer.GetSetter(); AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, (PType)node.GetArgType().Clone(), (TIdentifier)node.GetArgName().Clone(), null); block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local)); locals.Add(local); } data.ArrayPropertyLocals[replacer] = locals.ToArray(); node.ReplaceBy(replacer); replacer.Apply(this); }
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); }
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)); }
ArrayList New65() { ArrayList nodeList = new ArrayList(); ArrayList nodeArrayList8 = (ArrayList) Pop(); ArrayList nodeArrayList7 = (ArrayList) Pop(); ArrayList nodeArrayList6 = (ArrayList) Pop(); ArrayList nodeArrayList5 = (ArrayList) Pop(); ArrayList nodeArrayList4 = (ArrayList) Pop(); ArrayList nodeArrayList3 = (ArrayList) Pop(); ArrayList nodeArrayList2 = (ArrayList) Pop(); ArrayList nodeArrayList1 = (ArrayList) Pop(); PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0]; TStatic tstaticNode3 = (TStatic)nodeArrayList2[0]; PType ptypeNode4 = (PType)nodeArrayList3[0]; TIdentifier tidentifierNode5 = (TIdentifier)nodeArrayList4[0]; PBlock pblockNode6 = (PBlock)nodeArrayList7[0]; PBlock pblockNode7 = (PBlock)nodeArrayList6[0]; APropertyDecl pdeclNode1 = new APropertyDecl ( pvisibilitymodifierNode2, tstaticNode3, ptypeNode4, tidentifierNode5, pblockNode6, pblockNode7 ); nodeList.Add(pdeclNode1); return nodeList; }
public override void OutAPropertyDecl(APropertyDecl node) { AStructDecl pStruct = Util.GetAncestor<AStructDecl>(node); AEnrichmentDecl pEnrichment = Util.GetAncestor<AEnrichmentDecl>(node); if (pStruct != null) data.StructProperties[pStruct].Add(node); else if (pEnrichment == null) data.Properties.Add(new SharedData.DeclItem<APropertyDecl>(currentSourceFile, node)); base.OutAPropertyDecl(node); }
ArrayList New60() { ArrayList nodeList = new ArrayList(); ArrayList nodeArrayList6 = (ArrayList) Pop(); ArrayList nodeArrayList5 = (ArrayList) Pop(); ArrayList nodeArrayList4 = (ArrayList) Pop(); ArrayList nodeArrayList3 = (ArrayList) Pop(); ArrayList nodeArrayList2 = (ArrayList) Pop(); ArrayList nodeArrayList1 = (ArrayList) Pop(); PVisibilityModifier pvisibilitymodifierNode2 = (PVisibilityModifier)nodeArrayList1[0]; PType ptypeNode4 = (PType)nodeArrayList2[0]; TIdentifier tidentifierNode5 = (TIdentifier)nodeArrayList3[0]; PBlock pblockNode7 = (PBlock)nodeArrayList5[0]; APropertyDecl pdeclNode1 = new APropertyDecl ( pvisibilitymodifierNode2, null, ptypeNode4, tidentifierNode5, null, pblockNode7 ); nodeList.Add(pdeclNode1); return nodeList; }
public override void CaseAThisArrayPropertyDecl(AThisArrayPropertyDecl node) { APropertyDecl replacer = new APropertyDecl(node.GetVisibilityModifier(), null, node.GetType(), new TIdentifier("array property", node.GetToken().Line, node.GetToken().Pos), node.GetGetter(), node.GetSetter()); List<AALocalDecl> locals = new List<AALocalDecl>(); if (replacer.GetGetter() != null) { AABlock block = (AABlock)replacer.GetGetter(); AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, (PType)node.GetArgType().Clone(), (TIdentifier)node.GetArgName().Clone(), null); block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local)); locals.Add(local); } if (replacer.GetSetter() != null) { AABlock block = (AABlock)replacer.GetSetter(); AALocalDecl local = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, (PType)node.GetArgType().Clone(), (TIdentifier)node.GetArgName().Clone(), null); block.GetStatements().Insert(0, new ALocalDeclStm(new TSemicolon(";"), local)); locals.Add(local); } node.ReplaceBy(replacer); replacer.Apply(this); }
public override void CaseAPropertyDecl(APropertyDecl node) { VariableDescription variable; PropertyDescription.CreateItems(node, Methods, out variable); if (variable != null) Fields.Add(variable); }
public override void OutAPropertyDecl(APropertyDecl node) { VariableDescription variable; List<MethodDescription> methods = new List<MethodDescription>(); PropertyDescription.CreateItems(node, methods, out variable); foreach (MethodDescription method in methods) { if (inEnrichment) { method.Name = ""; method.Decl = null; } Methods.Add(method); } if (!inEnrichment && variable != null) Fields.Add(variable); }
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()); }