Skip to content

Commit

Permalink
modify Machine operator stack access
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Oct 2, 2023
1 parent 730e024 commit d711ed6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
11 changes: 3 additions & 8 deletions VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,9 @@ ChucK VERSIONS log
of ChuGL (ChucK Graphics Library), which will be part of the ChucK
language
- (added) Machine function to on-the-fly control operator overloading stack
static void operatorsPop();
Pop the operator overloading stack; use with care.
static void operatorsPush();
Push the operator overloading stack; use with care.
static void operatorsReset();
Reset operator overloading state to default startup state; use with care.
static void operatorsStackLevel();
Get the current operator overloading stack level.
static void resetOperators();
Reset operator overloading state to default startup state;
removes all public @operator overloads; use with care.
- (added) new Machine function for getting number of shreds currently in VM
static int numShreds();
Get the number of shreds currently in the VM.
Expand Down
33 changes: 17 additions & 16 deletions src/core/ulib_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,22 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY )
QUERY->add_sfun( QUERY, machine_clearVM_impl, "void", "clearVM" );
QUERY->doc_func( QUERY, "Reset the type system, removing all user-defined types and all global variables; removes all shreds in the VM (including the shred calling this function); use with care.");

// add operatorsPush
QUERY->add_sfun( QUERY, machine_opOverloadPush_impl, "void", "operatorsPush" );
QUERY->doc_func( QUERY, "Push the operator overloading stack; use with care.");

// add operatorsPop
QUERY->add_sfun( QUERY, machine_opOverloadPop_impl, "void", "operatorsPop" );
QUERY->doc_func( QUERY, "Pop the operator overloading stack; use with care.");

// add operatorsReset
QUERY->add_sfun( QUERY, machine_opOverloadReset_impl, "void", "operatorsReset" );
QUERY->doc_func( QUERY, "Reset operator overloading state to default startup state; use with care.");

// add operatorsStackLevel
QUERY->add_sfun( QUERY, machine_opOverloadStackLevel_impl, "void", "operatorsStackLevel" );
QUERY->doc_func( QUERY, "Get the current operator overloading stack level.");
// add resetOperators
QUERY->add_sfun( QUERY, machine_opOverloadReset_impl, "void", "resetOperators" );
QUERY->doc_func( QUERY, "Reset operator overloading state to default startup state; removes all public @operator overloads; use with care.");

// comment out for now -- since local overloads don't persist, push/pop should probably affect public @operator overloads
// // add operatorsPush
// QUERY->add_sfun( QUERY, machine_opOverloadPush_impl, "void", "operatorsPush" );
// QUERY->doc_func( QUERY, "Push the operator overloading stack; use with care.");
//
// // add operatorsPop
// QUERY->add_sfun( QUERY, machine_opOverloadPop_impl, "void", "operatorsPop" );
// QUERY->doc_func( QUERY, "Pop the operator overloading stack; use with care.");
//
// // add operatorsStackLevel
// QUERY->add_sfun( QUERY, machine_opOverloadStackLevel_impl, "void", "operatorsStackLevel" );
// QUERY->doc_func( QUERY, "Get the current operator overloading stack level.");

// add status (legacy version of printStatus; has return value)
QUERY->add_sfun( QUERY, machine_printStatus_impl, "int", "status" );
Expand Down Expand Up @@ -609,7 +610,7 @@ CK_DLL_SFUN( machine_opOverloadPop_impl)

CK_DLL_SFUN( machine_opOverloadReset_impl)
{
VM->env()->op_registry.reset2local();
VM->env()->op_registry.reset2public();
}

CK_DLL_SFUN( machine_opOverloadStackLevel_impl)
Expand Down

0 comments on commit d711ed6

Please sign in to comment.