Add lexer support for `TOKEN_INTERPOLATION` to split string literals at interpolation points, introduce `MAX_INTERPOLATION_NESTING` limit of 8, and compile interpolated strings by emitting calls to `String.interpolate_()`. Optimize list and map literal construction with new `addCore_` primitives to reduce stack churn. Update `String`, `List`, and `Map` `toString` methods in core library to use interpolation syntax, and migrate all benchmark and test files from explicit concatenation to interpolated strings.
42 lines
1.3 KiB
Plaintext
42 lines
1.3 KiB
Plaintext
class Foo {
|
|
construct new() {}
|
|
|
|
+(other) { "infix + %(other)" }
|
|
-(other) { "infix - %(other)" }
|
|
*(other) { "infix * %(other)" }
|
|
/(other) { "infix / %(other)" }
|
|
%(other) { "infix \% %(other)" }
|
|
<(other) { "infix < %(other)" }
|
|
>(other) { "infix > %(other)" }
|
|
<=(other) { "infix <= %(other)" }
|
|
>=(other) { "infix >= %(other)" }
|
|
==(other) { "infix == %(other)" }
|
|
!=(other) { "infix != %(other)" }
|
|
&(other) { "infix & %(other)" }
|
|
|(other) { "infix | %(other)" }
|
|
is(other) { "infix is %(other)" }
|
|
|
|
! { "prefix !" }
|
|
~ { "prefix ~" }
|
|
- { "prefix -" }
|
|
}
|
|
|
|
var foo = Foo.new()
|
|
System.print(foo + "a") // expect: infix + a
|
|
System.print(foo - "a") // expect: infix - a
|
|
System.print(foo * "a") // expect: infix * a
|
|
System.print(foo / "a") // expect: infix / a
|
|
System.print(foo % "a") // expect: infix % a
|
|
System.print(foo < "a") // expect: infix < a
|
|
System.print(foo > "a") // expect: infix > a
|
|
System.print(foo <= "a") // expect: infix <= a
|
|
System.print(foo >= "a") // expect: infix >= a
|
|
System.print(foo == "a") // expect: infix == a
|
|
System.print(foo != "a") // expect: infix != a
|
|
System.print(foo & "a") // expect: infix & a
|
|
System.print(foo | "a") // expect: infix | a
|
|
System.print(!foo) // expect: prefix !
|
|
System.print(~foo) // expect: prefix ~
|
|
System.print(-foo) // expect: prefix -
|
|
System.print(foo is "a") // expect: infix is a
|