14 dim as ASTNODE
ptr expr1 =
any, expr2 =
any, expr3 =
any, expr4 =
any
25 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
27 errReport( FB_ERRMSG_CONSTANTCANTBECHANGED, TRUE )
34 hMatchExpressionEx( expr2, FB_DATATYPE_INTEGER )
37 if(
hMatch( CHAR_COMMA ) )
then
39 hMatchExpressionEx( expr3, FB_DATATYPE_INTEGER )
53 hMatchExpressionEx( expr4, FB_DATATYPE_STRING )
58 #define CREATEFAKEID() _
59 astNewVAR( symbAddTempVar( FB_DATATYPE_STRING ) )
64 dim as ASTNODE
ptr dstexpr =
any, srcexpr =
any
65 dim as integer dtype1 =
any, dtype2 =
any
66 dim as FBSYMBOL
ptr dst =
any, src =
any
67 dim as integer is_rset =
any
72 is_rset = (tk = FB_TK_RSET)
77 if( dstexpr = NULL )
then
80 dstexpr = CREATEFAKEID( )
83 dtype1 = astGetDataType( dstexpr )
84 select case as const dtype1
85 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR, _
86 FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR, _
89 if( is_rset
and (dtype1 = FB_DATATYPE_STRUCT) )
then
95 dim as FBSYMBOL
ptr sym = astGetSymbol( dstexpr )
99 if (astGetClass( dstexpr ) = AST_NODECLASS_DEREF)
then
100 sym =
iif( astGetLeft( dstexpr ), astGetSymbol( astGetLeft( dstexpr ) ), NULL )
104 if( sym = NULL )
then
105 errReport( FB_ERRMSG_EXPECTEDIDENTIFIER, TRUE )
107 if( symbIsConstant( sym )
or typeIsConst( astGetFullType( dstexpr ) ) )
then
108 errReport( FB_ERRMSG_CONSTANTCANTBECHANGED, TRUE )
116 dstexpr = CREATEFAKEID( )
120 if(
hMatch( CHAR_COMMA ) = FALSE )
then
127 hMatchExpressionEx( srcexpr, dtype1 )
129 dtype2 = astGetDataType( srcexpr )
130 select case as const dtype2
131 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR, _
132 FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR, _
139 srcexpr = CREATEFAKEID( )
142 if( (dtype1 = FB_DATATYPE_STRUCT)
or _
143 (dtype2 = FB_DATATYPE_STRUCT) )
then
145 if( dtype1 <> dtype2 )
then
153 dst = astGetSymbol( dstexpr )
154 src = astGetSymbol( srcexpr )
155 if( (dst = NULL)
or (src = NULL) )
then
156 errReport( FB_ERRMSG_EXPECTEDIDENTIFIER )
164 srcexpr, symbGetLen( src->subtype ) )
166 function =
rtlStrLRSet( dstexpr, srcexpr, is_rset )
171 function cStrCHR(
byval is_wstr
as integer)
as ASTNODE
ptr
172 static as zstring * 32*6+1 zs
173 static as wstring * 32*6+1 ws
174 static as zstring * 8+1 o
175 dim as longint v =
any, i =
any, cnt =
any, isconst =
any
176 dim as ASTNODE
ptr exprtb(0
to 31) =
any
182 hMatchExpressionEx( exprtb(cnt), FB_DATATYPE_INTEGER )
187 loop while(
hMatch( CHAR_COMMA ) )
192 if( is_wstr
and (env.wchar_doconv = FALSE) )
then
198 if( astIsCONST( exprtb(i) ) = FALSE )
then
213 if( is_wstr = FALSE )
then
223 if( is_wstr = FALSE )
then
224 if(
culngint( v ) > 255 )
then
227 if( (v < CHAR_SPACE)
or (v > 127) )
then
230 zs +=
chr(
len( o ) )
236 if( (v < CHAR_SPACE)
or (v > 127) )
then
239 ws +=
wchr(
len( o ) )
247 if( is_wstr = FALSE )
then
250 function =
astNewVAR( symbAllocWstrConst( ws, cnt ) )
253 function =
rtlStrChr( cnt, exprtb(), is_wstr )
258 dim as ASTNODE
ptr expr1 =
any, posexpr =
any
259 dim as longint p =
any
262 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
265 if(
hMatch( CHAR_COMMA ) )
then
266 hMatchExpressionEx( posexpr, FB_DATATYPE_INTEGER )
274 dim as FBSYMBOL
ptr litsym = NULL
275 select case astGetDataType( expr1 )
276 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
280 if( litsym <> NULL )
then
282 if( (astGetDataType( expr1 ) = FB_DATATYPE_WCHAR)
and _
283 (env.wchar_doconv = FALSE) )
then
287 if( posexpr <> NULL )
then
288 if( astIsCONST( posexpr ) )
then
305 if( astGetDataType( expr1 ) <> FB_DATATYPE_WCHAR )
then
307 dim as zstring ptr zs =
hUnescape( symbGetVarLitText( litsym ) )
308 function =
astNewCONSTi(
asc( *zs, p ), FB_DATATYPE_UINT )
312 dim as wstring ptr ws =
hUnescapeW( symbGetVarLitTextW( litsym ) )
313 function =
astNewCONSTi(
asc( *ws, p ), FB_DATATYPE_UINT )
320 if( expr1 <> NULL )
then
337 dim as FB_DATATYPE dtype = FB_DATATYPE_INVALID
340 if( (tk = FB_TK_CVI)
andalso hMatch( FB_TK_LT ) )
then
346 if( lgt = 8 )
then lgt = 0
350 if(
hMatch( FB_TK_GT ) = FALSE )
then
360 dim as ASTNODE
ptr expr1 =
any
361 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
367 dim as FBSYMBOL
ptr litsym = NULL
368 dim as integer is_str = FALSE
369 select case astGetDataType( expr1 )
370 case FB_DATATYPE_CHAR
373 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR, FB_DATATYPE_WCHAR
377 dim as integer allowconst = TRUE
380 dim as FB_DATATYPE functype =
any
381 select case as const tk
383 functype = FB_DATATYPE_DOUBLE
386 functype = FB_DATATYPE_SINGLE
389 if( dtype <> FB_DATATYPE_INVALID )
then
392 functype = env.lang.integerkeyworddtype
396 functype = FB_DATATYPE_LONG
398 functype = FB_DATATYPE_SHORT
400 assert(tk = FB_TK_CVLONGINT)
401 functype = FB_DATATYPE_LONGINT
404 dim as zstring ptr zs =
any
405 dim as integer zslen =
any
406 if( (allowconst <> FALSE)
and (litsym <> NULL) )
then
408 zs =
hUnescape( symbGetVarLitText( litsym ) )
415 dim as ASTNODE
ptr funcexpr = NULL
417 if( is_str
orelse (functype = FB_DATATYPE_SHORT) )
then
418 if( zslen >= typeGetSize( functype ) )
then
419 select case( functype )
420 case FB_DATATYPE_DOUBLE
421 funcexpr =
astNewCONSTf(
cvd( *zs ), FB_DATATYPE_DOUBLE )
422 case FB_DATATYPE_SINGLE
423 funcexpr =
astNewCONSTf(
cvs( *zs ), FB_DATATYPE_SINGLE )
425 select case( typeGetSize( functype ) )
427 funcexpr =
astNewCONSTi(
cvshort( *zs ), FB_DATATYPE_SHORT )
436 select case( functype )
437 case FB_DATATYPE_DOUBLE
439 case FB_DATATYPE_SINGLE
442 select case( typeGetSize( functype ) )
444 funcexpr =
astNewCALL( PROCLOOKUP(
CVSHORT ) )
448 funcexpr =
astNewCALL( PROCLOOKUP(
CVLONGINT ) )
453 if(
astNewARG( funcexpr, expr1 ) = NULL )
then
458 select case( functype )
459 case FB_DATATYPE_DOUBLE
460 funcexpr =
astNewCALL( PROCLOOKUP( CVDFROMLONGINT ) )
461 case FB_DATATYPE_SINGLE
462 funcexpr =
astNewCALL( PROCLOOKUP( CVSFROML ) )
464 if( typeGetSize( functype ) = 4 )
then
465 funcexpr =
astNewCALL( PROCLOOKUP( CVLFROMS ) )
467 funcexpr =
astNewCALL( PROCLOOKUP( CVLONGINTFROMD ) )
471 if( funcexpr <> NULL )
then
473 if(
astNewARG( funcexpr, expr1 ) = NULL )
then
479 if( funcexpr <> NULL )
then
480 funcexpr =
astNewCONV( functype, NULL, funcexpr )
483 if( funcexpr = NULL )
then
503 dim as FB_DATATYPE dtype = FB_DATATYPE_INVALID
506 if( (tk = FB_TK_MKI)
andalso hMatch( FB_TK_LT ) )
then
512 if( lgt = 8 )
then lgt = 0
516 if(
hMatch( FB_TK_GT ) = FALSE )
then
525 dim as ASTNODE
ptr expr1 =
any
526 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
530 dim as ASTNODE
ptr funcexpr = NULL
532 #macro doMKX( token )
533 select case as const astGetDataType( expr1 )
534 case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
535 funcexpr =
astNewCONSTstr(
str( token( astConstGetAsInt64( expr1 ) ) ) )
536 case FB_DATATYPE_SINGLE, FB_DATATYPE_DOUBLE
538 case FB_DATATYPE_LONG, FB_DATATYPE_ULONG
539 if( 4 =
len(
integer ) )
then
540 funcexpr =
astNewCONSTstr(
str( token( astGetValueAsInt( expr1 ) ) ) )
542 funcexpr =
astNewCONSTstr(
str( token( astConstGetAsInt64( expr1 ) ) ) )
545 funcexpr =
astNewCONSTstr(
str( token( astGetValueAsInt( expr1 ) ) ) )
570 if( expr1 <> NULL )
then
571 select case as const tk
577 if( dtype = FB_DATATYPE_INVALID )
then
578 dtype = env.lang.integerkeyworddtype
581 if( typeGetDtAndPtrOnly( dtype ) = FB_DATATYPE_INTEGER )
then
585 select case( typeGetSizeType( dtype ) )
586 case FB_SIZETYPE_INT16
587 funcexpr =
astNewCALL( PROCLOOKUP(
MKSHORT ) )
588 case FB_SIZETYPE_INT32
590 case FB_SIZETYPE_INT64
591 funcexpr =
astNewCALL( PROCLOOKUP(
MKLONGINT ) )
598 funcexpr =
astNewCALL( PROCLOOKUP(
MKSHORT ) )
600 assert(tk = FB_TK_MKLONGINT)
601 funcexpr =
astNewCALL( PROCLOOKUP(
MKLONGINT ) )
605 if(
astNewARG( funcexpr, expr1 ) = NULL )
then
610 if( funcexpr = NULL )
then
629 dim as ASTNODE
ptr expr1 =
any, expr2 =
any, expr3 =
any
630 dim as integer dclass =
any, dtype =
any, is_any =
any, is_wstr =
any
636 case FB_TK_STR, FB_TK_WSTR
637 is_wstr = (tk = FB_TK_WSTR)
641 hMatchExpressionEx( expr1, FB_DATATYPE_INTEGER )
644 if( is_wstr = FALSE )
then
645 expr1 =
rtlToStr( expr1, fbLangIsSet( FB_LANG_QB ) )
649 if( expr1 = NULL )
then
661 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
663 hMatchExpressionEx( expr2, FB_DATATYPE_INTEGER )
664 if(
hMatch( CHAR_COMMA ) )
then
665 hMatchExpressionEx( expr3, FB_DATATYPE_INTEGER )
672 if( expr1 = NULL )
then
680 case FB_TK_STRING, FB_TK_WSTRING
681 is_wstr = (tk = FB_TK_WSTRING)
685 hMatchExpressionEx( expr1, FB_DATATYPE_INTEGER )
687 hMatchExpressionEx( expr2, FB_DATATYPE_INTEGER )
690 if( is_wstr = FALSE )
then
695 if( expr1 = NULL )
then
703 case FB_TK_CHR, FB_TK_WCHR
704 is_wstr = (tk = FB_TK_WCHR)
719 hMatchExpressionEx( expr1, FB_DATATYPE_INTEGER )
721 is_any =
hMatch( FB_TK_ANY )
722 hMatchExpressionEx( expr2, FB_DATATYPE_STRING )
724 if( is_any = FALSE )
then
725 if(
hMatch( CHAR_COMMA ) )
then
726 is_any =
hMatch( FB_TK_ANY )
727 hMatchExpressionEx( expr3, FB_DATATYPE_STRING )
730 if( expr3 = NULL )
then
738 if( expr1 = NULL )
then
749 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
751 is_any =
hMatch( FB_TK_ANY )
752 hMatchExpressionEx( expr2, FB_DATATYPE_STRING )
753 if(
hMatch( CHAR_COMMA ) )
then
754 hMatchExpressionEx( expr3, FB_DATATYPE_INTEGER )
761 if( expr1 = NULL )
then
768 case FB_TK_TRIM, FB_TK_LTRIM, FB_TK_RTRIM
772 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
773 if(
hMatch( CHAR_COMMA ) )
then
774 is_any =
hMatch( FB_TK_ANY )
775 hMatchExpressionEx( expr2, FB_DATATYPE_STRING )
791 if( expr1 = NULL )
then
799 case FB_TK_LCASE, FB_TK_UCASE
803 hMatchExpressionEx( expr1, FB_DATATYPE_STRING )
806 if(
hMatch( CHAR_COMMA ) )
then
807 hMatchExpressionEx( expr2, FB_DATATYPE_INTEGER )
814 function =
rtlStrCase( expr1, expr2, (tk = FB_TK_LCASE) )