protected virtual IReference DeclareHelper(string name, IReference variable, Expression optionalInitialValue)
 {
     FuncBuilder.Instance.BindLocalVariableToRepresentation(variable, name);
       if(!ReferenceEquals(optionalInitialValue, null)) {
     Assignment.AssignAny(variable, optionalInitialValue);
       }
       return variable;
 }
Exemple #2
0
 public static void AssignAny(IReference lhs, Expression rhs)
 {
     var f=FuncBuilder.Instance;
       using(f.OpenScope("assign")) {
     if(f.CanProveIsNeverRead(lhs)) {
       rhs.EvaluateForItsSideEffects();
     } else {
       SpecialAssignAny(lhs, rhs);
     }
       }
 }
Exemple #3
0
 public static void SpecialAssignAny(IReference lhs, Expression rhs)
 {
     var f=FuncBuilder.Instance;
       var lhsWasLivePriorToThisAssignment=f.IsLive(lhs);
       var rhsReadable=rhs.EvaluateTo(lhs);
       if(!ReferenceEquals(lhs, rhsReadable)) {
     var lhsReg=lhs.ProposeRegisterOrScratch0();
     var rhsReg=rhsReadable.ToRegister(lhsReg);
     lhs.FromRegister(rhsReg);
       }
       //Don't decide that a variable is live just because it was referenced (or it was used as temporary storage)
       //in its very-own assignment.
       if(!lhsWasLivePriorToThisAssignment) {
     f.UndoNoteRead(new[] {lhs});
       }
 }
 public IntPointerCast(Expression inner)
 {
     this.inner=inner;
 }
 public ArrayElement(string name, ExpressionType expressionType, Expression array, Expression index)
     : base(name, expressionType)
 {
     this.array=array;
       this.index=index;
 }
 public IntCast(Expression inner)
 {
     this.inner=inner;
 }
 public FuncPointerCast(Expression inner)
 {
     this.inner=inner;
 }
 public FuncPointerCast(Expression inner)
 {
     this.inner = inner;
 }
 public IReference ForLhs(Expression rhs)
 {
     return rhs.HasConflictWith(storage) ? temp : storage;
 }