implemented the call process function but not found the execv corrispective for libnds

This commit is contained in:
christallo 2022-07-16 11:31:03 +02:00
parent 915d44ba2c
commit bddf384420
2 changed files with 14 additions and 5 deletions

View File

@ -3,12 +3,12 @@
{
"name": "Linux",
"includePath": [
"C:/devkitpro/devkitARM/arm-none-eabi/include",
"C:/devkitpro/libnds/include",
"/opt/devkitpro/devkitARM/arm-none-eabi/include",
"/opt/devkitpro/libnds/include",
"${workspaceFolder}/**"
],
"defines": ["ARM9"],
"compilerPath": "C:/devkitPro/devkitARM/bin/arm-none-eabi-g++.exe",
"compilerPath": "/opt/devkitpro/devkitARM/bin/arm-none-eabi-g++",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x64"

View File

@ -308,8 +308,17 @@ void NScript::Evaluator::builtinPrint(CallNode call)
NScript::Node NScript::Evaluator::evaluateCallProcess(CallNode call, Position pos)
{
panic("evaluateCallProcess not implemented yet");
return Node::none(pos);
auto processPath = cstringRealloc(getFullPath(expectNonEmptyStringAndGetString(call.name), true).c_str());
auto processArgv = new char*[call.args.size() + 2];
processArgv[0] = (char*)processPath;
for (uint64_t i = 1; i < call.args.size(); i++)
processArgv[i] = (char*)cstringRealloc(expectStringLengthAndGetString(evaluateNode(call.args[i]), [] (uint64_t l) { return true; }).c_str());
processArgv[call.args.size()] = (char*)nullptr;
return Node(NodeKind::Num, (NodeValue) { .num = float64(execv(processPath, processArgv)) }, pos);
}
NScript::Node NScript::Evaluator::evaluateCall(CallNode call, Position pos)