@@ -39,6 +39,7 @@ final class Ast implements BuildMode
3939 public ?string $ curKey = null ;
4040
4141 private array $ output = [];
42+ private array $ skipped = [];
4243 private ?string $ needsParent = null ;
4344
4445 public function __construct (
@@ -67,6 +68,7 @@ public function finalize(string $refMapFile, string $refMapFileJson): void
6768 'db_schema ' => $ dbSchema ,
6869 'db_schema_json ' => json_encode ($ dbSchemaJSON , flags: JSON_THROW_ON_ERROR ),
6970 'ctxs ' => $ this ->output ,
71+ 'skipped ' => $ this ->skipped ,
7072 ];
7173 Magic::start (false );
7274
@@ -76,6 +78,8 @@ public function finalize(string $refMapFile, string $refMapFileJson): void
7678 $ TL ->init ($ s );
7779 $ serialized = $ TL ->serializeObject (['type ' => 'FileReferenceOrigins ' ], $ value , '' );
7880 $ valueDe = $ TL ->deserialize ($ serialized , ['type ' => '' , 'connection ' => null , 'encrypted ' => true ]);
81+ file_put_contents ('/tmp/a.json ' , json_encode ($ valueDe , flags: JSON_THROW_ON_ERROR ));
82+ file_put_contents ('/tmp/b.json ' , json_encode ($ value , flags: JSON_THROW_ON_ERROR ));
7983 Assert::true ($ value == $ valueDe );
8084 file_put_contents ($ refMapFile , $ serialized );
8185 file_put_contents ($ refMapFileJson , json_encode ($ valueDe , flags: JSON_THROW_ON_ERROR ));
@@ -104,21 +108,11 @@ private static function stringifySchema(string $constructor, array $params): str
104108 }
105109 public function addNode (TLContext $ ctx , ?array $ action = null , ?string $ why = null ): void
106110 {
107- $ out = [
108- '_ ' => 'origin ' ,
109- 'predicate ' => $ ctx ->position ,
110- 'is_constructor ' => $ ctx ->isConstructor ,
111- 'parent_is_constructor ' => false ,
112- ];
113- if ($ this ->needsParent !== null ) {
114- $ out ['needs_parent ' ] = $ this ->needsParent ;
115- $ out ['parent_is_constructor ' ] = $ ctx ->tl ->isConstructor ($ this ->needsParent );
116- }
117111 if ($ action !== null ) {
118112 Assert::keyExists ($ action , 'stored_constructor ' );
119113
120114 $ constructor = $ action ['stored_constructor ' ];
121- $ action ['skipped_flags ' ] = [] ;
115+ unset( $ action ['stored_constructor ' ]) ;
122116
123117 $ names = $ this ->storedNames ;
124118 $ flags = [];
@@ -133,6 +127,7 @@ public function addNode(TLContext $ctx, ?array $action = null, ?string $why = nu
133127 ...$ names ,
134128 ];
135129 }
130+ $ skipped = [];
136131
137132 if (isset ($ this ->outputSchema [$ constructor ])) {
138133 $ existing = $ this ->outputSchema [$ constructor ];
@@ -141,7 +136,7 @@ public function addNode(TLContext $ctx, ?array $action = null, ?string $why = nu
141136 if (isset ($ flags [$ name ])) {
142137 unset($ flags [$ name ], $ names [$ name ]);
143138 } else {
144- $ action [ ' skipped_flags ' ] []= $ name ;
139+ $ skipped []= $ name ;
145140 }
146141 }
147142 }
@@ -166,22 +161,39 @@ public function addNode(TLContext $ctx, ?array $action = null, ?string $why = nu
166161 $ this ->outputSchema [$ constructor ] = $ names ;
167162 }
168163
169- $ out ['action ' ] = $ action ;
164+ $ out = [
165+ '_ ' => 'origin ' ,
166+ 'predicate ' => $ ctx ->position ,
167+ 'is_constructor ' => $ ctx ->isConstructor ,
168+ 'action ' => $ action ,
169+ 'stored_constructor ' => $ constructor ,
170+ 'skipped_flags ' => $ skipped ,
171+ 'parent_is_constructor ' => false ,
172+ ];
173+ if ($ this ->needsParent !== null ) {
174+ $ out ['needs_parent ' ] = $ this ->needsParent ;
175+ $ out ['parent_is_constructor ' ] = $ ctx ->tl ->isConstructor ($ this ->needsParent );
176+ }
177+ $ this ->output [] = $ out ;
170178
171179 $ this ->storedFlags = 0 ;
172180 $ this ->stored = [];
173181 $ this ->storedNames = [];
174182 Assert::null ($ why );
175183 } elseif ($ why !== null ) {
176- $ out ['action ' ] = ['_ ' => 'noOp ' , 'why ' => $ why ];
184+ $ this ->skipped [] = [
185+ '_ ' => 'skippedOrigin ' ,
186+ 'why ' => $ why ,
187+ 'predicate ' => $ ctx ->position ,
188+ 'is_constructor ' => $ ctx ->isConstructor ,
189+ ];
177190 Assert::null ($ action );
178191 Assert::isEmpty ($ this ->stored );
179192 Assert::isEmpty ($ this ->storedNames );
180193 Assert::eq ($ this ->storedFlags , 0 );
181194 } else {
182195 throw new AssertionError ("Either 'action' or 'why' must be provided. " );
183196 }
184- $ this ->output [] = $ out ;
185197 $ this ->needsParent = null ;
186198 $ this ->curKey = null ;
187199 }
0 commit comments