@@ -44,10 +44,91 @@ public SixModelObject deserialize_stub(ThreadContext tc, STable st) {
44
44
45
45
public void deserialize_finish (ThreadContext tc , STable st ,
46
46
SerializationReader reader , SixModelObject obj ) {
47
- // XXX TODO
47
+ NFAInstance body = (NFAInstance )obj ;
48
+
49
+ /* Read fates. */
50
+ body .fates = reader .readRef ();
51
+
52
+ /* Read number of states. */
53
+ body .numStates = (int )reader .readLong ();
54
+
55
+ if (body .numStates > 0 ) {
56
+ /* Read state edge list counts. */
57
+ int [] numStateEdges = new int [body .numStates ];
58
+ for (int i = 0 ; i < body .numStates ; i ++)
59
+ numStateEdges [i ] = (int )reader .readLong ();
60
+
61
+ /* Read state graph. */
62
+ body .states = new NFAStateInfo [body .numStates ][];
63
+ for (int i = 0 ; i < body .numStates ; i ++) {
64
+ int edges = numStateEdges [i ];
65
+ body .states [i ] = new NFAStateInfo [edges ];
66
+ for (int j = 0 ; j < edges ; j ++) {
67
+ body .states [i ][j ] = new NFAStateInfo ();
68
+ body .states [i ][j ].act = (int )reader .readLong ();
69
+ body .states [i ][j ].to = (int )reader .readLong ();
70
+ switch (body .states [i ][j ].act ) {
71
+ case EDGE_FATE :
72
+ case EDGE_CODEPOINT :
73
+ case EDGE_CODEPOINT_NEG :
74
+ case EDGE_CHARCLASS :
75
+ case EDGE_CHARCLASS_NEG :
76
+ body .states [i ][j ].arg_i = (int )reader .readLong ();
77
+ break ;
78
+ case EDGE_CHARLIST :
79
+ case EDGE_CHARLIST_NEG :
80
+ body .states [i ][j ].arg_s = reader .readStr ();
81
+ break ;
82
+ case EDGE_CODEPOINT_I :
83
+ case EDGE_CODEPOINT_I_NEG : {
84
+ body .states [i ][j ].arg_lc = (char )reader .readLong ();
85
+ body .states [i ][j ].arg_uc = (char )reader .readLong ();
86
+ break ;
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
48
92
}
49
93
50
94
public void serialize (ThreadContext tc , SerializationWriter writer , SixModelObject obj ) {
51
- // XXX TODO
95
+ NFAInstance body = (NFAInstance )obj ;
96
+
97
+ /* Write fates. */
98
+ writer .writeRef (body .fates );
99
+
100
+ /* Write number of states. */
101
+ writer .writeInt (body .numStates );
102
+
103
+ /* Write state edge list counts. */
104
+ for (int i = 0 ; i < body .numStates ; i ++)
105
+ writer .writeInt (body .states [i ].length );
106
+
107
+ /* Write state graph. */
108
+ for (int i = 0 ; i < body .numStates ; i ++) {
109
+ for (int j = 0 ; j < body .states [i ].length ; j ++) {
110
+ writer .writeInt (body .states [i ][j ].act );
111
+ writer .writeInt (body .states [i ][j ].to );
112
+ switch (body .states [i ][j ].act ) {
113
+ case EDGE_FATE :
114
+ case EDGE_CODEPOINT :
115
+ case EDGE_CODEPOINT_NEG :
116
+ case EDGE_CHARCLASS :
117
+ case EDGE_CHARCLASS_NEG :
118
+ writer .writeInt (body .states [i ][j ].arg_i );
119
+ break ;
120
+ case EDGE_CHARLIST :
121
+ case EDGE_CHARLIST_NEG :
122
+ writer .writeStr (body .states [i ][j ].arg_s );
123
+ break ;
124
+ case EDGE_CODEPOINT_I :
125
+ case EDGE_CODEPOINT_I_NEG : {
126
+ writer .writeInt (body .states [i ][j ].arg_lc );
127
+ writer .writeInt (body .states [i ][j ].arg_uc );
128
+ break ;
129
+ }
130
+ }
131
+ }
132
+ }
52
133
}
53
134
}
0 commit comments