4 const type TAst = mixed;
6 public static function makeTree<<<__Explicit>> TInfer>(
9 'splices' => dict<string, mixed>,
10 'functions' => vec<mixed>,
11 'static_methods' => vec<mixed>,
13 (function(Code): Code::TAst) $ast,
14 ): ExprTree<Code, Code::TAst, TInfer> {
15 throw new Exception();
18 // Virtual types (These do not have to be implemented)
19 public static function intType(): ExampleInt {
20 throw new Exception();
22 public static function floatType(): ExampleFloat {
23 throw new Exception();
25 public static function boolType(): ExampleBool {
26 throw new Exception();
28 public static function stringType(): ExampleString {
29 throw new Exception();
31 public static function nullType(): null {
32 throw new Exception();
34 public static function voidType(): ExampleVoid {
35 throw new Exception();
37 public static function symbolType<T>(
38 (function(ExampleContext): Awaitable<ExprTree<Code, Code::TAst, T>>) $_,
40 throw new Exception();
43 // Desugared nodes (These should be implemented)
44 public function visitInt(?ExprPos $_, int $_): Code::TAst {
45 throw new Exception();
47 public function visitFloat(?ExprPos $_, float $_): Code::TAst {
48 throw new Exception();
50 public function visitBool(?ExprPos $_, bool $_): Code::TAst {
51 throw new Exception();
53 public function visitString(?ExprPos $_, string $_): Code::TAst {
54 throw new Exception();
56 public function visitNull(?ExprPos $_): Code::TAst {
57 throw new Exception();
60 public function visitBinop(
66 throw new Exception();
69 public function visitUnop(
74 throw new Exception();
77 public function visitLocal(?ExprPos $_, string $_): Code::TAst {
78 throw new Exception();
81 public function visitLambda(
84 vec<Code::TAst> $_body,
86 throw new Exception();
89 public function visitGlobalFunction<T>(
91 (function(ExampleContext): Awaitable<ExprTree<Code, Code::TAst, T>>) $_,
93 throw new Exception();
96 public function visitStaticMethod<T>(
98 (function(ExampleContext): Awaitable<ExprTree<Code, Code::TAst, T>>) $_,
100 throw new Exception();
103 public function visitCall(
106 vec<Code::TAst> $_args,
108 throw new Exception();
111 public function visitAssign(
116 throw new Exception();
119 public function visitTernary(
121 Code::TAst $_condition,
122 ?Code::TAst $_truthy,
125 throw new Exception();
129 public function visitIf(
132 vec<Code::TAst> $_then_body,
133 vec<Code::TAst> $_else_body,
135 throw new Exception();
137 public function visitWhile(
140 vec<Code::TAst> $_body,
142 throw new Exception();
144 public function visitReturn(?ExprPos $_, ?Code::TAst $_): Code::TAst {
145 throw new Exception();
147 public function visitFor(
154 throw new Exception();
156 public function visitBreak(?ExprPos $_): Code::TAst {
157 throw new Exception();
159 public function visitContinue(?ExprPos $_): Code::TAst {
160 throw new Exception();
162 public function visitPropertyAccess(
167 throw new Exception();
169 public function visitXhp(
172 dict<string, Code::TAst> $_,
175 throw new Exception();
178 public function visitInstanceMethod(
181 string $_method_name,
183 throw new Exception();
186 public function splice<T>(
189 Spliceable<Code, Code::TAst, T> $_,
191 throw new Exception();
195 interface Spliceable<TVisitor, TResult, +TInfer> {
196 public function visit(TVisitor $v): TResult;
199 final class ExprTree<TVisitor, TResult, +TInfer>
200 implements Spliceable<TVisitor, TResult, TInfer> {
201 public function __construct(
202 private ?ExprPos $pos,
204 'splices' => dict<string, mixed>,
205 'functions' => vec<mixed>,
206 'static_methods' => vec<mixed>,
208 private (function(TVisitor): TResult) $ast,
209 private (function(): TInfer) $err,
212 public function visit(TVisitor $v): TResult {
213 return ($this->ast)($v);
217 type ExprPos = shape(...);
219 interface ExampleMixed {
220 public function __tripleEquals(ExampleMixed $_): ExampleBool;
221 public function __notTripleEquals(ExampleMixed $_): ExampleBool;
223 interface ExampleInt extends ExampleMixed {
224 public function __plus(ExampleInt $_): ExampleInt;
225 public function __minus(ExampleInt $_): ExampleInt;
226 public function __star(ExampleInt $_): ExampleInt;
227 public function __slash(ExampleInt $_): ExampleInt;
228 public function __percent(ExampleInt $_): ExampleInt;
229 public function __negate(): ExampleInt;
231 public function __lessThan(ExampleInt $_): ExampleBool;
232 public function __lessThanEqual(ExampleInt $_): ExampleBool;
233 public function __greaterThan(ExampleInt $_): ExampleBool;
234 public function __greaterThanEqual(ExampleInt $_): ExampleBool;
236 public function __amp(ExampleInt $_): ExampleInt;
237 public function __bar(ExampleInt $_): ExampleInt;
238 public function __caret(ExampleInt $_): ExampleInt;
239 public function __lessThanLessThan(ExampleInt $_): ExampleInt;
240 public function __greaterThanGreaterThan(ExampleInt $_): ExampleInt;
241 public function __tilde(): ExampleInt;
244 interface ExampleBool extends ExampleMixed {
245 public function __ampamp(ExampleBool $_): ExampleBool;
246 public function __barbar(ExampleBool $_): ExampleBool;
247 public function __bool(): bool;
248 public function __exclamationMark(): ExampleBool;
251 interface ExampleString extends ExampleMixed, XHPChild {
252 public function __dot(ExampleString $_): ExampleString;
255 interface ExampleFloat extends ExampleMixed {}
257 final class ExampleContext {}
259 interface ExampleVoid {}