mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	minor changes.
This commit is contained in:
		| @@ -439,7 +439,7 @@ static void dst_compile_return(DstCompiler *c, const DstValue *sourcemap, DstSlo | |||||||
|     } else { |     } else { | ||||||
|         DstLocalSlot ls = dst_compile_slot_pre( |         DstLocalSlot ls = dst_compile_slot_pre( | ||||||
|                 c, sourcemap, 0xFFFF, -1, |                 c, sourcemap, 0xFFFF, -1, | ||||||
|                 1, 1, s); |                 0, 1, s); | ||||||
|         dst_compile_emit(c, sourcemap, DOP_RETURN | (ls.index << 8)); |         dst_compile_emit(c, sourcemap, DOP_RETURN | (ls.index << 8)); | ||||||
|         dst_compile_slot_post(c, sourcemap, ls); |         dst_compile_slot_post(c, sourcemap, ls); | ||||||
|     } |     } | ||||||
| @@ -516,30 +516,48 @@ static DstFuncDef *dst_compile_pop_funcdef(DstCompiler *c) { | |||||||
|  |  | ||||||
|     /* Initialize funcdef */ |     /* Initialize funcdef */ | ||||||
|     def = dst_alloc(DST_MEMORY_FUNCDEF, sizeof(DstFuncDef)); |     def = dst_alloc(DST_MEMORY_FUNCDEF, sizeof(DstFuncDef)); | ||||||
|     def->environments_length = scope->envcount; |     def->environments = NULL; | ||||||
|     def->environments = malloc(sizeof(int32_t) * def->environments_length); |     def->constants = NULL; | ||||||
|     def->constants_length = 0; |  | ||||||
|     def->constants = malloc(sizeof(DstValue) * scope->constants.count); |  | ||||||
|     def->bytecode_length = c->buffercount - scope->bytecode_start; |  | ||||||
|     def->bytecode = malloc(sizeof(uint32_t) * def->bytecode_length); |  | ||||||
|     def->slotcount = scope->slots.count; |     def->slotcount = scope->slots.count; | ||||||
|  |  | ||||||
|     if (NULL == def->environments || |     /* Copy envs */ | ||||||
|         NULL == def->constants || |     def->environments_length = scope->envcount; | ||||||
|         NULL == def->bytecode) { |     if (def->environments_length) { | ||||||
|         DST_OUT_OF_MEMORY; |         def->environments = malloc(sizeof(int32_t) * def->environments_length); | ||||||
|  |         if (def->environments == NULL) { | ||||||
|  |             DST_OUT_OF_MEMORY; | ||||||
|  |         } | ||||||
|  |         memcpy(def->environments, scope->envs, def->environments_length * sizeof(int32_t)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     memcpy(def->environments, scope->envs, def->environments_length * sizeof(int32_t)); |     /* Copy constants */ | ||||||
|     memcpy(def->constants, scope->constants.data, def->constants_length * sizeof(DstValue)); |     def->constants_length = scope->constants.count; | ||||||
|     memcpy(def->bytecode, c->buffer + c->buffercount, def->bytecode_length * sizeof(uint32_t)); |     if (def->constants) { | ||||||
|  |         def->constants = malloc(sizeof(DstValue) * scope->constants.count); | ||||||
|  |         if (NULL == def->constants) { | ||||||
|  |             DST_OUT_OF_MEMORY; | ||||||
|  |         } | ||||||
|  |         memcpy(def->constants, scope->constants.data, def->constants_length * sizeof(DstValue)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /* Copy bytecode */ | ||||||
|  |     def->bytecode_length = c->buffercount - scope->bytecode_start; | ||||||
|  |     if (def->bytecode_length) { | ||||||
|  |         def->bytecode = malloc(sizeof(uint32_t) * def->bytecode_length); | ||||||
|  |         if (NULL == def->bytecode) { | ||||||
|  |             DST_OUT_OF_MEMORY; | ||||||
|  |         } | ||||||
|  |         memcpy(def->bytecode, c->buffer + c->buffercount, def->bytecode_length * sizeof(uint32_t)); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     /* Copy source map over */ | ||||||
|     if (c->mapbuffer) { |     if (c->mapbuffer) { | ||||||
|         def->sourcemap = malloc(sizeof(uint32_t) * 2 * def->bytecode_length); |         def->sourcemap = malloc(sizeof(int32_t) * 2 * def->bytecode_length); | ||||||
|         if (NULL == def->sourcemap) { |         if (NULL == def->sourcemap) { | ||||||
|             DST_OUT_OF_MEMORY; |             DST_OUT_OF_MEMORY; | ||||||
|         } |         } | ||||||
|         memcpy(def->sourcemap, c->mapbuffer + 2 * c->buffercount, def->bytecode_length * 2 * sizeof(uint32_t)); |         memcpy(def->sourcemap, c->mapbuffer + 2 * c->buffercount, def->bytecode_length * 2 * sizeof(int32_t)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Reset bytecode gen */ |     /* Reset bytecode gen */ | ||||||
|   | |||||||
| @@ -680,7 +680,7 @@ int dst_init() { | |||||||
|      * a collection pretty much every cycle, which is |      * a collection pretty much every cycle, which is | ||||||
|      * horrible for performance, but helps ensure |      * horrible for performance, but helps ensure | ||||||
|      * there are no memory bugs during dev */ |      * there are no memory bugs during dev */ | ||||||
|     dst_vm_memory_interval = 0; |     dst_vm_memory_interval = 0x0000000; | ||||||
|     dst_symcache_init(); |     dst_symcache_init(); | ||||||
|     /* Set thread */ |     /* Set thread */ | ||||||
|     dst_vm_fiber = NULL; |     dst_vm_fiber = NULL; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 bakpakin
					bakpakin