3 <<file
:__EnableUnstableFeatures('expression_trees')>>
7 public function reset(): int {
12 function lift
<T
>(T
$_): ExprTree
<Code
, Code
::TAst
, T
> {
13 throw new Exception();
16 function test(): void
{
25 // We should think that $x->x could be null
31 // Placeholder definition so we don't get naming/typing errors.
33 const type TAst
= mixed;
35 public static function intLiteral(
37 ): ExprTree
<Code
, Code
::TAst
, ExampleInt
> {
38 throw new Exception();
40 public static function floatLiteral(
42 ): ExprTree
<Code
, Code
::TAst
, ExampleFloat
> {
43 throw new Exception();
45 public static function boolLiteral(bool $_):
46 ExprTree
<Code
, Code
::TAst
, ExampleBool
>
48 throw new Exception();
50 public static function stringLiteral(string $_):
51 ExprTree
<Code
, Code
::TAst
, ExampleString
>
53 throw new Exception();
55 public static function nullLiteral(): ExprTree
<Code
, Code
::TAst
, null> {
56 throw new Exception();
60 public static function symbol
<T
>(
62 (function(ExampleContext
): ExprTree
<Code
, Code
::TAst
, T
>) $_,
63 ): ExprTree
<Code
, Code
::TAst
, T
> {
64 throw new Exception();
68 public function localVar(?ExprPos
$_, string $_): Code
::TAst
{
69 throw new Exception();
71 public function lambdaLiteral(
74 vec
<Code
::TAst
> $_body,
76 throw new Exception();
80 public function methCall(
86 throw new Exception();
89 // Old style operators
90 public function call
<T
>(
93 vec
<Code
::TAst
> $_args,
95 throw new Exception();
98 public function assign(
103 throw new Exception();
106 public function ternary(
108 Code
::TAst
$_condition,
109 ?Code
::TAst
$_truthy,
112 throw new Exception();
116 public function ifStatement(
119 vec
<Code
::TAst
> $_then_body,
120 vec
<Code
::TAst
> $_else_body,
122 throw new Exception();
124 public function whileStatement(
127 vec
<Code
::TAst
> $_body,
129 throw new Exception();
131 public function returnStatement(
135 throw new Exception();
137 public function forStatement(
144 throw new Exception();
146 public function breakStatement(?ExprPos
$_): Code
::TAst
{
147 throw new Exception();
149 public function continueStatement(?ExprPos
$_,): Code
::TAst
{
150 throw new Exception();
154 public function splice
<T
>(
157 ExprTree
<Code
, Code
::TAst
, T
> $_,
159 throw new Exception();
162 // TODO: Discard unsupported syntax nodes while lowering
163 public function unsupportedSyntax(string $msg): Code
::TAst
{
164 throw new Exception($msg);
168 final class ExprTree
<TVisitor
, TResult
, +TInfer
>{
169 public function __construct(
170 private ?ExprPos
$pos,
171 private string $filepath,
172 private dict
<string, mixed> $spliced_values,
173 private (function(TVisitor
): TResult
) $x,
174 private (function(): TInfer
) $err,
178 final class ExprPos
{
179 public function __construct(
180 private int $begin_line,
181 private int $begin_col,
182 private int $end_line,
183 private int $end_col,
187 final class ExampleInt
{
188 public function __plus(ExampleInt
$_): ExampleInt
{
189 throw new Exception();
191 public function __minus(ExampleInt
$_): ExampleInt
{
192 throw new Exception();
194 public function __star(ExampleInt
$_): ExampleInt
{
195 throw new Exception();
197 public function __slash(ExampleInt
$_): ExampleInt
{
198 throw new Exception();
201 public function __lessThan(ExampleInt
$_): ExampleBool
{
202 throw new Exception();
205 public function __lessThanEqual(ExampleInt
$_): ExampleBool
{
206 throw new Exception();
209 public function __greaterThan(ExampleInt
$_): ExampleBool
{
210 throw new Exception();
213 public function __greaterThanEqual(ExampleInt
$_): ExampleBool
{
214 throw new Exception();
217 public function __tripleEquals(ExampleInt
$_): ExampleBool
{
218 throw new Exception();
221 public function __notTripleEquals(ExampleInt
$_): ExampleBool
{
222 throw new Exception();
226 final class ExampleBool
{
227 public function __ampamp(ExampleBool
$_): ExampleBool
{
228 throw new Exception();
231 public function __barbar(ExampleBool
$_): ExampleBool
{
232 throw new Exception();
235 public function __bool(): bool {
236 throw new Exception();
239 public function __exclamationMark(): ExampleBool
{
240 throw new Exception();
244 final class ExampleString
{}
246 final class ExampleContext
{}
248 final class ExampleFloat
{}