changed code for emit_indexed_variable_access()
This commit is contained in:
		| @ -633,20 +633,23 @@ static HCL_INLINE void patch_double_long_params (hcl_t* hcl, hcl_ooi_t ip, hcl_o | |||||||
|  |  | ||||||
| static int emit_indexed_variable_access (hcl_t* hcl, hcl_oow_t index, hcl_oob_t baseinst1, hcl_oob_t baseinst2, const hcl_ioloc_t* srcloc) | static int emit_indexed_variable_access (hcl_t* hcl, hcl_oow_t index, hcl_oob_t baseinst1, hcl_oob_t baseinst2, const hcl_ioloc_t* srcloc) | ||||||
| { | { | ||||||
| 	if (hcl->c->fnblk.depth >= 0) |  | ||||||
| 	{ |  | ||||||
| 	hcl_oow_t i; | 	hcl_oow_t i; | ||||||
|  |  | ||||||
|  | 	HCL_ASSERT (hcl, hcl->c->fnblk.depth >= 0); | ||||||
|  |  | ||||||
| 	/* if a temporary variable is accessed inside a block, | 	/* if a temporary variable is accessed inside a block, | ||||||
| 	 * use a special instruction to indicate it */ | 	 * use a special instruction to indicate it */ | ||||||
| 	HCL_ASSERT (hcl, index < hcl->c->fnblk.info[hcl->c->fnblk.depth].tmprcnt); | 	HCL_ASSERT (hcl, index < hcl->c->fnblk.info[hcl->c->fnblk.depth].tmprcnt); | ||||||
| 		for (i = hcl->c->fnblk.depth; i > 0; i--) /* excluded the top level -- TODO: change this code depending on global variable handling */ | 	for (i = hcl->c->fnblk.depth; i >= 0; i--) | ||||||
| 	{ | 	{ | ||||||
| 			if (index >= hcl->c->fnblk.info[i - 1].tmprcnt) | 		hcl_oow_t parent_tmprcnt; | ||||||
|  |  | ||||||
|  | 		parent_tmprcnt = (i > 0)? hcl->c->fnblk.info[i - 1].tmprcnt: 0; | ||||||
|  | 		if (index >= parent_tmprcnt) | ||||||
| 		{ | 		{ | ||||||
| 			hcl_oow_t ctx_offset, index_in_ctx; | 			hcl_oow_t ctx_offset, index_in_ctx; | ||||||
| 			ctx_offset = hcl->c->fnblk.depth - i; | 			ctx_offset = hcl->c->fnblk.depth - i; | ||||||
| 				index_in_ctx = index - hcl->c->fnblk.info[i - 1].tmprcnt; | 			index_in_ctx = index - parent_tmprcnt; | ||||||
| 			/* ctx_offset 0 means the current context. | 			/* ctx_offset 0 means the current context. | ||||||
| 			 *            1 means current->home. | 			 *            1 means current->home. | ||||||
| 			 *            2 means current->home->home.  | 			 *            2 means current->home->home.  | ||||||
| @ -656,8 +659,8 @@ static int emit_indexed_variable_access (hcl_t* hcl, hcl_oow_t index, hcl_oob_t | |||||||
| 			return 0; | 			return 0; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
|  |  | ||||||
|  | /* THIS PART MUST NOT BE REACHED */ | ||||||
| 	/* TODO: top-level... verify this. this will vary depending on how i implement the top-level and global variables... */ | 	/* TODO: top-level... verify this. this will vary depending on how i implement the top-level and global variables... */ | ||||||
| 	if (emit_single_param_instruction(hcl, baseinst2, index, srcloc) <= -1) return -1; | 	if (emit_single_param_instruction(hcl, baseinst2, index, srcloc) <= -1) return -1; | ||||||
| 	return 0; | 	return 0; | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ | |||||||
|  |  | ||||||
| #include <hcl-xma.h> | #include <hcl-xma.h> | ||||||
| #include "hcl-prv.h" | #include "hcl-prv.h" | ||||||
| #include <assert.h> /* TODO: replace assert() with builtin substition */ | #include <assert.h> /* TODO: replace assert() with HCL_ASSERT() or something */ | ||||||
|  |  | ||||||
|  |  | ||||||
| /*  | /*  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user