2 ion\Symbol\Table\Shared
10 $c->add(new ion\Symbol\Table\Shared("shared", 1, ["shared1", "shared2"]));
11 $w = new ion\Writer\Buffer\Writer($buf,
12 new ion\Writer\Options(catalog: $c, outputBinary: true));
14 $w->writeSymbol("shared1");
15 $w->writeSymbol("shared1");
16 $w->writeSymbol("shared2");
17 $w->writeSymbol("shared2");
21 foreach (str_split($buf, 8) as $line) {
22 printf("%-26s", chunk_split(bin2hex($line), 2, " "));
23 foreach (str_split($line) as $byte) {
24 echo ctype_print($byte) ? $byte : ".";
30 $u = new ion\Unserializer\PHP(multiSequence: true);
31 var_dump($s = $u->unserialize($buf));
33 foreach ($s as $sym) {
34 /** @var ion\Symbol $sym */
35 $t = $c->findBest($sym->importLocation->name);
36 $r = $t->findLocal($sym->importLocation->location);
37 printf("%s: %s@%d\n", $r->value, $sym->importLocation->name,
38 $sym->importLocation->location);
41 $u = new ion\Unserializer\PHP(multiSequence: true,
42 readerOptions: new ion\Reader\Options(
44 onContextChange: fn(ion\Reader $r) => print("on_context_change\n")));
45 var_dump($u->unserialize($buf));
51 e0 01 00 ea ee 97 81 83 ........
52 de 93 86 be 90 de 8e 84 ........
53 86 73 68 61 72 65 64 85 .shared.
54 21 01 88 21 02 71 0a 71 !..!.q.q
59 object(ion\Symbol)#%d (3) {
65 object(ion\Symbol\ImportLocation)#%d (2) {
73 object(ion\Symbol)#%d (3) {
79 object(ion\Symbol\ImportLocation)#%d (2) {
87 object(ion\Symbol)#%d (3) {
93 object(ion\Symbol\ImportLocation)#%d (2) {
101 object(ion\Symbol)#%d (3) {
107 object(ion\Symbol\ImportLocation)#%d (2) {
122 object(ion\Symbol)#%d (3) {
128 object(ion\Symbol\ImportLocation)#%d (2) {
136 object(ion\Symbol)#%d (3) {
142 object(ion\Symbol\ImportLocation)#%d (2) {
150 object(ion\Symbol)#%d (3) {
156 object(ion\Symbol\ImportLocation)#%d (2) {
164 object(ion\Symbol)#%d (3) {
170 object(ion\Symbol\ImportLocation)#%d (2) {