Commit 8bc37a0f authored by Victor Yacovlev's avatar Victor Yacovlev

LLVM: various stdlib fixes

parent 624a2001
......@@ -1930,6 +1930,15 @@ llvm::Value * LLVMGenerator::createFunctionCall(llvm::IRBuilder<> &builder, cons
currentModule_);
}
}
else {
const QString moduleName = alg->header.external.moduleName;
const CString message = CString(QString::fromUtf8(
"Невозможно использовать \"%1\": исполнители не поддерживаются"
).arg(moduleName).toUtf8().constData());
builder.CreateCall(kumirAbortOnError_,
builder.CreateGlobalStringPtr(message));
return 0;
}
size_t largsCount = alg->header.arguments.size();
size_t loffset = 0u;
......@@ -1986,17 +1995,10 @@ llvm::Value * LLVMGenerator::createFunctionCall(llvm::IRBuilder<> &builder, cons
args[0] = rval;
result = rval;
}
if (!func) {
const QString moduleName = alg->header.external.moduleName;
const CString message = CString(QString::fromUtf8(
"Невозможно использовать \"%1\": исполнители не поддерживаются"
).arg(moduleName).toUtf8().constData());
builder.CreateCall(kumirAbortOnError_,
builder.CreateGlobalStringPtr(message));
}
else {
builder.CreateCall(func, args);
}
Q_ASSERT(func);
builder.CreateCall(func, args);
return result;
}
......
......@@ -611,6 +611,37 @@ EXTERN void __kumir_stdlib_rnd(__kumir_scalar * result, const __kumir_scalar * v
);
}
EXTERN void __kumir_stdlib_irnd(__kumir_scalar * result, const __kumir_scalar * value)
{
__kumir_check_value_defined(value);
__kumir_create_int(result, Kumir::Random::irnd(value->data.i));
}
EXTERN void __kumir_stdlib_rand(__kumir_scalar * result, const __kumir_scalar * a, const __kumir_scalar * b)
{
__kumir_check_value_defined(a);
__kumir_check_value_defined(b);
__kumir_create_real(result,
Kumir::Random::rrand(
__kumir_scalar_as_real(a),
__kumir_scalar_as_real(b)
)
);
}
EXTERN void __kumir_stdlib_irand(__kumir_scalar * result, const __kumir_scalar * a, const __kumir_scalar * b)
{
__kumir_check_value_defined(a);
__kumir_check_value_defined(b);
__kumir_create_int(result,
Kumir::Random::irand(
a->data.i,
b->data.i
)
);
}
EXTERN void __kumir_stdlib_iabs(__kumir_scalar * result, const __kumir_scalar * value)
{
__kumir_check_value_defined(value);
......@@ -880,6 +911,19 @@ EXTERN void __kumir_stdlib_vstavit(const __kumir_scalar * fragment, __kumir_scal
__kumir_create_string(stroka, s);
}
EXTERN void __kumir_stdlib_udalit(__kumir_scalar * stroka, const __kumir_scalar * pozitsiya, const __kumir_scalar * dlina)
{
__kumir_check_value_defined(stroka);
__kumir_check_value_defined(pozitsiya);
__kumir_check_value_defined(dlina);
std::wstring s = __kumir_scalar_as_wstring(stroka);
int pos = pozitsiya->data.i;
int len = dlina->data.i;
Kumir::StringUtils::remove(s, pos, len);
__kumir_free_scalar(stroka);
__kumir_create_string(stroka, s);
}
EXTERN void __kumir_stdlib_lit_v_vesch(__kumir_scalar * result, const __kumir_scalar * value, __kumir_scalar * success)
......
......@@ -211,6 +211,9 @@ EXTERN void __kumir_stdlib_ln(__kumir_scalar * result, const __kumir_scalar * v
EXTERN void __kumir_stdlib_lg(__kumir_scalar * result, const __kumir_scalar * value);
EXTERN void __kumir_stdlib_exp(__kumir_scalar * result, const __kumir_scalar * value);
EXTERN void __kumir_stdlib_rnd(__kumir_scalar * result, const __kumir_scalar * value);
EXTERN void __kumir_stdlib_irnd(__kumir_scalar * result, const __kumir_scalar * value);
EXTERN void __kumir_stdlib_rand(__kumir_scalar * result, const __kumir_scalar * a, const __kumir_scalar * b);
EXTERN void __kumir_stdlib_irand(__kumir_scalar * result, const __kumir_scalar * a, const __kumir_scalar * b);
EXTERN void __kumir_stdlib_iabs(__kumir_scalar * result, const __kumir_scalar * value);
EXTERN void __kumir_stdlib_abs(__kumir_scalar * result, const __kumir_scalar * value);
EXTERN void __kumir_stdlib_sign(__kumir_scalar * result, const __kumir_scalar * value);
......@@ -246,6 +249,7 @@ EXTERN void __kumir_stdlib_pozitsiya(__kumir_scalar * result, const __kumir_scal
EXTERN void __kumir_stdlib_nizhnij_registr(__kumir_scalar * result, const __kumir_scalar * stroka);
EXTERN void __kumir_stdlib_verhnij_registr(__kumir_scalar * result, const __kumir_scalar * stroka);
EXTERN void __kumir_stdlib_vstavit(const __kumir_scalar * fragment, __kumir_scalar * stroka, const __kumir_scalar * pozitsiya);
EXTERN void __kumir_stdlib_udalit(__kumir_scalar * stroka, const __kumir_scalar * pozitsiya, const __kumir_scalar * dlina);
// Files
EXTERN void __kumir_stdlib_est_dannyie(__kumir_scalar * result, const __kumir_scalar * handle);
......
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