mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
34d620c82f
commit
f27548c6df
@ -234,12 +234,20 @@ bool py_checktype(py_Ref self, py_Type type) PY_RAISE;
|
||||
#define py_checkstr(self) py_checktype(self, tp_str)
|
||||
|
||||
/************* References *************/
|
||||
|
||||
/// Get the i-th register.
|
||||
/// All registers are located in a contiguous memory.
|
||||
py_GlobalRef py_getreg(int i);
|
||||
/// Set the i-th register.
|
||||
void py_setreg(int i, py_Ref val);
|
||||
|
||||
/// Get variable in the `__main__` module.
|
||||
py_GlobalRef py_getglobal(const char* name);
|
||||
/// Set variable in the `__main__` module.
|
||||
void py_setglobal(const char* name, py_Ref val);
|
||||
/// Get variable in the `builtins` module.
|
||||
py_GlobalRef py_getbuiltin(const char* name);
|
||||
|
||||
/// Equivalent to `*dst = *src`.
|
||||
void py_assign(py_Ref dst, py_Ref src);
|
||||
/// Get the last return value.
|
||||
|
@ -13,6 +13,18 @@ py_Ref py_getmodule(const char* path) {
|
||||
return NameDict__try_get(&vm->modules, py_name(path));
|
||||
}
|
||||
|
||||
py_Ref py_getbuiltin(const char* name){
|
||||
return py_getdict(&pk_current_vm->builtins, py_name(name));
|
||||
}
|
||||
|
||||
py_Ref py_getglobal(const char* name){
|
||||
return py_getdict(&pk_current_vm->main, py_name(name));
|
||||
}
|
||||
|
||||
void py_setglobal(const char* name, py_Ref val){
|
||||
py_setdict(&pk_current_vm->main, py_name(name), val);
|
||||
}
|
||||
|
||||
py_Ref py_newmodule(const char* path) {
|
||||
ManagedHeap* heap = &pk_current_vm->heap;
|
||||
PyObject* obj = ManagedHeap__new(heap, tp_module, -1, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user