Skip to content

Commit

Permalink
MVM_nativeref_lex_u for proper gelexref_u*
Browse files Browse the repository at this point in the history
  • Loading branch information
niner committed Jan 15, 2022
1 parent 4b2de6d commit 5961afa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/6model/reprs/NativeRef.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,23 @@ MVMObject * MVM_nativeref_lex_i(MVMThreadContext *tc, MVMuint16 outers, MVMuint1
}
MVM_exception_throw_adhoc(tc, "No int lexical reference type registered for current HLL");
}
MVMObject * MVM_nativeref_lex_u(MVMThreadContext *tc, MVMuint16 outers, MVMuint16 idx) {
MVMObject *ref_type;
MVM_frame_force_to_heap(tc, tc->cur_frame);
ref_type = MVM_hll_current(tc)->uint_lex_ref;
if (ref_type) {
MVMFrame *f = get_lexical_outer(tc, outers);
MVMuint16 *lexical_types = f->spesh_cand && f->spesh_cand->body.lexical_types
? f->spesh_cand->body.lexical_types
: f->static_info->body.lexical_types;
MVMuint16 type = lexical_types[idx];
if (type != MVM_reg_uint64 && type != MVM_reg_uint32 &&
type != MVM_reg_uint16 && type != MVM_reg_uint8)
MVM_exception_throw_adhoc(tc, "getlexref_u: lexical is not an uint");
return lex_ref(tc, ref_type, f, idx, type);
}
MVM_exception_throw_adhoc(tc, "No uint lexical reference type registered for current HLL");
}
MVMObject * MVM_nativeref_lex_n(MVMThreadContext *tc, MVMuint16 outers, MVMuint16 idx) {
MVMObject *ref_type;
MVM_frame_force_to_heap(tc, tc->cur_frame);
Expand Down
1 change: 1 addition & 0 deletions src/6model/reprs/NativeRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const MVMREPROps * MVMNativeRef_initialize(MVMThreadContext *tc);
/* Operations on a nativeref REPR. */
void MVM_nativeref_ensure(MVMThreadContext *tc, MVMObject *val, MVMuint16 wantprim, MVMuint16 wantkind, char *guilty);
MVMObject * MVM_nativeref_lex_i(MVMThreadContext *tc, MVMuint16 outers, MVMuint16 idx);
MVMObject * MVM_nativeref_lex_u(MVMThreadContext *tc, MVMuint16 outers, MVMuint16 idx);
MVMObject * MVM_nativeref_lex_n(MVMThreadContext *tc, MVMuint16 outers, MVMuint16 idx);
MVMObject * MVM_nativeref_lex_s(MVMThreadContext *tc, MVMuint16 outers, MVMuint16 idx);
MVMObject * MVM_nativeref_lex_name_i(MVMThreadContext *tc, MVMString *name);
Expand Down
3 changes: 1 addition & 2 deletions src/core/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4627,8 +4627,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
OP(getlexref_u32):
OP(getlexref_u16):
OP(getlexref_u8):
/* XXX Cheat should have a _u here. */
GET_REG(cur_op, 0).o = MVM_nativeref_lex_i(tc,
GET_REG(cur_op, 0).o = MVM_nativeref_lex_u(tc,
GET_UI16(cur_op, 4), GET_UI16(cur_op, 2));
cur_op += 6;
goto NEXT;
Expand Down
2 changes: 1 addition & 1 deletion src/jit/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static void * op_to_func(MVMThreadContext *tc, MVMint16 opcode) {
case MVM_OP_getsignals: return MVM_io_get_signals;
case MVM_OP_sleep: return MVM_platform_sleep;
case MVM_OP_getlexref_i32: case MVM_OP_getlexref_i16: case MVM_OP_getlexref_i8: case MVM_OP_getlexref_i: return MVM_nativeref_lex_i;
case MVM_OP_getlexref_u32: case MVM_OP_getlexref_u16: case MVM_OP_getlexref_u8: case MVM_OP_getlexref_u: return MVM_nativeref_lex_i;
case MVM_OP_getlexref_u32: case MVM_OP_getlexref_u16: case MVM_OP_getlexref_u8: case MVM_OP_getlexref_u: return MVM_nativeref_lex_u;
case MVM_OP_getlexref_n32: case MVM_OP_getlexref_n: return MVM_nativeref_lex_n;
case MVM_OP_getlexref_s: return MVM_nativeref_lex_s;
case MVM_OP_getattrref_i: return MVM_nativeref_attr_i;
Expand Down

0 comments on commit 5961afa

Please sign in to comment.