mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
pass by value
This commit is contained in:
parent
bfcec88871
commit
88e1a56150
@ -4,6 +4,11 @@ const char* __BUILTINS_CODE = R"(
|
||||
def len(x):
|
||||
return x.__len__()
|
||||
|
||||
def print(*args, sep=' ', end='\n'):
|
||||
s = sep.join([str(i) for i in args])
|
||||
__sys_stdout_write(s + end)
|
||||
|
||||
|
||||
str.__mul__ = lambda self, n: ''.join([self for _ in range(n)])
|
||||
|
||||
def __str4split(self, sep):
|
||||
|
@ -39,12 +39,9 @@ void __initializeBuiltinFunctions(VM* _vm) {
|
||||
#undef BIND_NUM_ARITH_OPT
|
||||
#undef BIND_NUM_LOGICAL_OPT
|
||||
|
||||
_vm->bindBuiltinFunc("print", [](VM* vm, const pkpy::ArgList& args) {
|
||||
_StrStream ss;
|
||||
for(int i=0; i<args.size(); i++){
|
||||
ss << vm->PyStr_AS_C(vm->asStr(args[i])) << " ";
|
||||
}
|
||||
(*vm->_stdout) << ss.str() << '\n';
|
||||
_vm->bindBuiltinFunc("__sys_stdout_write", [](VM* vm, const pkpy::ArgList& args) {
|
||||
vm->__checkArgSize(args, 1);
|
||||
(*vm->_stdout) << vm->PyStr_AS_C(args[0]);
|
||||
return vm->None;
|
||||
});
|
||||
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
PyVarDict() : emhash8::HashMap<_Str, PyVar>(5) {}
|
||||
PyVarDict() : emhash8::HashMap<_Str, PyVar>() {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
pkpy::shared_ptr<_StrMemory> _s;
|
||||
bool interned = false;
|
||||
public:
|
||||
_Str(const _StrLiteral& s){
|
||||
_Str(_StrLiteral s){
|
||||
construct(s);
|
||||
intern();
|
||||
}
|
||||
@ -95,7 +95,7 @@ public:
|
||||
this->_s = pkpy::make_shared<_StrMemory>(std::move(s));
|
||||
}
|
||||
|
||||
void construct(const std::string_view& sv){
|
||||
void construct(std::string_view sv){
|
||||
auto it = _strIntern.find(sv);
|
||||
if(it != _strIntern.end()){
|
||||
this->_s = it->second;
|
||||
|
Loading…
x
Reference in New Issue
Block a user