Add position metadata to desugaring
[hiphop-php.git] / hphp / hack / test / typecheck / expression_trees / expr_tree_defs.php
blobb8f0cb3e11c66ded9d27098106abfe9e85d0b21b
1 <?hh
3 //// BEGIN DEFS
4 // Placeholder definition so we don't get naming/typing errors.
5 final class Code {
6 const type TAst = mixed;
7 // Simple literals.
8 public function intLiteral(?ExprPos $_, int $_): this::TAst {
9 throw new Exception();
11 public function boolLiteral(?ExprPos $_, bool $_): this::TAst {
12 throw new Exception();
14 public function stringLiteral(?ExprPos $_, string $_): this::TAst {
15 throw new Exception();
17 public function nullLiteral(?ExprPos $_): this::TAst {
18 throw new Exception();
20 public function localVar(?ExprPos $_, string $_): this::TAst {
21 throw new Exception();
23 public function lambdaLiteral(
24 ?ExprPos $_,
25 vec<string> $_args,
26 vec<this::TAst> $_body,
27 ): this::TAst {
28 throw new Exception();
31 // Operators
32 public function plus(
33 ?ExprPos $_,
34 this::TAst $_,
35 this::TAst $_,
36 ): this::TAst {
37 throw new Exception();
39 public function ampamp(
40 ?ExprPos $_,
41 this::TAst $_,
42 this::TAst $_,
43 ): this::TAst {
44 throw new Exception();
46 public function barbar(
47 ?ExprPos $_,
48 this::TAst $_,
49 this::TAst $_,
50 ): this::TAst {
51 throw new Exception();
53 public function exclamationMark(
54 ?ExprPos $_,
55 this::TAst $_,
56 ): this::TAst {
57 throw new Exception();
59 public function call(
60 ?ExprPos $_,
61 string $_fnName,
62 vec<this::TAst> $_args,
63 ): this::TAst {
64 throw new Exception();
67 public function assign(
68 ?ExprPos $_,
69 this::TAst $_,
70 this::TAst $_,
71 ): this::TAst {
72 throw new Exception();
75 // Statements.
76 public function ifStatement(
77 ?ExprPos $_,
78 this::TAst $_cond,
79 vec<this::TAst> $_then_body,
80 vec<this::TAst> $_else_body,
81 ): this::TAst {
82 throw new Exception();
84 public function whileStatement(
85 ?ExprPos $_,
86 this::TAst $_cond,
87 vec<this::TAst> $_body,
88 ): this::TAst {
89 throw new Exception();
91 public function returnStatement(
92 ?ExprPos $_,
93 ?this::TAst $_,
94 ): this::TAst {
95 throw new Exception();
97 public function forStatement(
98 ?ExprPos $_,
99 vec<this::TAst> $_,
100 this::TAst $_,
101 vec<this::TAst> $_,
102 vec<this::TAst> $_,
103 ): this::TAst {
104 throw new Exception();
106 public function breakStatement(?ExprPos $_): this::TAst {
107 throw new Exception();
109 public function continueStatement(?ExprPos $_,): this::TAst {
110 throw new Exception();
113 // Splice
114 public function splice<T>(
115 ?ExprPos $_,
116 ExprTree<this, this::TAst, T> $_,
117 ): this::TAst {
118 throw new Exception();
121 // TODO: Discard unsupported syntax nodes while lowering
122 public function unsupportedSyntax(string $msg): this::TAst {
123 throw new Exception($msg);
127 final class ExprTree<TVisitor, TResult, TInfer>{
128 public function __construct(
129 private ?ExprPos $pos,
130 private (function(TVisitor): TResult) $x,
131 private (function(): TInfer) $err,
132 ) {}
135 final class ExprPos {
136 public function __construct(
137 private int $begin_line,
138 private int $begin_col,
139 private int $end_line,
140 private int $end_col,
141 ) {}
143 //// END DEFS