Commit ef012845 authored by Victor Yacovlev's avatar Victor Yacovlev

Fixed runtime to match existing tests

parent 20c4d4bd
......@@ -943,6 +943,7 @@ void popLexemsUntilSemicolonOrBlockClose(QList<Lexem*> & lexems, Statement &resu
if (lx->type==LxOperSemicolon
|| lx->type==LxPriElse
|| lx->type==LxPriEndLoop
|| lx->type==LxPriCase
|| lx->type==LxPriFi)
break;
lexems.pop_front();
......
......@@ -613,7 +613,7 @@ void SyntaxAnalizerPrivate::parseImport(int str)
st.data[1]->error = _("kumir2-bc crashed while compiling this module");
return;
}
binFile = QFileInfo (QDir::current().absoluteFilePath(binName));
binFile = QFileInfo (QDir(sourceDirName).absoluteFilePath(binName));
if (!binFile.exists()) {
st.data[1]->error = _("Error compiling this module");
return;
......@@ -747,6 +747,13 @@ void SyntaxAnalizerPrivate::parseOutput(int str)
maxSubgroups = 2;
else
maxSubgroups = 1;
if (expr->baseType.kind==AST::TypeNone && expr->kind==AST::ExprFunctionCall) {
delete expr;
err = _("This algorithm has no return value");
foreach (Lexem * lx, groups[i])
lx->error = err;
return;
}
Q_ASSERT(colons.size() == subgroups.size()-1);
if (subgroups.size()>maxSubgroups) {
delete expr;
......
......@@ -305,7 +305,11 @@ public:
// m_value = other.m_value;
// }
inline bool isValid() const { return e_baseType!=VT_void; }
inline bool isValid() const {
return m_reference
? m_reference->isValid()
: m_value.type()!=VT_void;
}
inline bool isConstant() const { return m_reference? m_reference->isConstant() : b_constant; }
inline void setConstantFlag(bool value) { b_constant = value; }
......
......@@ -845,6 +845,9 @@ void KumirVM::do_call(uint8_t mod, uint16_t alg)
c.algId = moduleContexts[reference.moduleContext].functions[key].algId;
c.moduleContextNo = reference.moduleContext;
stack_contexts.push(c);
currentLocals = &(stack_contexts.top().locals);
currentGlobals = &(moduleContexts[c.moduleContextNo].globals[c.moduleId]);
currentConstants = &(moduleContexts[reference.moduleContext].constants);
b_nextCallInto = false;
stack_values.pop(); // current implementation doesn't requere args count
if (m_dontTouchMe)
......@@ -1912,34 +1915,8 @@ void KumirVM::do_specialcall(uint16_t alg)
int localId = argsCount; // Already removed from stack
Variable ref = stack_contexts.top().locals[localId].toReference();
if (m_dontTouchMe) m_dontTouchMe->unlock();
if (m_externalHandler && m_externalHandler->makeOutputArgument(ref)) {
// pass
}
else {
if (m_dontTouchMe) m_dontTouchMe->lock();
// Kumir::IO::writeString(String(), Kumir::Core::fromUtf8("Значение ")+ref.name()+Kumir::Core::fromAscii(": "));
// if (ref.baseType()==VT_int) {
// int val = Kumir::IO::readInteger(String());
// ref.setValue(AnyValue(val));
// }
// else if (ref.baseType()==VT_int) {
// real val = Kumir::IO::readReal(String());
// ref.setValue(AnyValue(val));
// }
// else if (ref.baseType()==VT_bool) {
// bool val = Kumir::IO::readBool(String());
// ref.setValue(AnyValue(val));
// }
// else if (ref.baseType()==VT_char) {
// Char val = Kumir::IO::readChar(String());
// ref.setValue(AnyValue(val));
// }
// else if (ref.baseType()==VT_int) {
// const String & val = Kumir::IO::readString(String());
// ref.setValue(AnyValue(val));
// }
if (m_dontTouchMe) m_dontTouchMe->unlock();
}
if (m_externalHandler && ref.isValid())
m_externalHandler->makeOutputArgument(ref);
}
}
......
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