@@ -118,7 +118,7 @@ object Semantic:
118
118
end Warm
119
119
120
120
/** A function value */
121
- case class Fun (expr : Tree , thisV : Ref , klass : ClassSymbol , env : Env ) extends Value
121
+ case class Fun (expr : Tree , thisV : Ref , klass : ClassSymbol ) extends Value
122
122
123
123
/** A value which represents a set of addresses
124
124
*
@@ -144,7 +144,7 @@ object Semantic:
144
144
145
145
def hasField (f : Symbol ) = fields.contains(f)
146
146
147
- /** The environment for method parameters
147
+ /** The environment stores values for constructor parameters
148
148
*
149
149
* For performance and usability, we restrict parameters to be either `Cold`
150
150
* or `Hot`.
@@ -162,6 +162,9 @@ object Semantic:
162
162
* key. The reason is that given the same receiver, a method or function may
163
163
* be called with different arguments -- they are not decided by the receiver
164
164
* anymore.
165
+ *
166
+ * TODO: remove Env as it is only used to pass value from `callConstructor` -> `eval` -> `init`.
167
+ * It goes through `eval` for caching (termination) purposes.
165
168
*/
166
169
object Env :
167
170
opaque type Env = Map [Symbol , Value ]
@@ -704,14 +707,12 @@ object Semantic:
704
707
else
705
708
value.select(target, needResolve = false )
706
709
707
- case Fun (body, thisV, klass, env ) =>
710
+ case Fun (body, thisV, klass) =>
708
711
// meth == NoSymbol for poly functions
709
712
if meth.name.toString == " tupled" then value // a call like `fun.tupled`
710
713
else
711
714
promoteArgs()
712
- withEnv(env) {
713
- eval(body, thisV, klass, cacheResult = true )
714
- }
715
+ eval(body, thisV, klass, cacheResult = true )
715
716
716
717
case RefSet (refs) =>
717
718
refs.map(_.call(meth, args, receiver, superType)).join
@@ -823,7 +824,7 @@ object Semantic:
823
824
warm.callConstructor(ctor, argInfos2)
824
825
warm
825
826
826
- case Fun (body, thisV, klass, env ) =>
827
+ case Fun (body, thisV, klass) =>
827
828
report.error(" unexpected tree in instantiating a function, fun = " + body.show, trace.toVector.last)
828
829
Hot
829
830
@@ -933,10 +934,10 @@ object Semantic:
933
934
if errors.nonEmpty then promoted.remove(warm)
934
935
reporter.reportAll(errors)
935
936
936
- case fun @ Fun (body, thisV, klass, env ) =>
937
+ case fun @ Fun (body, thisV, klass) =>
937
938
if ! promoted.contains(fun) then
938
939
val errors = Reporter .stopEarly {
939
- val res = withEnv(env) {
940
+ val res = {
940
941
given Trace = Trace .empty
941
942
eval(body, thisV, klass)
942
943
}
@@ -1121,7 +1122,7 @@ object Semantic:
1121
1122
args.foreach { arg =>
1122
1123
val res =
1123
1124
if arg.isByName then
1124
- Fun (arg.tree, thisV, klass, env )
1125
+ Fun (arg.tree, thisV, klass)
1125
1126
else
1126
1127
eval(arg.tree, thisV, klass)
1127
1128
@@ -1227,10 +1228,10 @@ object Semantic:
1227
1228
}
1228
1229
1229
1230
case closureDef(ddef) =>
1230
- Fun (ddef.rhs, thisV, klass, env )
1231
+ Fun (ddef.rhs, thisV, klass)
1231
1232
1232
1233
case PolyFun (body) =>
1233
- Fun (body, thisV, klass, env )
1234
+ Fun (body, thisV, klass)
1234
1235
1235
1236
case Block (stats, expr) =>
1236
1237
eval(stats, thisV, klass)
0 commit comments