@@ -32,20 +32,26 @@ struct ParsedJson {
3232 size_t bytecapacity; // indicates how many bits are meant to be supported by
3333 // structurals
3434 size_t depthcapacity; // how deep we can go
35+
36+ u32 current_loc;
3537 u8 *structurals;
3638 u32 n_structural_indexes;
3739 u32 *structural_indexes;
3840
3941 u64 * tape;// [MAX_TAPE];
40- u32 * tape_locs;
42+ u32 * containing_scope_offset;
43+ void * * ret_address;
44+
4145 u8 * string_buf;// should be at least bytecapacity
46+
4247 u8 *current_string_buf_loc;
4348 u8 * number_buf;// holds either doubles or longs, really // should be at least 4 * bytecapacity
4449 u8 *current_number_buf_loc;
4550
4651 void init () {
4752 current_string_buf_loc = string_buf;
4853 current_number_buf_loc = number_buf;
54+ current_loc = 0 ;
4955
5056 // for (u32 i = 0; i < MAX_DEPTH; i++) {
5157 // tape_locs[i] = i * MAX_TAPE_ENTRIES;
@@ -75,33 +81,53 @@ struct ParsedJson {
7581 }
7682 }*/
7783 }
78- // TODO: will need a way of saving strings that's a bit more encapsulated
7984
80- void write_tape (u32 depth, u64 val, u8 c) {
81- tape[tape_locs[depth]] = val | (((u64 )c) << 56 );
82- tape_locs[depth]++;
85+ // all elements are stored on the tape using a 64-bit word.
86+ //
87+ // strings, double and ints are stored as
88+ // a 64-bit word with a pointer to the actual value
89+ //
90+ //
91+ //
92+ // for objects or arrays, store [ or { at the beginning and } and ] at the end.
93+ // For the openings ([ or {), we annotate them with a reference to the location on the tape of
94+ // the end, and for then closings (} and ]), we annotate them with a reference to the
95+ // location of the opening
96+ //
97+ //
98+
99+ // this should be considered a private function
100+ void write_tape (u64 val, u8 c) {
101+ tape[current_loc++] = val | (((u64 )c) << 56 );
102+ // tape[tape_locs[depth]] = val | (((u64)c) << 56);
103+ // tape_locs[depth]++;
83104 }
84105
85- void write_tape_s64 (u32 depth, s64 i) {
106+
107+ void write_tape_s64 (s64 i) {
86108 *((s64 *)current_number_buf_loc) = i;
87109 current_number_buf_loc += 8 ;
88- write_tape (depth, current_number_buf_loc - number_buf, ' l' );
110+ write_tape (current_number_buf_loc - number_buf, ' l' );
89111 }
90112
91- void write_tape_double (u32 depth, double d) {
113+ void write_tape_double (double d) {
92114 *((double *)current_number_buf_loc) = d;
93115 current_number_buf_loc += 8 ;
94- write_tape (depth, current_number_buf_loc - number_buf, ' d' );
116+ write_tape (current_number_buf_loc - number_buf, ' d' );
95117 }
96118
97- u32 save_loc ( u32 depth ) {
98- return tape_locs[depth] ;
119+ u32 get_current_loc ( ) {
120+ return current_loc ;
99121 }
100122
101- void write_saved_loc (u32 saved_loc, u64 val, u8 c ) {
102- tape[saved_loc] = val | ((( u64 )c) << 56 ) ;
123+ void annotate_previousloc (u32 saved_loc,u64 val) {
124+ tape[saved_loc] | = val;
103125 }
104126
127+ /* void write_saved_loc(u32 saved_loc, u64 val, u8 c) {
128+ tape[saved_loc] = val | (((u64)c) << 56);
129+ }*/
130+
105131 // public interface
106132#if 1
107133
@@ -121,13 +147,13 @@ struct ParsedJson {
121147 bool prev (); // valid if we're not at the start of a scope
122148 bool up (); // valid if we are at depth != 0
123149 bool down (); // valid if we're at a [ or { call site; moves us to header of that scope
124- void to_start_scope (); // move us to the start of our current scope; always succeeds
125- void to_end_scope (); // move us to the start of our current scope; always succeeds
150+ // void to_start_scope(); // move us to the start of our current scope; always succeeds
151+ // void to_end_scope(); // move us to the start of our current scope; always succeeds
126152
127153 // these navigation elements move us across scope if need be, so allow us to iterate over
128154 // everything at a given depth
129- bool next_flat (); // valid if we're not at the end of a tape
130- bool prev_flat (); // valid if we're not at the start of a tape
155+ // bool next_flat(); // valid if we're not at the end of a tape
156+ // bool prev_flat(); // valid if we're not at the start of a tape
131157
132158 void print (std::ostream & os); // print the thing we're currently pointing at
133159 u8 get_type (); // retrieve the character code of what we're looking at: [{"sltfn are the possibilities
0 commit comments