Skip to content

Commit

Permalink
add line number to mod instructions for exception reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Oct 29, 2024
1 parent 8f6c232 commit 36f8f73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/core/chuck_emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2633,17 +2633,20 @@ t_CKBOOL emit_engine_emit_op( Chuck_Emitter * emit, ae_Operator op, a_Exp lhs, a
if( ( left == te_time && right == te_dur ) ) // time % dur = dur
{
emit->append( instr = new Chuck_Instr_Mod_double );
instr->set_linepos( rhs->line );
}
else // other types
{
switch( left )
{
case te_int:
emit->append( instr = new Chuck_Instr_Mod_int );
instr->set_linepos( rhs->line );
break;
case te_float:
case te_dur:
emit->append( instr = new Chuck_Instr_Mod_double );
instr->set_linepos( rhs->line );
break;

default: break;
Expand All @@ -2656,17 +2659,20 @@ t_CKBOOL emit_engine_emit_op( Chuck_Emitter * emit, ae_Operator op, a_Exp lhs, a
if( ( left == te_dur && right == te_time ) ) // time % dur = dur
{
emit->append( instr = new Chuck_Instr_Mod_double_Assign );
instr->set_linepos( lhs->line );
}
else // other types
{
switch( left )
{
case te_int:
emit->append( instr = new Chuck_Instr_Mod_int_Assign );
instr->set_linepos( lhs->line );
break;
case te_float:
case te_dur:
emit->append( instr = new Chuck_Instr_Mod_double_Assign );
instr->set_linepos( lhs->line );
break;

default: break;
Expand Down
10 changes: 5 additions & 5 deletions src/core/chuck_instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void Chuck_Instr_Mod_int::execute( Chuck_VM * vm, Chuck_VM_Shred * shred )
return;

mod_zero:
// we have a problem
// we have a problem | 1.5.4.0 (nshaheed) throw exception
EM_exception(
"ModuloByZero: on line[%lu] in shred[id=%lu:%s]",
m_linepos, shred->xid, shred->name.c_str());
Expand Down Expand Up @@ -335,7 +335,7 @@ void Chuck_Instr_Mod_int_Reverse::execute( Chuck_VM * vm, Chuck_VM_Shred * shred
return;

mod_zero:
// we have a problem
// we have a problem | 1.5.4.0 (nshaheed) throw exception
EM_exception(
"ModuloByZero: on line[%lu] in shred[id=%lu:%s]",
m_linepos, shred->xid, shred->name.c_str());
Expand Down Expand Up @@ -549,7 +549,7 @@ void Chuck_Instr_Mod_double::execute( Chuck_VM * vm, Chuck_VM_Shred * shred )
return;

mod_zero:
// we have a problem
// we have a problem | 1.5.4.0 (nshaheed) throw exception
EM_exception(
"ModuloByZero: on line[%lu] in shred[id=%lu:%s]",
m_linepos, shred->xid, shred->name.c_str());
Expand Down Expand Up @@ -1312,7 +1312,7 @@ void Chuck_Instr_Mod_int_Assign::execute( Chuck_VM * vm, Chuck_VM_Shred * shred
return;

mod_zero:
// we have a problem
// we have a problem | 1.5.4.0 (nshaheed) throw exception
EM_exception(
"ModuloByZero: on line[%lu] in shred[id=%lu:%s]",
m_linepos, shred->xid, shred->name.c_str());
Expand Down Expand Up @@ -1482,7 +1482,7 @@ void Chuck_Instr_Mod_double_Assign::execute( Chuck_VM * vm, Chuck_VM_Shred * shr
return;

mod_zero:
// we have a problem
// we have a problem | 1.5.4.0 (nshaheed) throw exception
EM_exception(
"ModuloByZero: on line[%lu] in shred[id=%lu:%s]",
m_linepos, shred->xid, shred->name.c_str());
Expand Down

0 comments on commit 36f8f73

Please sign in to comment.