added the class_enter and class_exit instructions - partially implemented yet
This commit is contained in:
		| @ -1326,11 +1326,9 @@ static int compile_break (hcl_t* hcl, hcl_cnode_t* src) | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_TRY_EXIT, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				break; | ||||
|  | ||||
| #if 0 | ||||
| 			case HCL_CBLK_TYPE_CLASS: | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_TRY_CLASS, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_CLASS_EXIT, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				break; | ||||
| #endif | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @ -1438,11 +1436,9 @@ static int compile_continue (hcl_t* hcl, hcl_cnode_t* src) | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_TRY_EXIT, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				break; | ||||
|  | ||||
| #if 0 | ||||
| 			case HCL_CBLK_TYPE_CLASS: | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_CLASS_EXIT, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				break; | ||||
| #endif | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @ -1801,11 +1797,12 @@ printf ("22222222222\n"); | ||||
| 		obj = HCL_CNODE_CONS_CDR(obj); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	if (push_clsblk(hcl, HCL_CNODE_GET_LOC(cmd), 0, 0) <= -1) return -1; | ||||
|  | ||||
| 	/* TODO: emit make_class code... | ||||
| 	*/ | ||||
|  | ||||
| 	if (emit_byte_instruction(hcl, HCL_CODE_CLASS_ENTER, HCL_CNODE_GET_LOC(cmd)) <= -1) return -1; | ||||
|  | ||||
| 	SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT_LIST, obj); /* 1 */ | ||||
| 	PUSH_SUBCFRAME (hcl, COP_POST_CLASS, class_name); /* 2*/ | ||||
| @ -1861,6 +1858,7 @@ static HCL_INLINE int post_class (hcl_t* hcl) | ||||
| 	} | ||||
| #else | ||||
| /* should i make the assignment in POST?  or after variable declarations immediately? */ | ||||
| 	if (emit_byte_instruction(hcl, HCL_CODE_CLASS_EXIT, HCL_CNODE_GET_LOC(cf->operand)) <= -1) return -1; | ||||
| 	printf ("end of CLASS DEFINITION\n"); | ||||
| 	POP_CFRAME (hcl); | ||||
| #endif | ||||
| @ -2190,15 +2188,17 @@ static int compile_return (hcl_t* hcl, hcl_cnode_t* src, int ret_from_home) | ||||
| 	{ | ||||
| 		switch (hcl->c->cblk.info[i]._type) | ||||
| 		{ | ||||
| 			case HCL_CBLK_TYPE_LOOP: | ||||
| 				/* do nothing */ | ||||
| 				break; | ||||
|  | ||||
| 			case HCL_CBLK_TYPE_TRY: | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_TRY_EXIT, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				break; | ||||
|  | ||||
| #if 0 | ||||
| 			case HCL_CBLK_TYPE_CLASS: | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_TRY_CLASS, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				if (emit_byte_instruction(hcl, HCL_CODE_CLASS_EXIT, HCL_CNODE_GET_LOC(src)) <= -1) return -1; | ||||
| 				break; | ||||
| #endif | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|  | ||||
| @ -377,6 +377,14 @@ int hcl_decode (hcl_t* hcl, hcl_oow_t start, hcl_oow_t end) | ||||
| 				LOG_INST_0 (hcl, "throw"); | ||||
| 				break; | ||||
| 			/* -------------------------------------------------------- */ | ||||
| 			case HCL_CODE_CLASS_ENTER: | ||||
| 				LOG_INST_0 (hcl, "class_enter"); | ||||
| 				break; | ||||
| 				 | ||||
| 			case HCL_CODE_CLASS_EXIT: | ||||
| 				LOG_INST_0 (hcl, "class_exit"); | ||||
| 				break; | ||||
| 			/* -------------------------------------------------------- */ | ||||
|  | ||||
| 			case HCL_CODE_PUSH_CTXTEMPVAR_X: | ||||
| 			case HCL_CODE_STORE_INTO_CTXTEMPVAR_X: | ||||
|  | ||||
| @ -3268,6 +3268,23 @@ if (do_throw(hcl, hcl->_nil, fetched_instruction_pointer) <= -1) | ||||
| 				if (do_throw(hcl, return_value, fetched_instruction_pointer) <= -1) goto oops; | ||||
| 				break; | ||||
| 			/* -------------------------------------------------------- */ | ||||
| 			case HCL_CODE_CLASS_ENTER: | ||||
| 			{ | ||||
| 				hcl_oop_t c; | ||||
|  | ||||
| 				/* the class_enter instruct must follow the class_make instruction... */ | ||||
| 				LOG_INST_0 (hcl, "class_enter"); | ||||
| 				c = HCL_STACK_GETTOP(hcl); /* the class object */ | ||||
| 				//HCL_CLSTACK_PUSH (hcl, c); | ||||
| 				break; | ||||
| 			} | ||||
| 			 | ||||
| 			case HCL_CODE_CLASS_EXIT: | ||||
| 				LOG_INST_0 (hcl, "class_exit"); | ||||
| 				/* TODO: stack underflow check? */ | ||||
| 				//HCL_CLSTACK_POP (hcl); | ||||
| 				break; | ||||
| 			/* -------------------------------------------------------- */ | ||||
|  | ||||
| 			case HCL_CODE_PUSH_CTXTEMPVAR_X: | ||||
| 			case HCL_CODE_STORE_INTO_CTXTEMPVAR_X: | ||||
|  | ||||
| @ -387,7 +387,8 @@ typedef struct hcl_cframe_t hcl_cframe_t; | ||||
| enum hcl_cblk_type_t | ||||
| { | ||||
| 	HCL_CBLK_TYPE_LOOP, | ||||
| 	HCL_CBLK_TYPE_TRY | ||||
| 	HCL_CBLK_TYPE_TRY, | ||||
| 	HCL_CBLK_TYPE_CLASS | ||||
| }; | ||||
| typedef enum hcl_cblk_type_t hcl_cblk_type_t; | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user