Commit 84d5420d authored by Victor Yacovlev's avatar Victor Yacovlev

Fixed #kumir2-1636

parent b80333f5
......@@ -180,6 +180,8 @@ private /*methods*/:
inline void checkFunctors();
inline bool isRunningMain() const;
private /*instruction methods*/:
inline void do_call(uint8_t, uint16_t);
inline void do_stdcall(uint16_t);
......@@ -2402,14 +2404,14 @@ void KumirVM::do_load(uint8_t s, uint16_t id)
}
bool isRetVal = VariableScope(s)==LOCAL
&& contextsStack_.top().locals[id].algorhitmName()==contextsStack_.top().locals[id].name();
if (isRetVal && contextsStack_.top().type==Bytecode::EL_MAIN)
&& variable.algorhitmName()==variable.name();
if (isRetVal && isRunningMain())
Variable::unsetError();
if (Kumir::Core::getError().length()==0) {
valuesStack_.push(val);
if (val.dimension()==0)
register0_ = val.value();
if (isRetVal && contextsStack_.top().type==Bytecode::EL_MAIN)
if (isRetVal && isRunningMain())
Variable::unsetError();
}
error_ = Kumir::Core::getError();
......@@ -2417,6 +2419,19 @@ void KumirVM::do_load(uint8_t s, uint16_t id)
if (stacksMutex_) stacksMutex_->unlock();
}
bool KumirVM::isRunningMain() const
{
bool mainAtTop = Bytecode::EL_MAIN == contextsStack_.top().type;
bool noUpStacks =
1 == contextsStack_.size()
||
(
contextsStack_.size()>1 &&
Bytecode::EL_BELOWMAIN == contextsStack_.at(contextsStack_.size()-2).type
);
return mainAtTop && noUpStacks;
}
void KumirVM::do_storearr(uint8_t s, uint16_t id)
{
if (stacksMutex_) stacksMutex_->lock();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment