Skip to content

Commit 3020f7b

Browse files
authored
Merge pull request #1645 from GillesDuvert/patch_resolve_routine
patched resolve routine:
2 parents c564be5 + 1c9ac16 commit 3020f7b

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/basic_pro.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -2277,8 +2277,6 @@ static DWORD launch_cmd(BOOL hide, BOOL nowait,
22772277
e->GetParString(0));
22782278
DStringGDL* p0S = static_cast<DStringGDL*> (p0);
22792279

2280-
static StrArr openFiles;
2281-
22822280
SizeT nEl = p0S->N_Elements();
22832281
for (int i = 0; i < nEl; ++i) {
22842282
DString pro = (*p0S)[i];
@@ -2293,34 +2291,34 @@ static DWORD launch_cmd(BOOL hide, BOOL nowait,
22932291
else return;
22942292
}
22952293

2296-
// file already opened?
2297-
bool open = false;
2298-
for (StrArr::iterator j = openFiles.begin(); j != openFiles.end(); ++j) {
2299-
if (proFile == *j) {
2300-
open = true;
2301-
break;
2302-
}
2303-
}
2304-
if (open)
2305-
continue;
23062294
//routine already compiled? NATCHKEBIA Ilia 24.06.2015
23072295
bool exists = false;
23082296
for (ProListT::iterator i = proList.begin(); i != proList.end(); ++i) {
23092297
if (StrUpCase(proFile).find((*i)->ObjectName()) != std::string::npos) {
2310-
//cout << "Routine is compiled,so won't recompile " << (*i)->ObjectName() <<endl;
23112298
exists = true;
23122299
break;
23132300
}
23142301
}
2315-
if (exists && norecompileKeyword)
2316-
continue;
2317-
2318-
StackSizeGuard<StrArr> guard(openFiles);
2302+
if (!exists && (isfunctionKeyword || eitherKeyword)) { //give a chance that the FUNC is already compiled. GD.
2303+
for (FunListT::iterator i = funList.begin(); i != funList.end(); ++i) {
2304+
if (StrUpCase(proFile).find((*i)->ObjectName()) != std::string::npos) {
2305+
exists = true;
2306+
break;
2307+
}
2308+
}
2309+
}
2310+
if (exists && norecompileKeyword) continue;
23192311

2320-
// append file to list
2321-
openFiles.push_back(proFile);
23222312
bool success = GDLInterpreter::CompileFile(proFile,cff?StrUpCase(pro):""); // this might trigger recursion
2323-
2313+
//here the compilation may have produced BOTH a PRO and a FUNC (e.g;: TIC and TOC. Check:
2314+
bool isPro = false; //is pro (GD).
2315+
for (ProListT::iterator i = proList.begin(); i != proList.end(); ++i) {
2316+
if (StrUpCase(proFile).find((*i)->ObjectName()) != std::string::npos) {
2317+
//cout << "exists function " << (*i)->ObjectName() <<endl;
2318+
isPro = true;
2319+
break;
2320+
}
2321+
}
23242322
//is func NATCHKEBIA Ilia 25.06.2015
23252323
bool isFunc = false;
23262324
for (FunListT::iterator i = funList.begin(); i != funList.end(); ++i) {
@@ -2330,9 +2328,11 @@ static DWORD launch_cmd(BOOL hide, BOOL nowait,
23302328
break;
23312329
}
23322330
}
2333-
if ((!isFunc && isfunctionKeyword && !eitherKeyword) ||
2334-
(isFunc && !isfunctionKeyword && !eitherKeyword && !exists))
2335-
if (!quiet) e->Throw("Attempt to call undefined : " + proFile);
2331+
bool both=(isFunc && isPro);
2332+
if (!quiet && !both) {
2333+
if (!isFunc && isfunctionKeyword && !eitherKeyword) e->Throw("Attempt to call undefined : " + proFile);
2334+
if (isFunc && !isfunctionKeyword && !eitherKeyword && !exists) e->Throw("Attempt to call undefined : " + proFile);
2335+
}
23362336

23372337
if (success) {
23382338
// Message("RESOLVE_ROUTINE: Compiled file: " + proFile);

0 commit comments

Comments
 (0)