debugging the compiler
This commit is contained in:
		| @ -1634,8 +1634,10 @@ static HCL_INLINE int compile_symbol (hcl_t* hcl, hcl_oop_t obj) | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		/* add the entire cons pair to the literal frame */ | 		/* add the entire cons pair to the literal frame */ | ||||||
|  |  | ||||||
| 		if (add_literal(hcl, cons, &index) <= -1 || | 		if (add_literal(hcl, cons, &index) <= -1 || | ||||||
| 		    emit_single_param_instruction(hcl, HCL_CODE_PUSH_OBJECT_0, index) <= -1) return -1; | 		    emit_single_param_instruction(hcl, HCL_CODE_PUSH_OBJECT_0, index) <= -1) return -1; | ||||||
|  | HCL_DEBUG5 (hcl, "************* blk depth [%d] %O , index %d lfbase %d lit len %d\n", (int)hcl->c->blk.depth, cons, (int)index, (int)hcl->c->blk.info[hcl->c->blk.depth].lfbase, (int)hcl->code.lit.len); | ||||||
|  |  | ||||||
| 		return 0; | 		return 0; | ||||||
| 	} | 	} | ||||||
| @ -2511,6 +2513,7 @@ static HCL_INLINE int emit_lambda (hcl_t* hcl) | |||||||
| 	hcl_oow_t block_code_size, lfsize; | 	hcl_oow_t block_code_size, lfsize; | ||||||
| 	hcl_ooi_t jip; | 	hcl_ooi_t jip; | ||||||
|  |  | ||||||
|  | HCL_DEBUG1 (hcl, "emit_lambda   depth %d\n", (int)hcl->c->blk.depth); | ||||||
| 	cf = GET_TOP_CFRAME(hcl); | 	cf = GET_TOP_CFRAME(hcl); | ||||||
| 	HCL_ASSERT (hcl, cf->opcode == COP_EMIT_LAMBDA); | 	HCL_ASSERT (hcl, cf->opcode == COP_EMIT_LAMBDA); | ||||||
| 	HCL_ASSERT (hcl, HCL_OOP_IS_SMOOI(cf->operand)); | 	HCL_ASSERT (hcl, HCL_OOP_IS_SMOOI(cf->operand)); | ||||||
| @ -2597,6 +2600,7 @@ static HCL_INLINE int emit_set (hcl_t* hcl) | |||||||
|  |  | ||||||
| 		HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl, cf->operand)); | 		HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl, cf->operand)); | ||||||
|  |  | ||||||
|  | HCL_DEBUG2 (hcl, "emit_set....%O --- %d\n", cf->operand, (int)hcl->c->blk.depth); | ||||||
| 		cons = (hcl_oop_t)hcl_getatsysdic(hcl, cf->operand); | 		cons = (hcl_oop_t)hcl_getatsysdic(hcl, cf->operand); | ||||||
| 		if (!cons)  | 		if (!cons)  | ||||||
| 		{ | 		{ | ||||||
| @ -2641,8 +2645,10 @@ int hcl_compile (hcl_t* hcl, hcl_oop_t obj) | |||||||
| 	HCL_ASSERT (hcl, hcl->c->blk.depth == -1); | 	HCL_ASSERT (hcl, hcl->c->blk.depth == -1); | ||||||
|  |  | ||||||
| /* TODO: in case i implement all global variables as block arguments at the top level...what should i do? */ | /* TODO: in case i implement all global variables as block arguments at the top level...what should i do? */ | ||||||
|  |  | ||||||
| 	hcl->c->blk.depth++; | 	hcl->c->blk.depth++; | ||||||
| 	if (store_temporary_variable_count_for_block(hcl, hcl->c->tv.size, 0) <= -1) return -1; | HCL_DEBUG2 (hcl, "ENTERING DEPTH %d LIT LEN  %d\n", (int)hcl->c->blk.depth, (int)hcl->code.lit.len); | ||||||
|  | 	if (store_temporary_variable_count_for_block(hcl, hcl->c->tv.size, hcl->code.lit.len) <= -1) return -1; | ||||||
|  |  | ||||||
| 	PUSH_CFRAME (hcl, COP_COMPILE_OBJECT, obj); | 	PUSH_CFRAME (hcl, COP_COMPILE_OBJECT, obj); | ||||||
|  |  | ||||||
|  | |||||||
| @ -1674,8 +1674,9 @@ static int execute (hcl_t* hcl) | |||||||
| 				b1 = bcode & 0x7; /* low 3 bits */ | 				b1 = bcode & 0x7; /* low 3 bits */ | ||||||
| 			push_literal: | 			push_literal: | ||||||
| 				LOG_INST_1 (hcl, "push_literal @%zu", b1); | 				LOG_INST_1 (hcl, "push_literal @%zu", b1); | ||||||
| 				//HCL_STACK_PUSH (hcl, hcl->active_function->literal_frame[b1]); | 				/*HCL_STACK_PUSH (hcl, hcl->code.lit.arr->slot[b1]);*/ | ||||||
| 				HCL_STACK_PUSH (hcl, hcl->code.lit.arr->slot[b1]); | 				HCL_STACK_PUSH (hcl, hcl->active_function->literal_frame[b1]); | ||||||
|  | HCL_DEBUG3 (hcl, "*** push literal %O    => %d active_function %p\n", hcl->active_function->literal_frame[b1], b1, hcl->active_function); | ||||||
| 				break; | 				break; | ||||||
|  |  | ||||||
| 			/* ------------------------------------------------- */ | 			/* ------------------------------------------------- */ | ||||||
| @ -1704,6 +1705,7 @@ static int execute (hcl_t* hcl) | |||||||
| 			handle_object: | 			handle_object: | ||||||
| 				/*ass = hcl->code.lit.arr->slot[b1];*/ | 				/*ass = hcl->code.lit.arr->slot[b1];*/ | ||||||
| 				ass = (hcl_oop_cons_t)hcl->active_function->literal_frame[b1]; | 				ass = (hcl_oop_cons_t)hcl->active_function->literal_frame[b1]; | ||||||
|  | HCL_DEBUG3 (hcl, "handle object ass => %O   => %d active_function %p\n", ass, b1, hcl->active_function); | ||||||
| 				HCL_ASSERT (hcl, HCL_IS_CONS(hcl, ass)); | 				HCL_ASSERT (hcl, HCL_IS_CONS(hcl, ass)); | ||||||
|  |  | ||||||
| 				if ((bcode >> 3) & 1) | 				if ((bcode >> 3) & 1) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user