@@ -401,7 +401,7 @@ object Transformer {
401401    }
402402
403403  def  transform (value : machine.Variable )(using  FunctionContext ):  Operand  = 
404-     substitute( value)  match  {
404+     value match  {
405405      case  machine.Variable (name, tpe) =>  LocalReference (transform(tpe), name)
406406    }
407407
@@ -662,10 +662,10 @@ object Transformer {
662662      values match  {
663663        case  Nil  =>  ()
664664        case  value ::  values => 
665-         if  values.map(substitute). contains(substitute( value) ) then  {
665+         if  values.contains(value) then  {
666666          shareValue(value);
667667          loop(values)
668-         } else  if  freeInBody.map(substitute). contains(substitute( value) ) then  {
668+         } else  if  freeInBody.contains(value) then  {
669669          shareValue(value);
670670          loop(values)
671671        } else  {
@@ -678,7 +678,7 @@ object Transformer {
678678
679679  def  eraseValues (environment : machine.Environment , freeInBody : Set [machine.Variable ])(using  ModuleContext , FunctionContext , BlockContext ):  Unit  = 
680680    environment.foreach { value => 
681-       if  ! freeInBody.map(substitute). contains(substitute( value) ) then  eraseValue(value)
681+       if  ! freeInBody.contains(value) then  eraseValue(value)
682682    }
683683
684684  def  shareValue (value : machine.Variable )(using  FunctionContext , BlockContext ):  Unit  =  {
@@ -758,25 +758,12 @@ object Transformer {
758758  }
759759
760760  class  FunctionContext () {
761-     //  TODO delete substitution
762-     var  substitution :  Map [machine.Variable , machine.Variable ] =  Map ();
763761    var  basicBlocks :  List [BasicBlock ] =  List ();
764762  }
765763
766764  def  emit (basicBlock : BasicBlock )(using  C :  FunctionContext ) = 
767765    C .basicBlocks =  C .basicBlocks :+  basicBlock
768766
769-   def  withBindings [R ](bindings : List [(machine.Variable , machine.Variable )])(prog : () =>  R )(using  C :  FunctionContext ):  R  =  {
770-     val  substitution  =  C .substitution;
771-     C .substitution =  substitution ++  bindings.map { case  (variable ->  value) =>  (variable ->  substitution.getOrElse(value, value) ) }.toMap;
772-     val  result  =  prog();
773-     C .substitution =  substitution
774-     result
775-   }
776- 
777-   def  substitute (value : machine.Variable )(using  C :  FunctionContext ):  machine.Variable  = 
778-     C .substitution.toMap.getOrElse(value, value)
779- 
780767  class  BlockContext () {
781768    var  stack :  Operand  =  LocalReference (stackType, " stack" 
782769    var  instructions :  List [Instruction ] =  List ();
0 commit comments