mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-23 13:00:17 +00:00
rename
This commit is contained in:
parent
cd6484a61a
commit
01be71f0ef
@ -49,13 +49,12 @@ def reversed(iterable):
|
||||
return [a[i] for i in range(len(a)-1, -1, -1)]
|
||||
|
||||
def sorted(iterable, key=None, reverse=False):
|
||||
if key is None:
|
||||
key = lambda x: x
|
||||
a = [key(i) for i in iterable]
|
||||
b = list(iterable)
|
||||
a = (key is None) ? b : [key(i) for i in iterable]
|
||||
for i in range(len(a)):
|
||||
for j in range(i+1, len(a)):
|
||||
if (a[i] > a[j]) ^ reverse:
|
||||
if a is not b:
|
||||
a[i], a[j] = a[j], a[i]
|
||||
b[i], b[j] = b[j], b[i]
|
||||
return b
|
||||
|
@ -85,7 +85,7 @@ struct CodeObject {
|
||||
return consts.size() - 1;
|
||||
}
|
||||
|
||||
void optimize_level_1(){
|
||||
void optimize(){
|
||||
for(int i=0; i<codes.size(); i++){
|
||||
if(codes[i].op >= OP_BINARY_OP && codes[i].op <= OP_CONTAINS_OP){
|
||||
for(int j=0; j<2; j++){
|
||||
@ -116,10 +116,6 @@ struct CodeObject {
|
||||
}
|
||||
}
|
||||
|
||||
void optimize(int level=1){
|
||||
optimize_level_1();
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
int _curr_block_i = 0;
|
||||
bool _is_curr_block_loop() const {
|
||||
@ -150,6 +146,7 @@ struct Frame {
|
||||
PyVar _module;
|
||||
pkpy::shared_ptr<PyVarDict> _locals;
|
||||
const i64 id;
|
||||
std::stack<std::pair<int, std::vector<PyVar>>> s_try_block;
|
||||
|
||||
inline PyVarDict& f_locals() noexcept { return *_locals; }
|
||||
inline PyVarDict& f_globals() noexcept { return _module->attribs; }
|
||||
@ -190,7 +187,7 @@ struct Frame {
|
||||
return v;
|
||||
}
|
||||
|
||||
inline void __pop(){
|
||||
inline void _pop(){
|
||||
if(_data.empty()) throw std::runtime_error("_data.empty() is true");
|
||||
_data.pop_back();
|
||||
}
|
||||
@ -226,8 +223,6 @@ struct Frame {
|
||||
inline void jump_abs(int i){ _next_ip = i; }
|
||||
inline void jump_rel(int i){ _next_ip += i; }
|
||||
|
||||
std::stack<std::pair<int, std::vector<PyVar>>> s_try_block;
|
||||
|
||||
inline void on_try_block_enter(){
|
||||
s_try_block.push(std::make_pair(co->codes[_ip].block, _data));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user