Skip to content

Commit

Permalink
allows .m file empty to be called.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson-numerical-software committed Aug 2, 2021
1 parent ee7966c commit c7e5eb7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

- some warnings detected by LGTM or VS fixed.

## Bug Fixes:
- allows .m file empty to be called.

- [#480](http://github.com/Nelson-numerical-software/nelson/issues/468): A(':') = [] was not managed.
## Bug Fixes:

- [#480](http://github.com/Nelson-numerical-software/nelson/issues/480): publisher name updated for windows installer.

# 0.5.7 (2021-07-24)

Expand Down
5 changes: 4 additions & 1 deletion modules/interpreter/src/cpp/Evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class endData
ArrayOf endArray;
int index = 0;
size_t count = 0;
endData(ArrayOf p, int ndx, size_t cnt) : endArray(p), index(ndx), count(cnt) {}
endData(ArrayOf p, int ndx, size_t cnt) : endArray(p), index(ndx), count(cnt) { }
~endData() = default;
;
};
Expand Down Expand Up @@ -1987,6 +1987,9 @@ Evaluator::statement(AbstractSyntaxTreePtr t)
void
Evaluator::block(AbstractSyntaxTreePtr t)
{
if (t == nullptr) {
return;
}
try {
AbstractSyntaxTreePtr s = t->down;
if (state < NLS_STATE_QUIT) {
Expand Down
29 changes: 20 additions & 9 deletions modules/interpreter/src/cpp/MacroFunctionDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,13 @@ MacroFunctionDef::updateCode()
return false;
}
this->setTimestamp(currentFileTimestamp);

if (code) {
for (auto ptr : this->ptrAstCodeAsVector) {
delete ptr;
}
ptrAstCodeAsVector.clear();
code = nullptr;
}
FILE* fr;
#ifdef _MSC_VER
fr = _wfopen(this->getFilename().c_str(), L"rt");
Expand Down Expand Up @@ -420,15 +426,20 @@ MacroFunctionDef::updateCode()
try {
if (pstate == ParserState::FuncDef) {
MacroFunctionDef* macroFunctionDef = getParsedFunctionDef();
this->code = macroFunctionDef->code;
this->arguments = macroFunctionDef->arguments;
this->localFunction = macroFunctionDef->localFunction;
this->nextFunction = macroFunctionDef->nextFunction;
this->prevFunction = macroFunctionDef->prevFunction;
this->returnVals = macroFunctionDef->returnVals;
this->ptrAstCodeAsVector = macroFunctionDef->ptrAstCodeAsVector;
this->setIsScript(false);
this->setName(macroFunctionDef->getName());
if (macroFunctionDef == nullptr) {
boost::filesystem::path pathFunction(this->getFilename());
this->setName(pathFunction.stem().generic_string());
} else {
this->code = macroFunctionDef->code;
this->arguments = macroFunctionDef->arguments;
this->localFunction = macroFunctionDef->localFunction;
this->nextFunction = macroFunctionDef->nextFunction;
this->prevFunction = macroFunctionDef->prevFunction;
this->returnVals = macroFunctionDef->returnVals;
this->ptrAstCodeAsVector = macroFunctionDef->ptrAstCodeAsVector;
this->setName(macroFunctionDef->getName());
}
} else {
this->code = getParsedScriptBlock();
this->arguments.clear();
Expand Down

0 comments on commit c7e5eb7

Please sign in to comment.