public override StatementList AllocStaticVariable(IFieldReference field) { StaticField p = new StaticField(new StaticFieldAccess(field)); BoogieVariable bv = BoogieVariable.From(p); return(dispatcher.AllocAddr(bv)); }
/// <summary>Returns an lvalue.</summary> private LValueInfo GenLValue(FuzzType type, int minRefEscapeScope) { Debug.Assert(type != null); LValueInfo lv = GenExistingLValue(type, minRefEscapeScope); if (lv == null) { StaticField newStatic = Statics.GenerateNewField(type); lv = new LValueInfo(IdentifierName(newStatic.Var.Name), type, int.MaxValue); } return(lv); }
/// <summary> /// 将对象转换为其 XML 表示形式。 /// </summary> /// <param name="writer">对象要序列化为的 <see cref="T:System.Xml.XmlWriter" /> 流。</param> public override void WriteXml(XmlWriter writer) { writer.WriteAttributeString("type", Type); writer.WriteAttributeString("value", Value.ToString()); if (StaticField) { writer.WriteAttributeString("staticField", StaticField.ToString()); } foreach (ModuleBuildStepElement step in _innerSteps) { step.ObjectWriteXml(writer); } }
public static ISpecialAction ReadSpecialAction(this NetIncomingMessage msg, SceneMgr mgr, Player owner = null) { //chtelo by to aby kazdej objekt implementoval sendable takhle nektery akce nepujdou pouzit ISpecialAction action = null; int hash = msg.ReadInt32(); if (hash == typeof(HealAction).GUID.GetHashCode()) { action = new HealAction(); } else if (hash == typeof(ActiveWeapon).GUID.GetHashCode()) { action = new ActiveWeapon(); } else if (hash == typeof(WeaponUpgrade).GUID.GetHashCode()) { action = new WeaponUpgrade(); } else if (hash == typeof(AsteroidDamage).GUID.GetHashCode()) { action = new AsteroidDamage(mgr, owner); } else if (hash == typeof(AsteroidGrowth).GUID.GetHashCode()) { action = new AsteroidGrowth(mgr, owner); } else if (hash == typeof(AsteroidSlow).GUID.GetHashCode()) { action = new AsteroidSlow(mgr, owner); } else if (hash == typeof(AsteroidThrow).GUID.GetHashCode()) { action = new AsteroidThrow(mgr, owner); } else if (hash == typeof(StaticField).GUID.GetHashCode()) { action = new StaticField(mgr, owner); } if (action != null) { action.ReadObject(msg); } return(action); }
public LoadStatic(StaticField field) { Field = field; }
// Start is called before the first frame update void Start() { StartCoroutine(tagChecker()); StaticField.ResetStaticFields(); }
public _IFunction4_1760(ClassMetadata _enclosing, StaticField[] existingFields, Transaction trans) { this._enclosing = _enclosing; this.existingFields = existingFields; this.trans = trans; }
protected virtual StaticField FieldByName(StaticField[] fields, string fieldName) { for (var i = 0; i < fields.Length; i++) { var field = fields[i]; if (fieldName.Equals(field.name)) { return field; } } return null; }
protected virtual void UpdateExistingStaticField(Transaction trans, StaticField existingField , IReflectField reflectField) { var stream = trans.Container(); var newValue = StaticReflectFieldValue(reflectField); if (existingField.value != null && newValue != null && existingField.value.GetType () == newValue.GetType()) { var id = stream.GetID(trans, existingField.value); if (id > 0) { if (existingField.value != newValue) { // This is the clue: // Bind the current static member to it's old database identity, // so constants and enums will work with '==' stream.Bind(trans, newValue, id); // This may produce unwanted side effects if the static field object // was modified in the current session. TODO:Add documentation case. stream.Refresh(trans, newValue, int.MaxValue); existingField.value = newValue; } return; } } if (newValue == null) { try { _fieldAccessor.Set(reflectField, null, existingField.value); } catch (Exception) { } // fail silently // TODO: why? return; } existingField.value = newValue; }
private StatementSyntax GenAssignmentStatement() { LValueInfo lvalue = null; if (!Random.FlipCoin(Options.AssignToNewVarProb)) { lvalue = GenExistingLValue(null, int.MinValue); } if (lvalue == null) { FuzzType newType = Types.PickType(Options.LocalIsByRefProb); // Determine if we should create a new local. We do this with a certain probabilty, // or always if the new type is a by-ref type (we cannot have static by-refs). if (newType is RefType || Random.FlipCoin(Options.NewVarIsLocalProb)) { VariableIdentifier variable; string varName = $"var{_varCounter++}"; ExpressionSyntax rhs; if (newType is RefType newRt) { LValueInfo rhsLV = GenLValue(newRt.InnerType, int.MinValue); variable = new VariableIdentifier(newType, varName, rhsLV.RefEscapeScope); rhs = RefExpression(rhsLV.Expression); } else { rhs = GenExpression(newType); variable = new VariableIdentifier(newType, varName, -(_scope.Count - 1)); } LocalDeclarationStatementSyntax decl = LocalDeclarationStatement( VariableDeclaration( variable.Type.GenReferenceTo(), SingletonSeparatedList( VariableDeclarator(variable.Name) .WithInitializer( EqualsValueClause(rhs))))); _scope.Last().Variables.Add(variable); return(decl); } StaticField newStatic = Statics.GenerateNewField(newType); lvalue = new LValueInfo(IdentifierName(newStatic.Var.Name), newType, int.MaxValue); } // Determine if we should generate a ref-reassignment. In that case we cannot do anything // clever, like generate compound assignments. FuzzType rhsType = lvalue.Type; if (lvalue.Type is RefType rt) { if (Random.FlipCoin(Options.AssignGenRefReassignProb)) { RefExpressionSyntax refRhs = RefExpression(GenLValue(rt.InnerType, lvalue.RefEscapeScope).Expression); return (ExpressionStatement( AssignmentExpression( SyntaxKind.SimpleAssignmentExpression, lvalue.Expression, refRhs))); } // We have a ref-type, but are not generating a ref-reassign, so lift the type and make a normal assignment. rhsType = rt.InnerType; } SyntaxKind assignmentKind = SyntaxKind.SimpleAssignmentExpression; // Determine if we should generate compound assignment. if (rhsType.AllowedAdditionalAssignmentKinds.Length > 0 && Random.FlipCoin(Options.CompoundAssignmentProb)) { assignmentKind = Random.NextElement(rhsType.AllowedAdditionalAssignmentKinds); } // Early our for simple cases. if (assignmentKind == SyntaxKind.PreIncrementExpression || assignmentKind == SyntaxKind.PreDecrementExpression) { return(ExpressionStatement(PrefixUnaryExpression(assignmentKind, lvalue.Expression))); } if (assignmentKind == SyntaxKind.PostIncrementExpression || assignmentKind == SyntaxKind.PostDecrementExpression) { return(ExpressionStatement(PostfixUnaryExpression(assignmentKind, lvalue.Expression))); } // Right operand of shifts are always ints. if (assignmentKind == SyntaxKind.LeftShiftAssignmentExpression || assignmentKind == SyntaxKind.RightShiftAssignmentExpression) { rhsType = Types.GetPrimitiveType(SyntaxKind.IntKeyword); } ExpressionSyntax right = GenExpression(rhsType); // For modulo and division we don't want to throw divide-by-zero exceptions, // so always or right-hand-side with 1. if (assignmentKind == SyntaxKind.ModuloAssignmentExpression || assignmentKind == SyntaxKind.DivideAssignmentExpression) { right = CastExpression( rhsType.GenReferenceTo(), ParenthesizedExpression( BinaryExpression( SyntaxKind.BitwiseOrExpression, ParenthesizeIfNecessary(right), LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))); } return(ExpressionStatement(AssignmentExpression(assignmentKind, lvalue.Expression, right))); }
public StoreStatic(StaticField field, NodeReference value) { Field = field; Value = value; }
void Awake() { instance = this; }
protected void AddStaticField(StaticField fieldInfo) { base.StaticFields.Add(fieldInfo.Info.Name, fieldInfo); }
private StatementSyntax GenAssignmentStatement() { ExpressionSyntax lhs = null; FuzzType type = null; if (!Random.FlipCoin(Options.AssignToNewVarProb)) { (lhs, type) = GenMemberAccess(ft => true); } if (lhs == null) { type = Types.PickType(); if (Random.FlipCoin(Options.NewVarIsLocalProb)) { VariableIdentifier variable = new VariableIdentifier(type, $"var{_varCounter++}"); LocalDeclarationStatementSyntax decl = LocalDeclarationStatement( VariableDeclaration( variable.Type.GenReferenceTo(), SingletonSeparatedList( VariableDeclarator(variable.Name) .WithInitializer( EqualsValueClause( GenExpression(variable.Type)))))); _scope.Last().Variables.Add(variable); return(decl); } StaticField newStatic = Statics.GenerateNewField(type); lhs = IdentifierName(newStatic.Var.Name); } SyntaxKind assignmentKind = SyntaxKind.SimpleAssignmentExpression; if (type.AllowedAdditionalAssignmentKinds.Length > 0 && Random.FlipCoin(Options.FancyAssignmentProb)) { assignmentKind = Random.NextElement(type.AllowedAdditionalAssignmentKinds); } if (assignmentKind == SyntaxKind.PreIncrementExpression || assignmentKind == SyntaxKind.PreDecrementExpression) { return(ExpressionStatement(PrefixUnaryExpression(assignmentKind, lhs))); } if (assignmentKind == SyntaxKind.PostIncrementExpression || assignmentKind == SyntaxKind.PostDecrementExpression) { return(ExpressionStatement(PostfixUnaryExpression(assignmentKind, lhs))); } if (assignmentKind == SyntaxKind.LeftShiftAssignmentExpression || assignmentKind == SyntaxKind.RightShiftAssignmentExpression) { type = Types.GetPrimitiveType(SyntaxKind.IntKeyword); } ExpressionSyntax right = GenExpression(type); if (assignmentKind == SyntaxKind.ModuloAssignmentExpression || assignmentKind == SyntaxKind.DivideAssignmentExpression) { right = CastExpression( type.GenReferenceTo(), ParenthesizedExpression( BinaryExpression( SyntaxKind.BitwiseOrExpression, ParenthesizeIfNecessary(right), LiteralExpression(SyntaxKind.NumericLiteralExpression, Literal(1))))); } return(ExpressionStatement(AssignmentExpression(assignmentKind, lhs, right))); }
public StaticClass(string name_, StaticField[] fields_) { name = name_; fields = fields_; }