@@ -88,14 +88,14 @@ class Evaluator(
8888 Error .fail(" Should not have happened." , e.pos)
8989 }
9090
91- def visitAsLazy (e : Expr )(implicit scope : ValScope ): Lazy = e match {
91+ def visitAsLazy (e : Expr )(implicit scope : ValScope ): Eval = e match {
9292 case v : Val => v
93- case e => new LazyWithComputeFunc (() => visitExpr(e))
93+ case e => new Lazy (() => visitExpr(e))
9494 }
9595
9696 def visitValidId (e : ValidId )(implicit scope : ValScope ): Val = {
9797 val ref = scope.bindings(e.nameIdx)
98- ref.force
98+ ref.value
9999 }
100100
101101 def visitSelect (e : Select )(implicit scope : ValScope ): Val = visitExpr(e.value) match {
@@ -116,7 +116,7 @@ class Evaluator(
116116 newScope.bindings(base + i) = b.args match {
117117 case null => visitAsLazy(b.rhs)(newScope)
118118 case argSpec =>
119- new LazyWithComputeFunc (() => visitMethod(b.rhs, argSpec, b.pos)(newScope))
119+ new Lazy (() => visitMethod(b.rhs, argSpec, b.pos)(newScope))
120120 }
121121 i += 1
122122 }
@@ -311,7 +311,7 @@ class Evaluator(
311311 }
312312
313313 protected def visitApplyBuiltin (e : ApplyBuiltin )(implicit scope : ValScope ): Val = {
314- val arr = new Array [Lazy ](e.argExprs.length)
314+ val arr = new Array [Eval ](e.argExprs.length)
315315 var idx = 0
316316
317317 if (e.tailstrict) {
@@ -371,10 +371,10 @@ class Evaluator(
371371 if (v.length == 0 ) Error .fail(" array bounds error: array is empty" , pos)
372372 if (int >= v.length)
373373 Error .fail(s " array bounds error: $int not within [0, ${v.length}) " , pos)
374- v.force (int)
374+ v.value (int)
375375 case (v : Val .Str , i : Val .Num ) =>
376376 val int = i.asPositiveInt
377- val str = v.value
377+ val str = v.str
378378 if (str.isEmpty) Error .fail(" string bounds error: string is empty" , pos)
379379 val unicodeLength = str.codePointCount(0 , str.length)
380380 if (int >= unicodeLength)
@@ -383,7 +383,7 @@ class Evaluator(
383383 val endUtf16 = str.offsetByCodePoints(startUtf16, 1 )
384384 Val .Str (pos, str.substring(startUtf16, endUtf16))
385385 case (v : Val .Obj , i : Val .Str ) =>
386- v.value(i.value , pos)
386+ v.value(i.str , pos)
387387 case (lhs, rhs) =>
388388 Error .fail(s " attempted to index a ${lhs.prettyName} with ${rhs.prettyName}" , pos)
389389 }
@@ -393,7 +393,7 @@ class Evaluator(
393393 var sup = scope.bindings(e.selfIdx + 1 ).asInstanceOf [Val .Obj ]
394394 val key = visitExpr(e.index).cast[Val .Str ]
395395 if (sup == null ) sup = scope.bindings(e.selfIdx).asInstanceOf [Val .Obj ]
396- sup.value(key.value , e.pos)
396+ sup.value(key.str , e.pos)
397397 }
398398
399399 def visitImportStr (e : ImportStr ): Val .Str =
@@ -460,7 +460,7 @@ class Evaluator(
460460 if (sup == null ) Val .False (e.pos)
461461 else {
462462 val key = visitExpr(e.value).cast[Val .Str ]
463- Val .bool(e.pos, sup.containsKey(key.value ))
463+ Val .bool(e.pos, sup.containsKey(key.str ))
464464 }
465465 }
466466
@@ -642,16 +642,16 @@ class Evaluator(
642642 override def evalDefault (expr : Expr , vs : ValScope , es : EvalScope ): Val = visitExpr(expr)(vs)
643643 }
644644
645- def visitBindings (bindings : Array [Bind ], scope : => ValScope ): Array [Lazy ] = {
646- val arrF = new Array [Lazy ](bindings.length)
645+ def visitBindings (bindings : Array [Bind ], scope : => ValScope ): Array [Eval ] = {
646+ val arrF = new Array [Eval ](bindings.length)
647647 var i = 0
648648 while (i < bindings.length) {
649649 val b = bindings(i)
650650 arrF(i) = b.args match {
651651 case null =>
652- new LazyWithComputeFunc (() => visitExpr(b.rhs)(scope))
652+ new Lazy (() => visitExpr(b.rhs)(scope))
653653 case argSpec =>
654- new LazyWithComputeFunc (() => visitMethod(b.rhs, argSpec, b.pos)(scope))
654+ new Lazy (() => visitMethod(b.rhs, argSpec, b.pos)(scope))
655655 }
656656 i += 1
657657 }
@@ -689,7 +689,7 @@ class Evaluator(
689689 case null => Error .fail(" Assertion failed" , a.value.pos, " Assert" )
690690 case msg =>
691691 Error .fail(
692- " Assertion failed: " + visitExpr(msg)(newScope).cast[Val .Str ].value ,
692+ " Assertion failed: " + visitExpr(msg)(newScope).cast[Val .Str ].str ,
693693 a.value.pos,
694694 " Assert"
695695 )
@@ -716,7 +716,7 @@ class Evaluator(
716716 case null =>
717717 visitAsLazy(b.rhs)(newScope)
718718 case argSpec =>
719- new LazyWithComputeFunc (() => visitMethod(b.rhs, argSpec, b.pos)(newScope))
719+ new Lazy (() => visitMethod(b.rhs, argSpec, b.pos)(newScope))
720720 }
721721 i += 1
722722 j += 1
@@ -851,13 +851,13 @@ class Evaluator(
851851 def compare (x : Val , y : Val ): Int = (x, y) match {
852852 case (_ : Val .Null , _ : Val .Null ) => 0
853853 case (x : Val .Num , y : Val .Num ) => x.asDouble.compareTo(y.asDouble)
854- case (x : Val .Str , y : Val .Str ) => Util .compareStringsByCodepoint(x.value , y.value )
854+ case (x : Val .Str , y : Val .Str ) => Util .compareStringsByCodepoint(x.str , y.str )
855855 case (x : Val .Bool , y : Val .Bool ) => x.asBoolean.compareTo(y.asBoolean)
856856 case (x : Val .Arr , y : Val .Arr ) =>
857857 val len = math.min(x.length, y.length)
858858 var i = 0
859859 while (i < len) {
860- val cmp = compare(x.force (i), y.force (i))
860+ val cmp = compare(x.value (i), y.value (i))
861861 if (cmp != 0 ) return cmp
862862 i += 1
863863 }
@@ -871,7 +871,7 @@ class Evaluator(
871871 case _ : Val .Null => y.isInstanceOf [Val .Null ]
872872 case x : Val .Str =>
873873 y match {
874- case y : Val .Str => x.value == y.value
874+ case y : Val .Str => x.str == y.str
875875 case _ => false
876876 }
877877 case x : Val .Num =>
@@ -886,7 +886,7 @@ class Evaluator(
886886 if (xlen != y.length) return false
887887 var i = 0
888888 while (i < xlen) {
889- if (! equal(x.force (i), y.force (i))) return false
889+ if (! equal(x.value (i), y.value (i))) return false
890890 i += 1
891891 }
892892 true
@@ -995,5 +995,5 @@ object Evaluator {
995995 */
996996 type Logger = (Boolean , String ) => Unit
997997 val emptyStringArray = new Array [String ](0 )
998- val emptyLazyArray = new Array [Lazy ](0 )
998+ val emptyLazyArray = new Array [Eval ](0 )
999999}
0 commit comments