VariableToDeclare AddVariable(DisplayClass result, StObj statement, IField field) { VariableToDeclare variable = new VariableToDeclare(result, field); if (statement != null) { variable.Propagate(ResolveVariableToPropagate(statement.Value, field.Type)); variable.Initializers.Add(statement); } return variable; }
/// <summary> /// Get the position where the declaration for the variable will be inserted. /// </summary> public AstNode GetDeclarationPoint(ILVariable variable) { VariableToDeclare v = variableDict[variable]; while (v.ReplacementDueToCollision != null) { v = v.ReplacementDueToCollision; } return(v.InsertionPoint.nextNode); }
protected internal override void VisitStObj(StObj inst) { if (IsDisplayClassFieldAccess(inst.Target, out var v, out var displayClass, out var field)) { VariableToDeclare vd = displayClass.VariablesToDeclare[(IField)field.MemberDefinition]; if (vd.CanPropagate && vd.Initializers.Contains(inst)) { if (inst.Parent is Block containingBlock) { context.Step($"Remove initializer of {v.Name}.{vd.Name} due to propagation", inst); containingBlock.Instructions.Remove(inst); return; } } } base.VisitStObj(inst); EarlyExpressionTransforms.StObjToStLoc(inst, context); }
/// <summary> /// Determines whether a variable was merged with other variables. /// </summary> public bool WasMerged(ILVariable variable) { VariableToDeclare v = variableDict[variable]; return(v.InvolvedInCollision || v.RemovedDueToCollision); }