From d711ed6acc965b1ff9e151b52fb818860c7e65b2 Mon Sep 17 00:00:00 2001 From: Ge Wang Date: Sun, 1 Oct 2023 20:46:07 -0700 Subject: [PATCH] modify Machine operator stack access --- VERSIONS | 11 +++-------- src/core/ulib_machine.cpp | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/VERSIONS b/VERSIONS index 8c4c52fbf..0906319b6 100644 --- a/VERSIONS +++ b/VERSIONS @@ -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. diff --git a/src/core/ulib_machine.cpp b/src/core/ulib_machine.cpp index 7c8e763dd..dac6c1845 100644 --- a/src/core/ulib_machine.cpp +++ b/src/core/ulib_machine.cpp @@ -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" ); @@ -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)