@@ -983,8 +983,9 @@ export default class EquationGen extends ModelReader {
983983 // Push the var name on the stack and then emit it.
984984 let id = ctx . Id ( ) . getText ( )
985985 let varName = canonicalName ( id )
986+ let functionName = this . currentFunctionName ( )
986987 if ( isDimension ( varName ) ) {
987- if ( this . currentFunctionName ( ) === '_ELMCOUNT' ) {
988+ if ( functionName === '_ELMCOUNT' ) {
988989 // Emit the size of the dimension in place of the dimension name.
989990 this . emit ( `${ sub ( varName ) . size } ` )
990991 } else {
@@ -997,8 +998,8 @@ export default class EquationGen extends ModelReader {
997998 }
998999 } else {
9991000 this . varNames . push ( varName )
1000- if ( this . currentFunctionName ( ) === '_VECTOR_SELECT' ) {
1001- let argIndex = this . argIndexForFunctionName ( '_VECTOR_SELECT' )
1001+ if ( functionName === '_VECTOR_SELECT' ) {
1002+ let argIndex = this . argIndexForFunctionName ( functionName )
10021003 if ( argIndex === 0 ) {
10031004 this . vsSelectionArray = this . currentVarName ( )
10041005 super . visitVar ( ctx )
@@ -1007,30 +1008,42 @@ export default class EquationGen extends ModelReader {
10071008 } else {
10081009 super . visitVar ( ctx )
10091010 }
1010- } else if ( this . currentFunctionName ( ) === '_VECTOR_ELM_MAP' ) {
1011- if ( this . argIndexForFunctionName ( '_VECTOR_ELM_MAP' ) === 1 ) {
1011+ } else if ( functionName === '_VECTOR_ELM_MAP' ) {
1012+ if ( this . argIndexForFunctionName ( functionName ) === 1 ) {
10121013 this . vemOffset = this . currentVarName ( )
10131014 }
10141015 super . visitVar ( ctx )
1015- } else if ( this . currentFunctionName ( ) === '_VECTOR_SORT_ORDER' ) {
1016- if ( this . argIndexForFunctionName ( '_VECTOR_SORT_ORDER' ) === 0 ) {
1016+ } else if ( functionName === '_VECTOR_SORT_ORDER' ) {
1017+ if ( this . argIndexForFunctionName ( functionName ) === 0 ) {
10171018 this . vsoVarName = this . currentVarName ( )
10181019 this . vsoTmpName = newTmpVarName ( )
10191020 this . emit ( this . vsoTmpName )
10201021 }
10211022 super . visitVar ( ctx )
1022- } else if ( this . currentFunctionName ( ) === '_ALLOCATE_AVAILABLE' ) {
1023- if ( this . argIndexForFunctionName ( '_ALLOCATE_AVAILABLE' ) === 0 ) {
1023+ } else if ( functionName === '_ALLOCATE_AVAILABLE' ) {
1024+ if ( this . argIndexForFunctionName ( functionName ) === 0 ) {
10241025 this . aaRequestArray = this . currentVarName ( )
10251026 this . aaTmpName = newTmpVarName ( )
10261027 this . emit ( this . aaTmpName )
1027- } else if ( this . argIndexForFunctionName ( '_ALLOCATE_AVAILABLE' ) === 1 ) {
1028+ } else if ( this . argIndexForFunctionName ( functionName ) === 1 ) {
10281029 this . aaPriorityArray = this . currentVarName ( )
10291030 }
10301031 super . visitVar ( ctx )
1031- } else if ( this . currentFunctionName ( ) === '_GET_DATA_BETWEEN_TIMES' ) {
1032+ } else if ( functionName === '_GET_DATA_BETWEEN_TIMES' ) {
10321033 this . emit ( this . currentVarName ( ) )
10331034 super . visitVar ( ctx )
1035+ } else if (
1036+ functionName === '_LOOKUP_FORWARD' ||
1037+ functionName === '_LOOKUP_BACKWARD' ||
1038+ functionName === '_LOOKUP_INVERT'
1039+ ) {
1040+ let argIndex = this . argIndexForFunctionName ( functionName )
1041+ if ( argIndex === 0 ) {
1042+ this . emit ( this . currentVarName ( ) )
1043+ super . visitVar ( ctx )
1044+ } else {
1045+ emitVar ( )
1046+ }
10341047 } else {
10351048 emitVar ( )
10361049 }
0 commit comments