2 ion\Symbol\Table\Shared
10 $c->add(new ion\Symbol\Table\Shared("shared", 1, ["shared1", "shared2"]));
11 $w = new ion\Writer\Buffer\Writer(catalog: $c, outputBinary: true);
13 $w->writeSymbol("shared1");
14 $w->writeSymbol("shared1");
15 $w->writeSymbol("shared2");
16 $w->writeSymbol("shared2");
20 foreach (str_split($w->getBuffer(), 8) as $line) {
21 printf("%-26s", chunk_split(bin2hex($line), 2, " "));
22 foreach (str_split($line) as $byte) {
23 echo $byte >= ' ' && $byte <= '~' ? $byte : ".";
29 $u = new ion\Unserializer\Unserializer(multiSequence: true);
30 var_dump($s = $u->unserialize($w->getBuffer()));
32 foreach ($s as $sym) {
33 /** @var ion\Symbol $sym */
34 $t = $c->findBest($sym->importLocation->name);
35 $r = $t->findLocal($sym->importLocation->location);
36 printf("%s: %s@%d\n", $r->value, $sym->importLocation->name,
37 $sym->importLocation->location);
40 $u = new ion\Unserializer\Unserializer(multiSequence: true);
41 var_dump($u->unserialize(new ion\Reader\Buffer\Reader($w->getBuffer(),
43 onContextChange: fn(ion\Reader $r) => print("on_context_change\n")
50 e0 01 00 ea ee 97 81 83 ........
51 de 93 86 be 90 de 8e 84 ........
52 86 73 68 61 72 65 64 85 .shared.
53 21 01 88 21 02 71 0a 71 !..!.q.q
58 object(ion\Symbol)#%d (3) {
64 object(ion\Symbol\ImportLocation)#%d (2) {
72 object(ion\Symbol)#%d (3) {
78 object(ion\Symbol\ImportLocation)#%d (2) {
86 object(ion\Symbol)#%d (3) {
92 object(ion\Symbol\ImportLocation)#%d (2) {
100 object(ion\Symbol)#%d (3) {
106 object(ion\Symbol\ImportLocation)#%d (2) {
121 object(ion\Symbol)#%d (3) {
127 object(ion\Symbol\ImportLocation)#%d (2) {
135 object(ion\Symbol)#%d (3) {
141 object(ion\Symbol\ImportLocation)#%d (2) {
149 object(ion\Symbol)#%d (3) {
155 object(ion\Symbol\ImportLocation)#%d (2) {
163 object(ion\Symbol)#%d (3) {
169 object(ion\Symbol\ImportLocation)#%d (2) {