| 
									
										
										
										
											2013-05-11 21:46:08 -04:00
										 |  |  | namespace factor { | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-29 14:53:10 -04:00
										 |  |  | struct growable_byte_array { | 
					
						
							| 
									
										
										
										
											2013-05-11 21:46:08 -04:00
										 |  |  |   cell count; | 
					
						
							|  |  |  |   data_root<byte_array> elements; | 
					
						
							| 
									
										
										
										
											2009-09-29 14:53:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-13 23:42:44 -05:00
										 |  |  |   /* Allocates memory */ | 
					
						
							| 
									
										
										
										
											2013-05-12 21:48:38 -04:00
										 |  |  |   growable_byte_array(factor_vm* parent, cell capacity = 40) | 
					
						
							| 
									
										
										
										
											2013-05-11 21:46:08 -04:00
										 |  |  |       : count(0), elements(parent->allot_byte_array(capacity), parent) {} | 
					
						
							| 
									
										
										
										
											2009-09-29 14:53:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:46:08 -04:00
										 |  |  |   void grow_bytes(cell len); | 
					
						
							|  |  |  |   void append_bytes(void* elts, cell len); | 
					
						
							|  |  |  |   void append_byte_array(cell elts); | 
					
						
							| 
									
										
										
										
											2009-09-29 14:53:10 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 21:46:08 -04:00
										 |  |  |   void trim(); | 
					
						
							| 
									
										
										
										
											2009-09-29 14:53:10 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-16 00:30:55 -04:00
										 |  |  | /* Allocates memory */ | 
					
						
							| 
									
										
										
										
											2013-05-11 21:46:08 -04:00
										 |  |  | template <typename Type> | 
					
						
							|  |  |  | byte_array* factor_vm::byte_array_from_value(Type* value) { | 
					
						
							|  |  |  |   byte_array* data = allot_uninitialized_array<byte_array>(sizeof(Type)); | 
					
						
							|  |  |  |   memcpy(data->data<char>(), value, sizeof(Type)); | 
					
						
							|  |  |  |   return data; | 
					
						
							| 
									
										
										
										
											2009-10-27 04:32:28 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-04 02:46:13 -04:00
										 |  |  | } |