History

memory system upgrade (part 1); scope-sensitive cleanup for each return statement; clarified reference counting semantics; function argument release for builtin functions; improved post-function call object cleanup; auto-reference-increment on returned objects from all builtin/imported functions; absyn tree printing for instruction dumping abysn2str(); Machine.refcount() and refcount printing for object references

Ge Wang committed 3 years ago

Commit beef6541 parent 2eec4e717 files · +835 −72Browse files

Showing the changes to src/core/ulib_machine.cpp (1 of 17 files). Show all

Unified · Split

src/core/ulib_machine.cpp+34−2
@@ -40,6 +40,25 @@ · 39 unmodified lines
40#include <string>40#include <string>
41using namespace std;41using namespace std;
42 42
43// exports
44CK_DLL_SFUN( machine_crash_impl );
45CK_DLL_SFUN( machine_add_impl );
46CK_DLL_SFUN( machine_spork_impl );
47CK_DLL_SFUN( machine_remove_impl );
48CK_DLL_SFUN( machine_replace_impl );
49CK_DLL_SFUN( machine_status_impl );
50CK_DLL_SFUN( machine_intsize_impl );
51CK_DLL_SFUN( machine_shreds_impl );
52CK_DLL_SFUN( machine_realtime_impl );
53CK_DLL_SFUN( machine_silent_impl );
54CK_DLL_SFUN( machine_eval_impl );
55CK_DLL_SFUN( machine_eval2_impl );
56CK_DLL_SFUN( machine_eval3_impl );
57CK_DLL_SFUN( machine_version_impl );
58CK_DLL_SFUN( machine_setloglevel_impl );
59CK_DLL_SFUN( machine_getloglevel_impl );
60CK_DLL_SFUN( machine_refcount_impl);
61
43 62
44 63
45 64
@@ -154,7 +173,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 108 unmodified lines
154 QUERY->add_sfun( QUERY, machine_version_impl, "string", "version" );173 QUERY->add_sfun( QUERY, machine_version_impl, "string", "version" );
155 QUERY->doc_func( QUERY, "return version string" );174 QUERY->doc_func( QUERY, "return version string" );
156 175
157 // get version string176 // get set loglevel
158 QUERY->add_sfun( QUERY, machine_setloglevel_impl, "int", "loglevel" );177 QUERY->add_sfun( QUERY, machine_setloglevel_impl, "int", "loglevel" );
159 QUERY->add_arg( QUERY, "int", "level" );178 QUERY->add_arg( QUERY, "int", "level" );
160 QUERY->doc_func( QUERY, "set log level\n"179 QUERY->doc_func( QUERY, "set log level\n"
@@ -170,10 +189,15 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 9 unmodified lines
170 " |- 9: FINEST\n"189 " |- 9: FINEST\n"
171 " |- 10: ALL" );190 " |- 10: ALL" );
172 191
173 // get version string192 // get log level
174 QUERY->add_sfun( QUERY, machine_getloglevel_impl, "int", "loglevel" );193 QUERY->add_sfun( QUERY, machine_getloglevel_impl, "int", "loglevel" );
175 QUERY->doc_func( QUERY, "get log level." );194 QUERY->doc_func( QUERY, "get log level." );
176 195
196 // get reference count for any object
197 QUERY->add_sfun( QUERY, machine_refcount_impl, "int", "refcount" );
198 QUERY->add_arg( QUERY, "Object", "obj" );
199 QUERY->doc_func( QUERY, "get an object's current internal reference count; this is intended for testing or curiosity; NOTE: this function intentionally does not take into account any reference counting related to the calling of this function (normally all functions increments the reference count for objects passed as arguments and decrements upon returning)" );
200
177 // end class201 // end class
178 QUERY->end_class( QUERY );202 QUERY->end_class( QUERY );
179 203
@@ -399,3 +423,11 @@ CK_DLL_SFUN( machine_getloglevel_impl ) · 219 unmodified lines
399 // return423 // return
400 RETURN->v_int = VM->carrier()->chuck->getLogLevel();424 RETURN->v_int = VM->carrier()->chuck->getLogLevel();
401}425}
426
427CK_DLL_SFUN( machine_refcount_impl )
428{
429 // get the argument
430 Chuck_Object * obj = (Chuck_Object *)GET_NEXT_OBJECT(ARGS);
431 // return (-1 to account for the extra refcount as part of calling this function!)
432 RETURN->v_int = obj != NULL ? obj->m_ref_count-1 : 0;
433}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t