Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
670719a
use an unordered_map to find quickly the index of the FUN or PRO base…
Jul 5, 2026
6ec3204
oops wrong string used in comparison
Jul 6, 2026
742ab02
oops wrong string used in comparison, twice
Jul 7, 2026
d07d75c
avoid using IsFun() to check if this is a fun if STRICTARR is set (wi…
Jul 7, 2026
12ba87d
explicite the error
Jul 7, 2026
be2e742
avoid a name search ... time gain.
Jul 7, 2026
670ec83
added important comment
Jul 7, 2026
7c95ef6
added important comment & correct error message
Jul 7, 2026
df8c865
changed type of return for SearchCompilePro to avoid rechecking the P…
Jul 7, 2026
75c9432
just removed unused code (invalid deque references) and factorized so…
Jul 8, 2026
f3fb847
insured some 'int... KeywordIx() ' could be 'static int' and never r…
Jul 17, 2026
6d2c68d
Merge master into tentative_remove_search_for_routines
Jul 20, 2026
1464439
Merge commit '0d7c33c9f3cb8e041a1a290c5af87180d12c0303' into tentativ…
Jul 20, 2026
9653ec5
binsearch implementation for keys
Jul 21, 2026
2cb97e3
align to master
Jul 26, 2026
c196450
speed: looking if each variable may be a loopVar just to tell if teh …
Jul 28, 2026
f81b19e
use pro->FindKey() everywhere possible as this uses an (indirect) bin…
Jul 28, 2026
b73fd24
NOZERO is silently ignored here
Jul 28, 2026
0625ba6
added BSearch for var also
Jul 29, 2026
3e7706d
Revert "added BSearch for var also"
Jul 29, 2026
1aaf87a
Revert "Revert "added BSearch for var also""
Jul 29, 2026
9a1a8c7
Revert "Revert "Revert "added BSearch for var also"""
Jul 30, 2026
7053e7b
removed indirect BSearch as deep test show overhead for building sort…
Jul 30, 2026
e65a86f
Jul 30, 2026
c20cea7
Jul 30, 2026
cdefb5d
Merge branch 'master' into tentative_remove_search_for_routines
GillesDuvert Jul 30, 2026
f7121d4
testing if last change on build_gdl.sh for windows was not THE problem
Jul 30, 2026
9c7d6a8
Merge origin/tentative_remove_search_for_routines into tentative_remo…
Jul 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions scripts/build_gdl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,9 @@ function build_msys2_package {
}

function find_architecture {

if [ ${Platform:-`uname -m`} == "x86_64" ]; then
declare -x MSYSTEM="UCRT64"
declare -x MSYSTEM_CARCH="x86_64"
declare -x MSYSTEM_CHOST="x86_64-w64-mingw32"
declare -x MSYSTEM_PREFIX="/ucrt64"
export mname="mingw64"
# export MSYSTEM="MINGW64"
export MSYSTEM="MINGW64"
export arch="x86_64"
else
export mname="mingw32"
Expand Down
2 changes: 1 addition & 1 deletion src/GDLInterpreter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CUSTOM_API GDLInterpreter : public antlr::TreeParser, public GDLInterprete

// code in: dinterpreter.cpp
// procedure (searchForPro == true) or function (searchForPro == false)
static bool SearchCompilePro(const std::string& pro, bool searchForPro);
static int SearchCompilePro(const std::string& pro, bool searchForPro); //-1 not found, 0 both, 1 pro 2 fun
static int SearchRoutineNoCompile(const std::string& pro);
static int GetFunIx( ProgNodeP, bool dothrow=true);
static int GetFunIx( const std::string& subName);
Expand Down
2 changes: 1 addition & 1 deletion src/GDLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9908,7 +9908,7 @@ void GDLParser::primary_expr() {
}
if ( synPredMatched296 ) {
{
if (((LA(1) == IDENTIFIER) && (LA(2) == LBRACE))&&( IsFun(LT(1)))) {
if (((LA(1) == IDENTIFIER) && (LA(2) == LBRACE))&&( ((fussy==0) && IsFun(LT(1))) )) {
formal_function_call();
if (inputState->guessing==0) {
astFactory->addASTChild(currentAST, antlr::RefAST(returnAST));
Expand Down
2 changes: 1 addition & 1 deletion src/GDLTreeParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CUSTOM_API GDLTreeParser : public antlr::TreeParser, public GDLTreeParserT
// Replaces ASSIGN with ASSIGN_REPLACE if appropiate
void AssignReplace( RefDNode& lN, RefDNode& aN)
{
if( LoopVar( lN))
if( warnLoopIndexModified && LoopVar( lN))
{
Warning( "Warning: Assignment to loop variable detected.");
}
Expand Down
146 changes: 35 additions & 111 deletions src/basic_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,6 @@ namespace lib {

DPtrGDL* ret;

// Why this code exists ? AC240526 #1837
static int nozeroIx = e->KeywordIx("NOZERO");
if (e->KeywordSet(nozeroIx)) Message("Obsolete Keyword NOZERO");
// return new DPtrGDL(dim);

static int ALLOCATE_HEAP = e->KeywordIx("ALLOCATE_HEAP");
if (e->KeywordSet(ALLOCATE_HEAP)) {
ret = new DPtrGDL(dim, BaseGDL::NOZERO);
Expand All @@ -447,8 +442,6 @@ namespace lib {
arr(e, dim);
if (dim[0] == 0)
throw GDLException("Array dimensions must be greater than 0");

// reference counting if( e->KeywordSet(0)) return new DObjGDL(dim, BaseGDL::NOZERO);
return new DObjGDL(dim);
}

Expand Down Expand Up @@ -1680,16 +1673,16 @@ namespace lib {
if (np > 1) e->Throw("The Offset and Dimension arguments are not allowed when converting to string type.");

// SA: calling GDL_STRING() with correct parameters
int stringIx = LibFunIx("STRING");
static int stringIx = LibFunIx("STRING");
//assert(stringIx >= 0);

EnvT* newEnv = new EnvT(e, libFunList[stringIx], NULL);

Guard<EnvT> guard(newEnv);

BaseGDL* par0 = e->GetPar(0)->Dup();
newEnv->SetNextPar(&par0);
BaseGDL* par0 = e->GetPar(0)->Dup();
newEnv->SetNextPar(&par0);

// newEnv->SetNextPar(e->GetPar(0)); // pass as global

if (e->KeywordSet(PRINTIX) && e->GetPar(0)->Type() == GDL_BYTE) {
Expand Down Expand Up @@ -1817,7 +1810,7 @@ unsigned int JSHash(const std::string& str)
} else {
// no direct call here

funIx = GDLInterpreter::GetFunIx(callF);
funIx = GDLInterpreter::GetFunIx(callF); //throws if absent

StackGuard<EnvStackT> guard(e->Interpreter()->CallStack());

Expand Down Expand Up @@ -7946,58 +7939,22 @@ unsigned int JSHash(const std::string& str)

DString name;
string FullFileName;
for (int i = 0; i < nPath; i++) {
for (int iPath = 0; iPath < nPath; ++iPath) {

name = StrUpCase((*p0S)[i]);
name = StrUpCase((*p0S)[iPath]);

bool found = false;
FullFileName = "";

size_t pos(0);
if ((pos = name.find("::")) != DString::npos) {
DString struct_tag = name.substr(0, pos);
DString method_name = name.substr(pos + 2);
for (auto& s : structList) {
if (s && (s->Name() != struct_tag)) continue;
if (eitherKW || !is_functionKW) {
DPro* pp = s->FindInProList(method_name);
if (pp) {
found = true;
FullFileName = pp->GetFilename();
break;
}
}
if (!found && (is_functionKW || eitherKW)) {
DFun* fp = s->FindInFunList(method_name);
if (fp) {
found = true;
FullFileName = fp->GetFilename();
break;
}
}
}
} else {
if (eitherKW || !is_functionKW) {
for (ProListT::iterator i = proList.begin();
i != proList.end(); ++i)
if ((*i)->ObjectName() == name) {
found = true;
FullFileName = (*i)->GetFilename();
break;
}
}
if (!found && (is_functionKW || eitherKW)) {
for (FunListT::iterator i = funList.begin();
i != funList.end(); ++i)
if ((*i)->ObjectName() == name) {
found = true;
FullFileName = (*i)->GetFilename();
break;
}
}
int i;
if (eitherKW || !is_functionKW) {
DPro *p;
if (p=GetDPro(name)) {FullFileName = p->GetFilename(); found=true;}
}

(*res)[i] = FullFileName;
if (!found && (is_functionKW || eitherKW)) {
DFun *f;
if (f=GetDFun(name)) FullFileName = f->GetFilename();
}
(*res)[iPath] = FullFileName;
}
// if(nParam == 0) return new DStringGDL(FullFileName);
return res_guard.release();
Expand Down Expand Up @@ -8069,28 +8026,18 @@ unsigned int JSHash(const std::string& str)
// getting the routine name from the first parameter (must be a singleton)
e->AssureScalarPar<DStringGDL>(0, raw_name);
name = StrUpCase(raw_name);
int i;
if (functionsKW) {
for (FunListT::iterator i = funList.begin(); i != funList.end(); ++i) {
if ((*i)->ObjectName() == name) {
found = true;
FullFileName = (*i)->GetFilename();
break;
}
}
if (!found) e->Throw("% Attempt to call undefined/not compiled function: '" + raw_name + "'");
DFun *f;
if (f=GetDFun(name)) FullFileName = f->GetFilename(); else e->Throw("% Attempt to call undefined/not compiled function: '" + raw_name + "'");
} else {
for (ProListT::iterator i = proList.begin(); i != proList.end(); ++i) {
if ((*i)->ObjectName() == name) {
if (name == "$MAIN$") {
found = true;
FullFileName = (*i)->GetFilename();
break;
FullFileName = "";
} else {
DPro *p;
if (p=GetDPro(name)) FullFileName = p->GetFilename(); else e->Throw("% Attempt to call undefined/not compiled procedure: '" + raw_name + "'");
}
}
if (name == "$MAIN$") {
found = true;
FullFileName = "";
}
if (!found) e->Throw("% Attempt to call undefined/not compiled procedure: '" + raw_name + "'");
}

// creating the output anonymous structure
Expand Down Expand Up @@ -8119,14 +8066,14 @@ unsigned int JSHash(const std::string& str)

if (functionsKW) {
SizeT ii = 1;
for (FunListT::iterator i = funList.begin(); i != funList.end(); ++i) {
for (FunListT::iterator i = funList.begin(); i != funList.end(); ++i) { //funList complete explore: ok
(*static_cast<DStringGDL*> (stru->GetTag((SizeT) 0, ii)))[0] = (*i)->ObjectName();
(*static_cast<DStringGDL*> (stru->GetTag((SizeT) 1, ii)))[0] = (*i)->GetFilename();
ii++;
}
} else {
SizeT ii = 1;
for (ProListT::iterator i = proList.begin(); i != proList.end(); ++i) {
for (ProListT::iterator i = proList.begin(); i != proList.end(); ++i) { //proList complete explore: ok
(*static_cast<DStringGDL*> (stru->GetTag((SizeT) 0, ii)))[0] = (*i)->ObjectName();
(*static_cast<DStringGDL*> (stru->GetTag((SizeT) 1, ii)))[0] = (*i)->GetFilename();
ii++;
Expand All @@ -8146,8 +8093,8 @@ unsigned int JSHash(const std::string& str)
name = StrUpCase(name);

DSubUD* routine = functionsKW
? static_cast<DSubUD*> (funList[GDLInterpreter::GetFunIx(name)])
: static_cast<DSubUD*> (proList[GDLInterpreter::GetProIx(name)]);
? static_cast<DSubUD*> (funList[GDLInterpreter::GetFunIx(name)]) //throws if not found
: static_cast<DSubUD*> (proList[GDLInterpreter::GetProIx(name)]);//throws if absent
SizeT np = routine->NPar(), nk = routine->NKey();

// creating the output anonymous structure
Expand Down Expand Up @@ -8194,40 +8141,22 @@ unsigned int JSHash(const std::string& str)
if (systemKW) {
SizeT n = libFunList.size();
if (n == 0) return new DStringGDL("");

DStringGDL* res = new DStringGDL(dimension(n), BaseGDL::NOZERO);
for (SizeT i = 0; i < n; ++i)
(*res)[i] = libFunList[ i]->ObjectName();

return res;
for (SizeT i = 0; i < n; ++i) subList.push_back(libFunList[ i]->ObjectName());
} else {
SizeT n = funList.size();
if (n == 0) {
return new DStringGDL("");
}
for (SizeT i = 0; i < n; ++i)
subList.push_back(funList[ i]->ObjectName());
if (n == 0) return new DStringGDL("");
for (SizeT i = 0; i < n; ++i) subList.push_back(funList[ i]->ObjectName());
}
} else {
if (systemKW) {
SizeT n = libProList.size();
if (n == 0) return new DStringGDL("");

DStringGDL* res = new DStringGDL(dimension(n), BaseGDL::NOZERO);
for (SizeT i = 0; i < n; ++i)
(*res)[i] = libProList[ i]->ObjectName();

return res;
for (SizeT i = 0; i < n; ++i) subList.push_back(libProList[ i]->ObjectName());
} else {
SizeT n = proList.size();
if (n == 0) {
DStringGDL* res = new DStringGDL(1, BaseGDL::NOZERO);
(*res)[0] = "$MAIN$";
return res;
}
if (n == 0) return new DStringGDL("$MAIN$");
subList.push_back("$MAIN$");
for (SizeT i = 0; i < n; ++i)
subList.push_back(proList[ i]->ObjectName());
for (SizeT i = 0; i < n; ++i) subList.push_back(proList[ i]->ObjectName());
}
}

Expand Down Expand Up @@ -9024,12 +8953,7 @@ unsigned int JSHash(const std::string& str)
// we do have a long way in "dinterpreter.cpp" with
// if( firstChar == "#")
bool isFunc = false;
for (FunListT::iterator ifunc = funList.begin(); ifunc != funList.end(); ++ifunc) {
if (StrUpCase(tmp).find((*ifunc)->ObjectName()) != std::string::npos) {
isFunc = true;
break;
}
}
if ( findDFunIx(tmp) != -1 ) isFunc = true; //just to test if func: OK
*(res->GetTag(tFunction, i)) = (isFunc) ? DByteGDL(1) : DByteGDL(0);
//all others 0 for the time being
*(res->GetTag(tMethod, i)) = DByteGDL(0);
Expand Down
32 changes: 20 additions & 12 deletions src/basic_fun_cl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,25 @@ namespace lib {

long dim = timestamps->Dim(0);

long valueYEAR = e->KeywordIx("YEAR");
static int valueYEAR = e->KeywordIx("YEAR");
bool hasYear = e->KeywordPresent(valueYEAR);

long valueMONTH = e->KeywordIx("MONTH");
static int valueMONTH = e->KeywordIx("MONTH");
bool hasMonth = e->KeywordPresent(valueMONTH);

long valueDAY = e->KeywordIx("DAY");
static int valueDAY = e->KeywordIx("DAY");
bool hasDay = e->KeywordPresent(valueDAY);

long valueHOUR = e->KeywordIx("HOUR");
static int valueHOUR = e->KeywordIx("HOUR");
bool hasHour = e->KeywordPresent(valueHOUR);

long valueMINUTE = e->KeywordIx("MINUTE");
static int valueMINUTE = e->KeywordIx("MINUTE");
bool hasMinute = e->KeywordPresent(valueMINUTE);

long valueSECOND = e->KeywordIx("SECOND");
static int valueSECOND = e->KeywordIx("SECOND");
bool hasSecond = e->KeywordPresent(valueSECOND);

long valueOFFSET = e->KeywordIx("OFFSET");
static int valueOFFSET = e->KeywordIx("OFFSET");
bool hasOffset = e->KeywordPresent(valueOFFSET);

if (dim >= 1) {
Expand Down Expand Up @@ -314,6 +314,16 @@ namespace lib {
static int utcIx=e->KeywordIx("UTC");
bool isUTC=e->BooleanKeywordAbsentOrSet(utcIx);

static int YEAR=e->KeywordIx("YEAR");
static int MONTH=e->KeywordIx("MONTH");
static int DAY=e->KeywordIx("DAY");
static int HOUR=e->KeywordIx("HOUR");
static int MINUTE=e->KeywordIx("MINUTE");
static int SECOND=e->KeywordIx("SECOND");
static int OFFSET=e->KeywordIx("OFFSET");

int* values_indexes[]={&YEAR,&MONTH,&DAY,&HOUR,&MINUTE,&SECOND,&OFFSET};

struct timeval tv;

/* Get the current time at high precision; could also use clock_gettime() for
Expand Down Expand Up @@ -347,8 +357,7 @@ namespace lib {
int minListNelem = -1;

for(int i=0; i < 7; ++i){
int valueIx = e->KeywordIx(values_str[i]);
isValue[i]=e->KeywordSet(valueIx);
isValue[i]=e->KeywordSet(*values_indexes[i]);

if(isValue[i]){
if(i==6){
Expand All @@ -357,7 +366,7 @@ namespace lib {
isAnyValue=true;
}

DFloatGDL * par = e->GetKWAs<DFloatGDL>(valueIx);
DFloatGDL * par = e->GetKWAs<DFloatGDL>(*values_indexes[i]);
isParScalar[i] = par->Rank() == 0;

if(!isParScalar[i])
Expand Down Expand Up @@ -479,8 +488,7 @@ namespace lib {

}

static double elapsedIx=e->KeywordIx("ELAPSED");
//bool iselapsed=e->KeywordSet("ELAPSED");
static int elapsedIx=e->KeywordIx("ELAPSED");
bool iselapsed=e->KeywordPresentAndDefined(elapsedIx);
static int julianIx=e->KeywordIx("JULIAN");
bool isjulian=e->KeywordSet(julianIx);
Expand Down
4 changes: 2 additions & 2 deletions src/basic_fun_jmg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1268,12 +1268,12 @@ namespace lib {
pfList.push_back("$MAIN$");

// Procedures
for (ProListT::iterator i = proList.begin(); i != proList.end(); ++i) {
for (ProListT::iterator i = proList.begin(); i != proList.end(); ++i) {//proList complete explore: ok
pfList.push_back((*i)->ObjectName());
}

// Functions
for (FunListT::iterator i = funList.begin(); i != funList.end(); ++i) {
for (FunListT::iterator i = funList.begin(); i != funList.end(); ++i) {//funList complete explore: ok
pfList.push_back((*i)->ObjectName());
}

Expand Down
Loading
Loading