enhanced class_enter to check indexed type between a class and a superclass
This commit is contained in:
		
							
								
								
									
										14
									
								
								lib/exec.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								lib/exec.c
									
									
									
									
									
								
							@ -4122,6 +4122,9 @@ static int execute (hak_t* hak)
 | 
			
		||||
 | 
			
		||||
				if (b1 > 0)
 | 
			
		||||
				{
 | 
			
		||||
					hak_ooi_t super_spec;
 | 
			
		||||
					hak_obj_type_t super_indexed_type;
 | 
			
		||||
 | 
			
		||||
					HAK_STACK_POP_TO(hak, superclass); /* TODO: support more than 1 superclass later when the compiler supports more */
 | 
			
		||||
					if (!HAK_IS_CLASS(hak, superclass))
 | 
			
		||||
					{
 | 
			
		||||
@ -4129,6 +4132,17 @@ static int execute (hak_t* hak)
 | 
			
		||||
						if (do_throw_with_internal_errmsg(hak, fetched_instruction_pointer) >= 0) break;
 | 
			
		||||
						goto oops_with_errmsg_supplement;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					super_spec = HAK_OOP_TO_SMOOI(((hak_oop_class_t)superclass)->spec);
 | 
			
		||||
					super_indexed_type = HAK_CLASS_SPEC_INDEXED_TYPE(super_spec);
 | 
			
		||||
					if (super_indexed_type != b5)
 | 
			
		||||
					{
 | 
			
		||||
						/* TODO: include the class indexed type in the message .. */
 | 
			
		||||
						hak_seterrbfmt(hak, HAK_ECALL, "incompatible %hs superclass %O with %hs class",
 | 
			
		||||
							hak_obj_type_to_bcstr(super_indexed_type), superclass, hak_obj_type_to_bcstr(b5));
 | 
			
		||||
						if (do_throw_with_internal_errmsg(hak, fetched_instruction_pointer) >= 0) break;
 | 
			
		||||
						goto oops_with_errmsg_supplement;
 | 
			
		||||
					}
 | 
			
		||||
 				}
 | 
			
		||||
				else superclass = hak->_nil;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								lib/hak.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lib/hak.c
									
									
									
									
									
								
							@ -1017,3 +1017,15 @@ hak_pfbase_t* hak_findpfbase (hak_t* hak, hak_pfinfo_t* pfinfo, hak_oow_t pfcoun
 | 
			
		||||
	return HAK_NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const hak_bch_t* hak_obj_type_to_bcstr (hak_obj_type_t type)
 | 
			
		||||
{
 | 
			
		||||
	static const hak_bch_t* names[] = {
 | 
			
		||||
		"oop",
 | 
			
		||||
		"char",
 | 
			
		||||
		"byte",
 | 
			
		||||
		"halfword",
 | 
			
		||||
		"word",
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	return (type < HAK_COUNTOF(names))? names[type]: "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user