about summary refs log blame commit diff stats
path: root/cpp/.traces/array-from-args
blob: 695f32cb5ca508e908e79d000959e09ef3c3e53e (plain) (tree)
9636c7ae
#ifndef ELF_H
#define ELF_H

#include "common.h"

/*
 * ELF HEADER
 */
typedef struct {
    unsigned char e_ident[16];	/* ELF identification */
    uint16 e_type;		/* 2 (exec file) */
    uint16 e_machine;		/* 3 (intel architecture) */
    uint32 e_version;		/* 1 */
    uint32 e_entry;		/* starting point */
    uint32 e_phoff;		/* program header table offset */
    uint32 e_shoff;		/* section header table offset */
    uint32 e_flags;		/* various flags */
    uint16 e_ehsize;		/* ELF header (this) size */

    uint16 e_phentsize;	/* program header table entry size */
    uint16 e_phnum;		/* number of entries */

    uint16 e_shentsize;	/* section header table entry size */
    uint16 e_shnum;		/* number of entries */

    uint16 e_shstrndx;		/* index of the section name string table */
} Elf32_Ehdr;

/*
 * ELF identification
 */
#define	EI_MAG0		0
#define	EI_MAG1		1
#define	EI_MAG2		2
#define	EI_MAG3		3
#define	EI_CLASS	4
#define	EI_DATA		5
#define	EI_VERSION	6
#define EI_PAD		7

/* EI_MAG */
#define	ELFMAG0		0x7f
#define	ELFMAG1		'E'
#define	ELFMAG2		'L'
#define	ELFMAG3		'F'

/* EI_CLASS */
#define	ELFCLASSNONE	0	/* invalid class */
#define	ELFCLASS32	1	/* 32-bit objects */
#define	ELFCLASS64	2	/* 64-bit objects */

/* EI_DATA */
#define	ELFDATANONE	0	/* invalide data encoding */
#define	ELFDATA2LSB	1	/* least significant byte first (0x01020304 is 0x04 0x03 0x02 0x01) */
#define	ELFDATA2MSB	2	/* most significant byte first (0x01020304 is 0x01 0x02 0x03 0x04) */

/* EI_VERSION */
#define	EV_CURRENT	1
#define	ELFVERSION	EV_CURRENT

/*
 * PROGRAM HEADER
 */
typedef struct {
    uint32 p_type;		/* type of segment */
    uint32 p_offset;
    uint32 p_vaddr;
    uint32 p_paddr;
    uint32 p_filesz;
    uint32 p_memsz;
    uint32 p_flags;
    uint32 p_align;
} Elf32_Phdr;

/* p_type */
#define	PT_NULL             0
#define	PT_LOAD             1
#define	PT_DYNAMIC          2
#define	PT_INTERP           3
#define	PT_NOTE             4
#define	PT_SHLIB            5
#define	PT_PHDR             6
#define	PT_LOPROC  0x70000000
#define	PT_HIPROC  0x7fffffff

/* p_flags */
#define PF_X	0x1
#define PF_W	0x2
#define PF_R	0x4



enum eElfSectionTypes {
    SHT_NULL,	//0
    SHT_PROGBITS,	//1
    SHT_SYMTAB,	//2
    SHT_STRTAB,	//3
    SHT_RELA,	//4
    SHT_HASH,	//5
    SHT_DYNAMIC,	//6
    SHT_NOTE,	//7
    SHT_NOBITS,	//8
    SHT_REL,	//9
    SHT_SHLIB,	//A
    SHT_DYNSYM,	//B
    SHT_LAST,	//C
    SHT_LOPROC = 0x70000000,
    SHT_HIPROC = 0x7fffffff,
    SHT_LOUSER = 0x80000000,
    SHT_HIUSER = 0xffffffff
};


typedef struct {
    uint32		name;
    uint32	type;
    uint32	flags;
    uint32	address;
    uint32	offset;
    uint32	size;
    uint32	link;
    uint32	info;
    uint32	addralign;
    uint32	entsize;
} Elf32_Scdr;





enum {
    R_386_NONE=0,	// none
    R_386_32,	// S+A
    R_386_PC32,	// S+A-P
    R_386_GOT32,	// G+A-P
    R_386_PLT32,	// L+A-P
    R_386_COPY,	// none
    R_386_GLOB_DAT,	// S
    R_386_JMP_SLOT,	// S
    R_386_RELATIVE,	// B+A
    R_386_GOTOFF,	// S+A-GOT
    R_386_GOTPC,	// GOT+A-P
    R_386_LAST	// none
};

typedef struct {
    uint16	d_tag;
    uint32	d_val;	//Also d_ptr
} Elf32_dyn;


enum {
    DT_NULL,	//!< Marks End of list
    DT_NEEDED,	//!< Offset in strtab to needed library
    DT_PLTRELSZ,	//!< Size in bytes of PLT
    DT_PLTGOT,	//!< Address of PLT/GOT
    DT_HASH,	//!< Address of symbol hash table
    DT_STRTAB,	//!< String Table address
    DT_SYMTAB,	//!< Symbol Table address
    DT_RELA,	//!< Relocation table address
    DT_RELASZ,	//!< Size of relocation table
    DT_RELAENT,	//!< Size of entry in relocation table
    DT_STRSZ,	//!< Size of string table
    DT_SYMENT,	//!< Size of symbol table entry
    DT_INIT,	//!< Address of initialisation function
    DT_FINI,	//!< Address of termination function
    DT_SONAME,	//!< String table offset of so name
    DT_RPATH,	//!< String table offset of library path
    DT_SYMBOLIC,//!< Reverse order of symbol searching for library, search libs first then executable
    DT_REL,		//!< Relocation Entries (Elf32_Rel instead of Elf32_Rela)
    DT_RELSZ,	//!< Size of above table (bytes)
    DT_RELENT,	//!< Size of entry in above table
    DT_PLTREL,	//!< Relocation entry of PLT
    DT_DEBUG,	//!< Debugging Entry - Unknown contents
    DT_TEXTREL,	//!< Indicates that modifcations to a non-writeable segment may occur
    DT_JMPREL,	//!< Address of PLT only relocation entries
    DT_LOPROC = 0x70000000,	//!< Low Definable
    DT_HIPROC = 0x7FFFFFFF	//!< High Definable
};

BOOL isElf(char *elfData);
uint32 loadElf(char *elfData);

#endif // ELF_H
om-args?h=hlt&id=72c4fb2ddacc9fccb8ebe8cba9d1322ddcaac017'>72c4fb2d ^
9636c7ae ^

72c4fb2d ^


9636c7ae ^
249a5672 ^
9636c7ae ^

72c4fb2d ^

9636c7ae ^
249a5672 ^
9636c7ae ^





249a5672 ^
9636c7ae ^


249a5672 ^
9636c7ae ^






249a5672 ^
9636c7ae ^



a11d9c4a ^
9636c7ae ^



249a5672 ^
9636c7ae ^


a11d9c4a ^
9636c7ae ^
72c4fb2d ^
9636c7ae ^

72c4fb2d ^


9636c7ae ^
249a5672 ^
9636c7ae ^

72c4fb2d ^

9636c7ae ^
249a5672 ^
9636c7ae ^





249a5672 ^
9636c7ae ^


249a5672 ^
9636c7ae ^






249a5672 ^
9636c7ae ^



a11d9c4a ^
9636c7ae ^



249a5672 ^
9636c7ae ^


a11d9c4a ^
9636c7ae ^
72c4fb2d ^
9636c7ae ^

72c4fb2d ^


9636c7ae ^
249a5672 ^
9636c7ae ^

72c4fb2d ^

9636c7ae ^
249a5672 ^
9636c7ae ^





249a5672 ^
9636c7ae ^


249a5672 ^
9636c7ae ^






249a5672 ^
9636c7ae ^




a11d9c4a ^
72c4fb2d ^


6aea156e ^
249a5672 ^
9636c7ae ^
72c4fb2d ^




9636c7ae ^



22b30692 ^
363685b8 ^
22b30692 ^













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329

























                                                                          
                      





                                                                          
                                



                                                                                                       
                          

                                                                                                                     
                             

                             
                            
                                                                                                                                                                                                                                                                                                     
                               
                                                                                                                                                                                                                                                                     


                               
                                                                                                                                                        


                                 
                                                                                                                                                                                       



                                 
                                                                                                                                                 



                               
                                                                                                                                                                                                                                   





                                 
                                                                


                               
                                                                                                                                                                                       



                                 
                                                                                                                                                 



                               
                                                                                                                                                                                                                                   





                                 
                                                                


                               
                                                                                                                                                                                       



                                 
                                                                                                                                                 



                               
                                                                                                                                                                                                                                   





                                 
                                                                


                               
                                                                                                                                                                                       

                                 
                                                                                                                                                 




                               
                                                                                                                                                                                                                                                                  

                         

                                    
                               
                             
                                
                                                                                                                                          


                                 
                                                                                                                                                                                                                                           






                                 
                                                                                                                                         



                                
                                                                                                                                                                                       



                                 
                                                                                                                                                                                                                                                    


                                
                                                                                                                                                                                                                                                                               
                             
                            

                                                                                   


                                    
                                
                                                                                                                                                                                         

                                 

                                 
                                
                                                                                                                                                                                                       





                                 
                                                                


                                
                                                                                                                                                                                                                                           






                                 
                                                                                                                                         



                                
                                                                                                                                                                                       



                                 
                                                                                                                                                                                                                                                    


                                
                                                                                                                                                                                                                                                                               
                             
                            

                                                                                   


                                    
                                
                                                                                                                                                                                         

                                 

                                 
                                
                                                                                                                                                                                                       





                                 
                                                                


                                
                                                                                                                                                                                                                                           






                                 
                                                                                                                                         



                                
                                                                                                                                                                                       



                                 
                                                                                                                                                                                                                                                    


                                
                                                                                                                                                                                                                                                                               
                             
                            

                                                                                   


                                    
                                
                                                                                                                                                                                         

                                 

                                 
                                
                                                                                                                                                                                                       





                                 
                                                                


                                
                                                                                                                                                                                                                                           






                                 
                                                                                                                                         




                                
                                                                                                             


                                 
                            
                                                                                                                                                                                       
                        




                         



                              
                                    
                                        













                                      
parse/0: instruction: run
parse/0:   ingredient: {name: "
    1:address:array:location <- init-array 0:literal, 1:literal, 2:literal
    2:array:location <- copy 1:address:array:location/deref
  ", value: 0, type: 0, properties: ["
    1:address:array:location <- init-array 0:literal, 1:literal, 2:literal
    2:array:location <- copy 1:address:array:location/deref
  ": "literal-string"]}
parse/0: instruction: memory-should-contain
parse/0:   ingredient: {name: "
    2 <- 3  # array length
    3 <- 0
    4 <- 1
    5 <- 2
  ", value: 0, type: 0, properties: ["
    2 <- 3  # array length
    3 <- 0
    4 <- 1
    5 <- 2
  ": "literal-string"]}
after-brace/0: recipe array-from-args
after-brace/0: run ...
after-brace/0: memory-should-contain ...
new/0: routine allocated memory from 1000 to 101000
schedule/0: array-from-args
run/0: instruction array-from-args/0
run/0: run/45 {name: "
    1:address:array:location <- init-array 0:literal, 1:literal, 2:literal
    2:array:location <- copy 1:address:array:location/deref
  ", value: 0, type: 0, properties: ["
    1:address:array:location <- init-array 0:literal, 1:literal, 2:literal
    2:array:location <- copy 1:address:array:location/deref
  ": "literal-string"]}
parse/0: instruction: init-array
parse/0:   ingredient: {name: "0", value: 0, type: 0, properties: ["0": "literal"]}
parse/0:   ingredient: {name: "1", value: 0, type: 0, properties: ["1": "literal"]}
parse/0:   ingredient: {name: "2", value: 0, type: 0, properties: ["2": "literal"]}
parse/0:   product: {name: "1", value: 0, type: 2-5-1, properties: ["1": "address":"array":"location"]}
parse/0: instruction: copy
parse/0:   ingredient: {name: "1", value: 0, type: 2-5-1, properties: ["1": "address":"array":"location", "deref": ]}
parse/0:   product: {name: "2", value: 0, type: 5-1, properties: ["2": "array":"location"]}
after-brace/0: recipe run1001
after-brace/0: init-array ...
after-brace/0: copy ...
run/0: instruction run1001/0
run/0: {name: "1", value: 1, type: 2-5-1, properties: ["1": "address":"array":"location"]} <- init-array/114 {name: "0", value: 0, type: 0, properties: ["0": "literal"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}, {name: "2", value: 2, type: 0, properties: ["2": "literal"]}
run/0: instruction init-array/0
run/0: {name: "default-space", value: 0, type: 2-5-1, properties: ["default-space": "address":"array":"location"]} <- new/44 {name: "location", value: 1, type: 0, properties: ["location": "type"]}, {name: "30", value: 30, type: 0, properties: ["30": "literal"]}
mem/0: array size is 30
mem/0: new alloc: 1000
run/0: instruction init-array/1
run/0: {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]} <- copy/1 {name: "0", value: 0, type: 0, properties: ["0": "literal"]}
run/0: ingredient 0 is 0
mem/0: storing 0 in location 1002
run/0: instruction init-array/3
run/0: {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}, {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]} <- next-ingredient/30 
run/0: product 0 is 0
mem/0: storing 0 in location 1003
mem/0: storing 1 in location 1004
run/0: instruction init-array/4
run/0: break-unless/12 {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]}, {name: "", value: 2, type: , properties: ["": ]}
mem/0: location 1004 is 1
run/0: ingredient 0 is 1
run/0: jump-unless fell through
run/0: instruction init-array/5
run/0: {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]} <- add/2 {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is capacity
mem/0: location 1002 is 0
run/0: ingredient 1 is 1
run/0: product 0 is 1
mem/0: storing 1 in location 1002
run/0: instruction init-array/6
run/0: loop/10 {name: "", value: -4, type: , properties: ["": ]}
run/0: ingredient 0 is -4
run/0: jumping to instruction 3
run/0: instruction init-array/3
run/0: {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}, {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]} <- next-ingredient/30 
run/0: product 0 is 1
mem/0: storing 1 in location 1003
mem/0: storing 1 in location 1004
run/0: instruction init-array/4
run/0: break-unless/12 {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]}, {name: "", value: 2, type: , properties: ["": ]}
mem/0: location 1004 is 1
run/0: ingredient 0 is 1
run/0: jump-unless fell through
run/0: instruction init-array/5
run/0: {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]} <- add/2 {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is capacity
mem/0: location 1002 is 1
run/0: ingredient 1 is 1
run/0: product 0 is 2
mem/0: storing 2 in location 1002
run/0: instruction init-array/6
run/0: loop/10 {name: "", value: -4, type: , properties: ["": ]}
run/0: ingredient 0 is -4
run/0: jumping to instruction 3
run/0: instruction init-array/3
run/0: {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}, {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]} <- next-ingredient/30 
run/0: product 0 is 2
mem/0: storing 2 in location 1003
mem/0: storing 1 in location 1004
run/0: instruction init-array/4
run/0: break-unless/12 {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]}, {name: "", value: 2, type: , properties: ["": ]}
mem/0: location 1004 is 1
run/0: ingredient 0 is 1
run/0: jump-unless fell through
run/0: instruction init-array/5
run/0: {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]} <- add/2 {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is capacity
mem/0: location 1002 is 2
run/0: ingredient 1 is 1
run/0: product 0 is 3
mem/0: storing 3 in location 1002
run/0: instruction init-array/6
run/0: loop/10 {name: "", value: -4, type: , properties: ["": ]}
run/0: ingredient 0 is -4
run/0: jumping to instruction 3
run/0: instruction init-array/3
run/0: {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}, {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]} <- next-ingredient/30 
mem/0: storing 0 in location 1004
run/0: instruction init-array/4
run/0: break-unless/12 {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]}, {name: "", value: 2, type: , properties: ["": ]}
mem/0: location 1004 is 0
run/0: ingredient 0 is 0
run/0: ingredient 1 is 
run/0: jumping to instruction 7
run/0: instruction init-array/8
run/0: {name: "result", value: 4, type: 2-5-1, properties: ["result": "address":"array":"location"]} <- new/44 {name: "location", value: 1, type: 0, properties: ["location": "type"]}, {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}
mem/0: location 1002 is 3
mem/0: array size is 3
mem/0: new alloc: 1031
mem/0: storing 1031 in location 1005
run/0: instruction init-array/9
run/0: rewind-ingredients/31 
run/0: instruction init-array/10
run/0: {name: "i", value: 5, type: 1, properties: ["i": "integer"]} <- copy/1 {name: "0", value: 0, type: 0, properties: ["0": "literal"]}
run/0: ingredient 0 is 0
mem/0: storing 0 in location 1006
run/0: instruction init-array/12
run/0: {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]} <- greater-or-equal/16 {name: "i", value: 5, type: 1, properties: ["i": "integer"]}, {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}
run/0: ingredient 0 is i
mem/0: location 1006 is 0
run/0: ingredient 1 is capacity
mem/0: location 1002 is 3
run/0: product 0 is 0
mem/0: storing 0 in location 1007
run/0: instruction init-array/13
run/0: break-if/11 {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]}, {name: "", value: 6, type: , properties: ["": ]}
mem/0: location 1007 is 0
run/0: ingredient 0 is 0
run/0: jump-if fell through
run/0: instruction init-array/14
run/0: {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}, {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]} <- next-ingredient/30 
run/0: product 0 is 0
mem/0: storing 0 in location 1003
mem/0: storing 1 in location 1004
run/0: instruction init-array/15
run/0: assert/19 {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]}, {name: "error in rewinding ingredients to init-array", value: 0, type: 0, properties: ["error in rewinding ingredients to init-array": "literal-string"]}
run/0: ingredient 0 is exists?
mem/0: location 1004 is 1
run/0: instruction init-array/16
run/0: {name: "tmp", value: 7, type: 2-1, properties: ["tmp": "address":"location"]} <- index-address/27 {name: "result", value: 4, type: 2-5-1, properties: ["result": "address":"array":"location", "deref": ]}, {name: "i", value: 5, type: 1, properties: ["i": "integer"]}
run/0: ingredient 0 is result
mem/0: location 1005 is 1031
run/0: ingredient 1 is {name: "i", value: 5, type: 1, properties: ["i": "integer"]}
mem/0: location 1006 is 0
run/0: address to copy is 1032
run/0: product 0 is 1032
mem/0: storing 1032 in location 1008
run/0: instruction init-array/17
run/0: {name: "tmp", value: 7, type: 2-1, properties: ["tmp": "address":"location", "deref": ]} <- copy/1 {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}
run/0: ingredient 0 is curr-value
mem/0: location 1003 is 0
mem/0: location 1008 is 1032
mem/0: storing 0 in location 1032
run/0: instruction init-array/18
run/0: {name: "i", value: 5, type: 1, properties: ["i": "integer"]} <- add/2 {name: "i", value: 5, type: 1, properties: ["i": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is i
mem/0: location 1006 is 0
run/0: ingredient 1 is 1
run/0: product 0 is 1
mem/0: storing 1 in location 1006
run/0: instruction init-array/19
run/0: loop/10 {name: "", value: -8, type: , properties: ["": ]}
run/0: ingredient 0 is -8
run/0: jumping to instruction 12
run/0: instruction init-array/12
run/0: {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]} <- greater-or-equal/16 {name: "i", value: 5, type: 1, properties: ["i": "integer"]}, {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}
run/0: ingredient 0 is i
mem/0: location 1006 is 1
run/0: ingredient 1 is capacity
mem/0: location 1002 is 3
run/0: product 0 is 0
mem/0: storing 0 in location 1007
run/0: instruction init-array/13
run/0: break-if/11 {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]}, {name: "", value: 6, type: , properties: ["": ]}
mem/0: location 1007 is 0
run/0: ingredient 0 is 0
run/0: jump-if fell through
run/0: instruction init-array/14
run/0: {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}, {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]} <- next-ingredient/30 
run/0: product 0 is 1
mem/0: storing 1 in location 1003
mem/0: storing 1 in location 1004
run/0: instruction init-array/15
run/0: assert/19 {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]}, {name: "error in rewinding ingredients to init-array", value: 0, type: 0, properties: ["error in rewinding ingredients to init-array": "literal-string"]}
run/0: ingredient 0 is exists?
mem/0: location 1004 is 1
run/0: instruction init-array/16
run/0: {name: "tmp", value: 7, type: 2-1, properties: ["tmp": "address":"location"]} <- index-address/27 {name: "result", value: 4, type: 2-5-1, properties: ["result": "address":"array":"location", "deref": ]}, {name: "i", value: 5, type: 1, properties: ["i": "integer"]}
run/0: ingredient 0 is result
mem/0: location 1005 is 1031
run/0: ingredient 1 is {name: "i", value: 5, type: 1, properties: ["i": "integer"]}
mem/0: location 1006 is 1
run/0: address to copy is 1033
run/0: product 0 is 1033
mem/0: storing 1033 in location 1008
run/0: instruction init-array/17
run/0: {name: "tmp", value: 7, type: 2-1, properties: ["tmp": "address":"location", "deref": ]} <- copy/1 {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}
run/0: ingredient 0 is curr-value
mem/0: location 1003 is 1
mem/0: location 1008 is 1033
mem/0: storing 1 in location 1033
run/0: instruction init-array/18
run/0: {name: "i", value: 5, type: 1, properties: ["i": "integer"]} <- add/2 {name: "i", value: 5, type: 1, properties: ["i": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is i
mem/0: location 1006 is 1
run/0: ingredient 1 is 1
run/0: product 0 is 2
mem/0: storing 2 in location 1006
run/0: instruction init-array/19
run/0: loop/10 {name: "", value: -8, type: , properties: ["": ]}
run/0: ingredient 0 is -8
run/0: jumping to instruction 12
run/0: instruction init-array/12
run/0: {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]} <- greater-or-equal/16 {name: "i", value: 5, type: 1, properties: ["i": "integer"]}, {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}
run/0: ingredient 0 is i
mem/0: location 1006 is 2
run/0: ingredient 1 is capacity
mem/0: location 1002 is 3
run/0: product 0 is 0
mem/0: storing 0 in location 1007
run/0: instruction init-array/13
run/0: break-if/11 {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]}, {name: "", value: 6, type: , properties: ["": ]}
mem/0: location 1007 is 0
run/0: ingredient 0 is 0
run/0: jump-if fell through
run/0: instruction init-array/14
run/0: {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}, {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]} <- next-ingredient/30 
run/0: product 0 is 2
mem/0: storing 2 in location 1003
mem/0: storing 1 in location 1004
run/0: instruction init-array/15
run/0: assert/19 {name: "exists?", value: 3, type: 3, properties: ["exists?": "boolean"]}, {name: "error in rewinding ingredients to init-array", value: 0, type: 0, properties: ["error in rewinding ingredients to init-array": "literal-string"]}
run/0: ingredient 0 is exists?
mem/0: location 1004 is 1
run/0: instruction init-array/16
run/0: {name: "tmp", value: 7, type: 2-1, properties: ["tmp": "address":"location"]} <- index-address/27 {name: "result", value: 4, type: 2-5-1, properties: ["result": "address":"array":"location", "deref": ]}, {name: "i", value: 5, type: 1, properties: ["i": "integer"]}
run/0: ingredient 0 is result
mem/0: location 1005 is 1031
run/0: ingredient 1 is {name: "i", value: 5, type: 1, properties: ["i": "integer"]}
mem/0: location 1006 is 2
run/0: address to copy is 1034
run/0: product 0 is 1034
mem/0: storing 1034 in location 1008
run/0: instruction init-array/17
run/0: {name: "tmp", value: 7, type: 2-1, properties: ["tmp": "address":"location", "deref": ]} <- copy/1 {name: "curr-value", value: 2, type: 1, properties: ["curr-value": "location"]}
run/0: ingredient 0 is curr-value
mem/0: location 1003 is 2
mem/0: location 1008 is 1034
mem/0: storing 2 in location 1034
run/0: instruction init-array/18
run/0: {name: "i", value: 5, type: 1, properties: ["i": "integer"]} <- add/2 {name: "i", value: 5, type: 1, properties: ["i": "integer"]}, {name: "1", value: 1, type: 0, properties: ["1": "literal"]}
run/0: ingredient 0 is i
mem/0: location 1006 is 2
run/0: ingredient 1 is 1
run/0: product 0 is 3
mem/0: storing 3 in location 1006
run/0: instruction init-array/19
run/0: loop/10 {name: "", value: -8, type: , properties: ["": ]}
run/0: ingredient 0 is -8
run/0: jumping to instruction 12
run/0: instruction init-array/12
run/0: {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]} <- greater-or-equal/16 {name: "i", value: 5, type: 1, properties: ["i": "integer"]}, {name: "capacity", value: 1, type: 1, properties: ["capacity": "integer"]}
run/0: ingredient 0 is i
mem/0: location 1006 is 3
run/0: ingredient 1 is capacity
mem/0: location 1002 is 3
run/0: product 0 is 1
mem/0: storing 1 in location 1007
run/0: instruction init-array/13
run/0: break-if/11 {name: "done?", value: 6, type: 3, properties: ["done?": "boolean"]}, {name: "", value: 6, type: , properties: ["": ]}
mem/0: location 1007 is 1
run/0: ingredient 0 is 1
run/0: ingredient 1 is 
run/0: jumping to instruction 20
run/0: instruction init-array/21
run/0: reply/33 {name: "result", value: 4, type: 2-5-1, properties: ["result": "address":"array":"location"]}
mem/0: location 1005 is 1031
run/0: result 0 is 1031
mem/0: storing 1031 in location 1
run/0: instruction run1001/1
run/0: {name: "2", value: 2, type: 5-1, properties: ["2": "array":"location"]} <- copy/1 {name: "1", value: 1, type: 2-5-1, properties: ["1": "address":"array":"location", "deref": ]}
run/0: ingredient 0 is 1
mem/0: location 1 is 1031
mem/0: location 1031 is 3
mem/0: location 1032 is 0
mem/0: location 1033 is 1
mem/0: location 1034 is 2
mem/0: storing 3 in location 2
mem/0: storing 0 in location 3
mem/0: storing 1 in location 4
mem/0: storing 2 in location 5
run/0: instruction array-from-args/1
run/0: memory-should-contain/46 {name: "
    2 <- 3  # array length
    3 <- 0
    4 <- 1
    5 <- 2
  ", value: 0, type: 0, properties: ["
    2 <- 3  # array length
    3 <- 0
    4 <- 1
    5 <- 2
  ": "literal-string"]}
run/0: checking location 2
run/0: checking location 3
run/0: checking location 4
run/0: checking location 5