|
@@ -675,7 +675,7 @@ bool checkExternFoldable(IHqlExpression* expr, unsigned foldOptions, StringBuffe
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void *loadExternalEntryPoint(IHqlExpression* expr, unsigned foldOptions, ITemplateContext *templateContext, const char *library, const char *entrypoint, HINSTANCE &hDLL)
|
|
|
+void *loadExternalEntryPoint(IHqlExpression* expr, unsigned foldOptions, const char *library, const char *entrypoint, HINSTANCE &hDLL)
|
|
|
{
|
|
|
IHqlExpression * funcdef = expr->queryExternalDefinition();
|
|
|
IHqlExpression *body = funcdef->queryChild(0);
|
|
@@ -709,7 +709,7 @@ void *loadExternalEntryPoint(IHqlExpression* expr, unsigned foldOptions, ITempla
|
|
|
extern __int64 foldExternalCallStub(void * fh, double * doubleresult, size_t len, void * params);
|
|
|
#endif
|
|
|
|
|
|
-IValue * doFoldExternalCall(IHqlExpression* expr, unsigned foldOptions, ITemplateContext *templateContext, const char *library, const char *entrypoint, void *fh)
|
|
|
+IValue * doFoldExternalCall(IHqlExpression* expr, unsigned foldOptions, const char *library, const char *entrypoint, void *fh)
|
|
|
{
|
|
|
// NOTE - on OSX there are compiler bugs that prevent exceptions thrown from within this function from properly unwinding.
|
|
|
// Hence anything that can throw an exception should be pre-checked in one of the functions above.
|
|
@@ -721,9 +721,6 @@ IValue * doFoldExternalCall(IHqlExpression* expr, unsigned foldOptions, ITemplat
|
|
|
// the called function
|
|
|
FuncCallStack fstack(getBoolAttribute(body, passParameterMetaAtom, false), DEFAULTSTACKSIZE);
|
|
|
|
|
|
- if(body->hasAttribute(templateAtom))
|
|
|
- fstack.pushPtr(templateContext);
|
|
|
-
|
|
|
//if these were allowed to be optional - then the following code would be needed
|
|
|
if(body->hasAttribute(contextAtom) || body->hasAttribute(globalContextAtom))
|
|
|
fstack.pushPtr(NULL);
|
|
@@ -1345,7 +1342,7 @@ IValue * doFoldExternalCall(IHqlExpression* expr, unsigned foldOptions, ITemplat
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-IValue * foldExternalCall(IHqlExpression* expr, unsigned foldOptions, ITemplateContext *templateContext)
|
|
|
+IValue * foldExternalCall(IHqlExpression* expr, unsigned foldOptions)
|
|
|
{
|
|
|
StringBuffer library;
|
|
|
StringBuffer entry;
|
|
@@ -1353,13 +1350,13 @@ IValue * foldExternalCall(IHqlExpression* expr, unsigned foldOptions, ITemplateC
|
|
|
return NULL;
|
|
|
// NOTE - we do not call FreeSharedObject(hDLL) - the embedded language folding requires that the dll stay loaded, and it's also more efficient for other cases
|
|
|
HINSTANCE hDll;
|
|
|
- void *funcptr = loadExternalEntryPoint(expr, foldOptions, templateContext, library.str(), entry.str(), hDll);
|
|
|
+ void *funcptr = loadExternalEntryPoint(expr, foldOptions, library.str(), entry.str(), hDll);
|
|
|
if (!funcptr)
|
|
|
{
|
|
|
UERRLOG("Failed to load function %s", entry.str());
|
|
|
return NULL;
|
|
|
}
|
|
|
- return doFoldExternalCall(expr, foldOptions, templateContext, library.str(), entry.str(), funcptr);
|
|
|
+ return doFoldExternalCall(expr, foldOptions, library.str(), entry.str(), funcptr);
|
|
|
}
|
|
|
|
|
|
//------------------------------------------------------------------------------------------
|
|
@@ -1609,7 +1606,7 @@ IHqlExpression *deserializeConstantSet(ITypeInfo *type, bool isAll, size32_t len
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-IHqlExpression * foldEmbeddedCall(IHqlExpression* expr, unsigned foldOptions, ITemplateContext *templateContext)
|
|
|
+IHqlExpression * foldEmbeddedCall(IHqlExpression* expr, unsigned foldOptions)
|
|
|
{
|
|
|
if (!checkEmbeddedFoldable(expr, foldOptions))
|
|
|
return NULL;
|
|
@@ -1649,7 +1646,7 @@ IHqlExpression * foldEmbeddedCall(IHqlExpression* expr, unsigned foldOptions, IT
|
|
|
IHqlExpression *languageAttr = body->queryAttribute(languageAtom);
|
|
|
HqlExprArray noParams;
|
|
|
OwnedHqlExpr langLoadCall = createTranslatedExternalCall(NULL, languageAttr->queryChild(0), noParams);
|
|
|
- Owned<IValue> plugin = foldExternalCall(langLoadCall, foldOptions, templateContext);
|
|
|
+ Owned<IValue> plugin = foldExternalCall(langLoadCall, foldOptions);
|
|
|
if (plugin == nullptr)
|
|
|
return NULL;
|
|
|
// Slightly odd code - the getEmbedContext function returns a linked object or a singleton depending on a flag
|
|
@@ -2419,7 +2416,7 @@ static IHqlExpression * foldHashXX(IHqlExpression * expr)
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
-IHqlExpression * foldConstantOperator(IHqlExpression * expr, unsigned foldOptions, ITemplateContext * templateContext)
|
|
|
+IHqlExpression * foldConstantOperator(IHqlExpression * expr, unsigned foldOptions)
|
|
|
{
|
|
|
DBZaction onZero = (foldOptions & HFOforcefold) ? DBZfail : DBZnone;
|
|
|
node_operator op = expr->getOperator();
|
|
@@ -3783,7 +3780,7 @@ IHqlExpression * foldConstantOperator(IHqlExpression * expr, unsigned foldOption
|
|
|
}
|
|
|
case no_externalcall:
|
|
|
{ //external function folding.
|
|
|
- IValue * result = foldExternalCall(expr, foldOptions, templateContext);
|
|
|
+ IValue * result = foldExternalCall(expr, foldOptions);
|
|
|
if (result)
|
|
|
return createConstant(result);
|
|
|
break;
|
|
@@ -3799,7 +3796,7 @@ IHqlExpression * foldConstantOperator(IHqlExpression * expr, unsigned foldOption
|
|
|
IHqlExpression * body = def->queryChild(0);
|
|
|
if (body->getOperator() == no_outofline && body->queryChild(0)->getOperator()==no_embedbody)
|
|
|
{
|
|
|
- IHqlExpression * result = foldEmbeddedCall(expr, foldOptions, templateContext);
|
|
|
+ IHqlExpression * result = foldEmbeddedCall(expr, foldOptions);
|
|
|
if (result)
|
|
|
return result;
|
|
|
break;
|
|
@@ -5382,7 +5379,7 @@ IHqlExpression * CExprFolderTransformer::doFoldTransformed(IHqlExpression * unfo
|
|
|
if ((unfolded != body) && !expr->isAnnotation() && !expr->queryValue())
|
|
|
expr.setown(unfolded->cloneAllAnnotations(expr));
|
|
|
#else
|
|
|
- OwnedHqlExpr expr = foldConstantOperator(unfolded, foldOptions, templateContext);
|
|
|
+ OwnedHqlExpr expr = foldConstantOperator(unfolded, foldOptions);
|
|
|
#endif
|
|
|
|
|
|
node_operator op = expr->getOperator();
|
|
@@ -5897,8 +5894,8 @@ FolderTransformInfo::~FolderTransformInfo()
|
|
|
}
|
|
|
|
|
|
static HqlTransformerInfo cExprFolderTransformerInfo("CExprFolderTransformer");
|
|
|
-CExprFolderTransformer::CExprFolderTransformer(IErrorReceiver & _errorProcessor, ITemplateContext * _templateContext, unsigned _options)
|
|
|
-: NewHqlTransformer(cExprFolderTransformerInfo), templateContext(_templateContext), errorProcessor(_errorProcessor)
|
|
|
+CExprFolderTransformer::CExprFolderTransformer(IErrorReceiver & _errorProcessor, unsigned _options)
|
|
|
+: NewHqlTransformer(cExprFolderTransformerInfo), errorProcessor(_errorProcessor)
|
|
|
{
|
|
|
foldOptions = _options;
|
|
|
}
|
|
@@ -7082,7 +7079,7 @@ IHqlExpression * foldHqlExpression(IHqlExpression * expr)
|
|
|
return foldHqlExpression(errorProcessor, expr);
|
|
|
}
|
|
|
|
|
|
-IHqlExpression * foldHqlExpression(IErrorReceiver & errorProcessor, IHqlExpression * expr, ITemplateContext *templateContext, unsigned foldOptions)
|
|
|
+IHqlExpression * foldHqlExpression(IErrorReceiver & errorProcessor, IHqlExpression * expr, unsigned foldOptions)
|
|
|
{
|
|
|
if (!expr)
|
|
|
return NULL;
|
|
@@ -7103,7 +7100,7 @@ IHqlExpression * foldHqlExpression(IErrorReceiver & errorProcessor, IHqlExpressi
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- CExprFolderTransformer folder(errorProcessor, templateContext, foldOptions);
|
|
|
+ CExprFolderTransformer folder(errorProcessor, foldOptions);
|
|
|
|
|
|
#if 0
|
|
|
dbglogExpr(expr);
|
|
@@ -7123,7 +7120,7 @@ IHqlExpression * foldScopedHqlExpression(IErrorReceiver & errorProcessor, IHqlEx
|
|
|
if (!expr)
|
|
|
return NULL;
|
|
|
|
|
|
- CExprFolderTransformer folder(errorProcessor, NULL, foldOptions);
|
|
|
+ CExprFolderTransformer folder(errorProcessor, foldOptions);
|
|
|
|
|
|
if (dataset)
|
|
|
folder.setScope(dataset);
|
|
@@ -7136,7 +7133,7 @@ IHqlExpression * foldScopedHqlExpression(IErrorReceiver & errorProcessor, IHqlEx
|
|
|
|
|
|
void foldHqlExpression(IErrorReceiver & errorProcessor, HqlExprArray & tgt, HqlExprArray & src, unsigned foldOptions)
|
|
|
{
|
|
|
- CExprFolderTransformer folder(errorProcessor, NULL, foldOptions);
|
|
|
+ CExprFolderTransformer folder(errorProcessor, foldOptions);
|
|
|
folder.transformRoot(src, tgt);
|
|
|
}
|
|
|
|
|
@@ -7241,8 +7238,8 @@ static HqlTransformerInfo quickConstantTransformerInfo("QuickConstantTransformer
|
|
|
class QuickConstantTransformer : public QuickHqlTransformer
|
|
|
{
|
|
|
public:
|
|
|
- QuickConstantTransformer(ITemplateContext * _templateContext, unsigned _foldOptions) :
|
|
|
- QuickHqlTransformer(quickConstantTransformerInfo, NULL), templateContext(_templateContext), foldOptions(_foldOptions) {}
|
|
|
+ QuickConstantTransformer(unsigned _foldOptions) :
|
|
|
+ QuickHqlTransformer(quickConstantTransformerInfo, NULL), foldOptions(_foldOptions) {}
|
|
|
|
|
|
virtual IHqlExpression * createTransformedBody(IHqlExpression * expr)
|
|
|
{
|
|
@@ -7295,23 +7292,22 @@ public:
|
|
|
}
|
|
|
|
|
|
OwnedHqlExpr transformed = QuickHqlTransformer::createTransformedBody(expr);
|
|
|
- return foldConstantOperator(transformed, foldOptions, templateContext);
|
|
|
+ return foldConstantOperator(transformed, foldOptions);
|
|
|
}
|
|
|
|
|
|
protected:
|
|
|
- ITemplateContext *templateContext;
|
|
|
unsigned foldOptions;
|
|
|
};
|
|
|
|
|
|
-extern HQLFOLD_API IHqlExpression * quickFoldExpression(IHqlExpression * expr, ITemplateContext *context, unsigned options)
|
|
|
+extern HQLFOLD_API IHqlExpression * quickFoldExpression(IHqlExpression * expr, unsigned options)
|
|
|
{
|
|
|
- QuickConstantTransformer transformer(context, options);
|
|
|
+ QuickConstantTransformer transformer(options);
|
|
|
return transformer.transform(expr);
|
|
|
}
|
|
|
|
|
|
-extern HQLFOLD_API void quickFoldExpressions(HqlExprArray & target, const HqlExprArray & source, ITemplateContext *context, unsigned options)
|
|
|
+extern HQLFOLD_API void quickFoldExpressions(HqlExprArray & target, const HqlExprArray & source, unsigned options)
|
|
|
{
|
|
|
- QuickConstantTransformer transformer(context, options);
|
|
|
+ QuickConstantTransformer transformer(options);
|
|
|
ForEachItemIn(i, source)
|
|
|
target.append(*transformer.transform(&source.item(i)));
|
|
|
}
|