📄 opt_coercion.c
字号:
#line 53 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_coercion.mx"#include "mal_config.h"#include "opt_coercion.h"static intcoercionOptimizerStep(MalBlkPtr mb, int i, InstrPtr p){ int t, a, b; a = getArg(p, 0); b = getArg(p, 1); t = getVarType(mb, b); if( getVarType(mb,a) != t) return 0; if (strcmp(getFunctionId(p), ATOMname(t)) == 0) { removeInstruction(mb, p); replaceAlias(mb, i, mb->stop, a, b); return 1; } return 0;}static intOPTcoercionImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){ int i, k; InstrPtr p; int actions = 0; str calcRef= putName("calc",4); (void) pci; (void) stk; /* to fool compilers */ for (i = 1; i < mb->stop; i++) { p = getInstrPtr(mb, i); if (getModuleId(p) == NULL) continue; if (getModuleId(p)==calcRef && p->argc == 2) { k= coercionOptimizerStep(mb, i, p); actions += k; if( k) i--; } }#line 97 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_coercion.mx" return actions;}#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_coercion.mx"#line 101 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_coercion.mx"/* #define _DEBUG_OPTIMIZER_*/str OPTcoercion(MalBlkPtr mb, MalStkPtr stk, InstrPtr p){ str modnme; str fcnnme; Module scope=NULL; Symbol s= NULL; lng clk= GDKusec(); int actions = 0; optimizerInit(); if( p ) removeInstruction(mb, p);#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"apply coercion\n"); printFunction(GDKout,mb,LIST_MAL_ALL);#endif if( p && p->argc > 1 && getFunctionId(p) != multiplexRef){#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"locate function coercion\n");#endif if( getArgType(mb,p,1) != TYPE_str || getArgType(mb,p,2) != TYPE_str || !isConstant(mb,getArg(p,1)) || !isConstant(mb,getArg(p,2)) ) { char buf[1024]; snprintf(buf,1024, "Optimizer requires constant string arguments\n"); throw(MAL, "optimizer.coercion",buf); } if( stk != 0){ modnme= (str)getArgValue(stk,p,1); fcnnme= (str)getArgValue(stk,p,2); } else { modnme= getArgDefault(mb,p,1); fcnnme= getArgDefault(mb,p,2); } scope = findModule(MCgetClient()->nspace,putName(modnme,strlen(modnme)) ); if( scope) s= findSymbolInModule(scope,putName(fcnnme,strlen(fcnnme))); if( s == NULL) { char buf[1024]; snprintf(buf,1024, "Could not find %s.%s\n",modnme,fcnnme); throw(MAL, "optimizer.coercion",buf); }#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"coercion %s %d\n",modnme,fcnnme);#endif mb = s->def; stk= 0; } if( mb->errors ) return MAL_SUCCEED; addtoMalBlkHistory(mb); actions= OPTcoercionImplementation(mb,stk,p);#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"finished coercion %d\n",actions); printFunction(GDKout,mb,LIST_MAL_ALL);#endif optimizerCheck(mb, "optimizer.coercion", actions, GDKusec() - clk,OPT_CHECK_FLOW); return MAL_SUCCEED;}#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_coercion.mx"#line 105 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_coercion.mx"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -