File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -984,6 +984,8 @@ class Variant(Object):
984984 TYPE_ACCESS := b"@" ,
985985 TYPE_SPREAD := b"S" ,
986986 TYPE_NAMED_SPREAD := b"R" ,
987+ TYPE_TRUE := b"T" ,
988+ TYPE_FALSE := b"F"
987989]
988990FLAG_REF = 0x80
989991
@@ -1091,6 +1093,10 @@ def serialize(self, obj: Object) -> None:
10911093 self .serialize (item )
10921094 return
10931095 if isinstance (obj , Variant ):
1096+ if obj .tag == "true" and isinstance (obj .value , Hole ):
1097+ return self .emit (TYPE_TRUE )
1098+ if obj .tag == "false" and isinstance (obj .value , Hole ):
1099+ return self .emit (TYPE_FALSE )
10941100 # TODO(max): Determine if this should be a ref
10951101 self .emit (TYPE_VARIANT )
10961102 # TODO(max): String pool (via refs) for strings longer than some length?
@@ -1329,6 +1335,12 @@ def parse(self) -> Object:
13291335 return Spread ()
13301336 if ty == TYPE_NAMED_SPREAD :
13311337 return Spread (self ._string ())
1338+ if ty == TYPE_TRUE :
1339+ assert not is_ref
1340+ return Variant ("true" , Hole ())
1341+ if ty == TYPE_FALSE :
1342+ assert not is_ref
1343+ return Variant ("false" , Hole ())
13321344 raise NotImplementedError (bytes (ty ))
13331345
13341346
You can’t perform that action at this time.
0 commit comments