mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Address #137
Fix compiler bug when compiling desturctured bindings in a top-level def or var. Also introduce janet_table_clone API call to make this easier.
This commit is contained in:
		| @@ -208,6 +208,18 @@ const JanetKV *janet_table_to_struct(JanetTable *t) { | ||||
|     return janet_struct_end(st); | ||||
| } | ||||
|  | ||||
| /* Clone a table. */ | ||||
| JanetTable *janet_table_clone(JanetTable *table) { | ||||
|     JanetTable *newTable = janet_gcalloc(JANET_MEMORY_TABLE, sizeof(JanetTable)); | ||||
|     memcpy(newTable, table, sizeof(JanetTable)); | ||||
|     newTable->data = malloc(newTable->capacity * sizeof(JanetKV)); | ||||
|     if (NULL == newTable->data) { | ||||
|         JANET_OUT_OF_MEMORY; | ||||
|     } | ||||
|     memcpy(newTable->data, table->data, table->capacity * sizeof(JanetKV)); | ||||
|     return newTable; | ||||
| } | ||||
|  | ||||
| /* Merge a table or struct into a table */ | ||||
| static void janet_table_mergekv(JanetTable *table, const JanetKV *kvs, int32_t cap) { | ||||
|     int32_t i; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose