public VariableDescription(AFieldDecl fieldDecl) { Name = fieldDecl.GetName().Text; Type = Util.TypeToString(fieldDecl.GetType()); PlacementPrefix = "Field"; VariableType = VariableTypes.Field; Const = fieldDecl.GetConst() != null; IsStatic = fieldDecl.GetStatic() != null; Visibility = fieldDecl.GetVisibilityModifier(); realType = (PType)fieldDecl.GetType().Clone(); init = fieldDecl.GetInit(); Line = fieldDecl.GetName().Line; Position = TextPoint.FromCompilerCoords(fieldDecl.GetName()); }
public override void CaseAFieldDecl(AFieldDecl node) { if (node.GetConst() == null) return; initialFieldDecl = node; if (IsConstant(node.GetInit())) { List<AFieldLvalue> lvalues = new List<AFieldLvalue>(); lvalues.AddRange(data.FieldLinks.Where(link => link.Value == node).Select(link => link.Key)); foreach (AFieldLvalue lvalue in lvalues) { PExp parent = (PExp)lvalue.Parent(); parent.ReplaceBy(Util.MakeClone(node.GetInit(), data)); } node.Parent().RemoveChild(node); } initialFieldDecl = null; }
public override void CaseAFieldDecl(AFieldDecl node) { InAFieldDecl(node); if (node.GetInit() != null) { node.GetInit().Apply(this); } if (node.GetName() != null) { node.GetName().Apply(this); } if (node.GetType() != null) { node.GetType().Apply(this); } if (node.GetConst() != null) { node.GetConst().Apply(this); } if (node.GetStatic() != null) { node.GetStatic().Apply(this); } if (node.GetVisibilityModifier() != null) { node.GetVisibilityModifier().Apply(this); } OutAFieldDecl(node); }
public override void OutAFieldDecl(AFieldDecl node) { bool isAConstStringVar = data.ObfuscationFields.Contains(node);/* data.ObfuscatedStrings.Values.Any(stringField => stringField == node) || data.UnobfuscatedStrings.Values.Any(stringField => stringField == node);*/ if (!isAConstStringVar && node.GetConst() != null && node.GetInit() == null) errors.Add(new ErrorCollection.Error(node.GetConst(), currentSourceFile, LocRM.GetString("ErrorText183"), false)); //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.OutAFieldDecl(node); }
public override void CaseAFieldDecl(AFieldDecl node) { //Check that it is const if (node.GetConst() != null && !data.ObfuscationFields.Contains(node)) { if (node.GetInit() == null) { errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText112"))); return; } ConstChecker checker = new ConstChecker(data); node.GetInit().Apply(checker); if (!checker.IsConst) { errors.Add(new ErrorCollection.Error(node.GetName(), LocRM.GetString("ErrorText113"))); return; } } base.CaseAFieldDecl(node); }
public override void CaseAFieldDecl(AFieldDecl node) { if (node.GetStatic() != null) Write("static "); if (node.GetConst() != null) Write("const "); node.GetType().Apply(this); Write(" " + node.GetName().Text); if (node.GetInit() != null) { Write(" = "); node.GetInit().Apply(this); } Write(";\n\n"); }