17 byval l as ASTNODE
ptr,
_
18 byval r
as ASTNODE
ptr _
21 dim as FBSYMBOL
ptr s =
any, ls =
any, rs =
any
23 ls = astGetSymbol(
l )
24 rs = astGetSymbol( r )
28 symbGetStrLen( ls ) - 1 + symbGetStrLen( rs ) - 1 )
40 byval l as ASTNODE
ptr,
_
41 byval r
as ASTNODE
ptr _
44 dim as FBSYMBOL
ptr s =
any, ls =
any, rs =
any
46 ls = astGetSymbol(
l )
47 rs = astGetSymbol( r )
49 if( symbGetType( ls ) <> FB_DATATYPE_WCHAR )
then
51 s = symbAllocWstrConst(
wstr( *symbGetVarLitText( ls ) ) + *symbGetVarLitTextW( rs ),
_
52 symbGetStrLen( ls ) - 1 + symbGetWstrLen( rs ) - 1 )
54 elseif( symbGetType( rs ) <> FB_DATATYPE_WCHAR )
then
55 s = symbAllocWstrConst( *symbGetVarLitTextW( ls ) +
wstr( *symbGetVarLitText( rs ) ),
_
56 symbGetWstrLen( ls ) - 1 + symbGetStrLen( rs ) - 1 )
59 s = symbAllocWstrConst( *symbGetVarLitTextW( ls ) + *symbGetVarLitTextW( rs ),
_
60 symbGetWstrLen( ls ) - 1 + symbGetWstrLen( rs ) - 1 )
73 byval op as integer,
_
74 byval l as ASTNODE
ptr,
_
75 byval r
as ASTNODE
ptr _
78 static as DZSTRING ltext, rtext
79 dim as integer res =
any
84 select case as const op
86 res = (*ltext.
data = *rtext.
data)
88 res = (*ltext.
data > *rtext.
data)
90 res = (*ltext.
data < *rtext.
data)
92 res = (*ltext.
data <> *rtext.
data)
94 res = (*ltext.
data <= *rtext.
data)
96 res = (*ltext.
data >= *rtext.
data)
109 byval op as integer,
_
110 byval l as ASTNODE
ptr,
_
111 byval r
as ASTNODE
ptr _
114 dim as FBSYMBOL
ptr ls =
any, rs =
any
115 static as DZSTRING textz
116 static as DWSTRING ltextw, rtextw
117 dim as integer res =
any
119 ls = astGetSymbol(
l )
120 rs = astGetSymbol( r )
123 if( symbGetType( ls ) <> FB_DATATYPE_WCHAR )
then
127 select case as const op
129 res = (*textz.
data = *rtextw.
data)
131 res = (*textz.
data > *rtextw.
data)
133 res = (*textz.
data < *rtextw.
data)
135 res = (*textz.
data <> *rtextw.
data)
137 res = (*textz.
data <= *rtextw.
data)
139 res = (*textz.
data >= *rtextw.
data)
143 elseif( symbGetType( rs ) <> FB_DATATYPE_WCHAR )
then
147 select case as const op
149 res = (*ltextw.
data = *textz.
data)
151 res = (*ltextw.
data > *textz.
data)
153 res = (*ltextw.
data < *textz.
data)
155 res = (*ltextw.
data <> *textz.
data)
157 res = (*ltextw.
data <= *textz.
data)
159 res = (*ltextw.
data >= *textz.
data)
167 select case as const op
169 res = (*ltextw.
data = *rtextw.
data)
171 res = (*ltextw.
data > *rtextw.
data)
173 res = (*ltextw.
data < *rtextw.
data)
175 res = (*ltextw.
data <> *rtextw.
data)
177 res = (*ltextw.
data <= *rtextw.
data)
179 res = (*ltextw.
data >= *rtextw.
data)
191 sub hToStr(
byref l as ASTNODE
ptr,
byref r
as ASTNODE
ptr)
192 dim as integer ldtype =
any, rdtype =
any
194 ldtype = astGetDataType(
l )
195 rdtype = astGetDataType( r )
198 select case as const ldtype
199 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR,
_
200 FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
214 select case as const rdtype
215 case FB_DATATYPE_STRING, FB_DATATYPE_FIXSTR,
_
216 FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
221 if( ldtype <> FB_DATATYPE_WCHAR )
then
237 byval op as integer,
_
238 byval dtype
as integer,
_
239 byval subtype
as FBSYMBOL
ptr,
_
240 byval l as ASTNODE
ptr,
_
241 byval r
as ASTNODE
ptr _
244 if( typeGetClass(
l->dtype ) = FB_DATACLASS_FPOINT )
then
245 select case as const(
op )
247 l->
val.f =
l->
val.f + r->
val.f
249 l->
val.f =
l->
val.f - r->
val.f
251 l->
val.f =
l->
val.f * r->
val.f
255 l->
val.f =
l->
val.f / r->
val.f
257 l->
val.f =
l->
val.f ^ r->
val.f
259 l->
val.i =
l->
val.f <> r->
val.f
261 l->
val.i =
l->
val.f = r->
val.f
263 l->
val.i =
l->
val.f > r->
val.f
265 l->
val.i =
l->
val.f < r->
val.f
267 l->
val.i =
l->
val.f <= r->
val.f
269 l->
val.i =
l->
val.f >= r->
val.f
271 l->
val.f =
atan2(
l->
val.f, r->
val.f )
274 l->
val.i = (r->
val.f <> 0)
282 l->
val.i = (r->
val.f <> 0)
288 elseif( typeIsSigned(
l->dtype ) )
then
289 select case as const(
op )
290 case AST_OP_ADD :
l->
val.i =
l->
val.i + r->
val.i
291 case AST_OP_SUB :
l->
val.i =
l->
val.i - r->
val.i
292 case AST_OP_MUL :
l->
val.i =
l->
val.i * r->
val.i
293 case AST_OP_SHL :
l->
val.i =
l->
val.i
shl r->
val.i
294 case AST_OP_SHR :
l->
val.i =
l->
val.i
shr r->
val.i
295 case AST_OP_AND :
l->
val.i =
l->
val.i
and r->
val.i
296 case AST_OP_OR :
l->
val.i =
l->
val.i
or r->
val.i
297 case AST_OP_XOR :
l->
val.i =
l->
val.i
xor r->
val.i
298 case AST_OP_EQV :
l->
val.i =
l->
val.i
eqv r->
val.i
299 case AST_OP_IMP :
l->
val.i =
l->
val.i
imp r->
val.i
300 case AST_OP_NE :
l->
val.i =
l->
val.i <> r->
val.i
301 case AST_OP_EQ :
l->
val.i =
l->
val.i = r->
val.i
302 case AST_OP_GT :
l->
val.i =
l->
val.i > r->
val.i
303 case AST_OP_LT :
l->
val.i =
l->
val.i < r->
val.i
304 case AST_OP_LE :
l->
val.i =
l->
val.i <= r->
val.i
305 case AST_OP_GE :
l->
val.i =
l->
val.i >= r->
val.i
306 case AST_OP_ANDALSO :
l->
val.i =
iif(
l->
val.i <> 0, r->
val.i <> 0, 0 )
307 case AST_OP_ORELSE :
l->
val.i =
iif(
l->
val.i <> 0, -1, r->
val.i <> 0 )
309 if( r->
val.i <> 0 )
then
310 l->
val.i =
l->
val.i \ r->
val.i
316 if( r->
val.i <> 0 )
then
317 l->
val.i =
l->
val.i
mod r->
val.i
328 select case as const(
op )
329 case AST_OP_ADD :
l->
val.i = cunsg(
l->
val.i ) + cunsg( r->
val.i )
330 case AST_OP_SUB :
l->
val.i = cunsg(
l->
val.i ) - cunsg( r->
val.i )
331 case AST_OP_MUL :
l->
val.i = cunsg(
l->
val.i ) * cunsg( r->
val.i )
332 case AST_OP_SHL :
l->
val.i = cunsg(
l->
val.i )
shl cunsg( r->
val.i )
333 case AST_OP_SHR :
l->
val.i = cunsg(
l->
val.i )
shr cunsg( r->
val.i )
334 case AST_OP_AND :
l->
val.i = cunsg(
l->
val.i )
and cunsg( r->
val.i )
335 case AST_OP_OR :
l->
val.i = cunsg(
l->
val.i )
or cunsg( r->
val.i )
336 case AST_OP_XOR :
l->
val.i = cunsg(
l->
val.i )
xor cunsg( r->
val.i )
337 case AST_OP_EQV :
l->
val.i = cunsg(
l->
val.i )
eqv cunsg( r->
val.i )
338 case AST_OP_IMP :
l->
val.i = cunsg(
l->
val.i )
imp cunsg( r->
val.i )
339 case AST_OP_NE :
l->
val.i = cunsg(
l->
val.i ) <> cunsg( r->
val.i )
340 case AST_OP_EQ :
l->
val.i = cunsg(
l->
val.i ) = cunsg( r->
val.i )
341 case AST_OP_GT :
l->
val.i = cunsg(
l->
val.i ) > cunsg( r->
val.i )
342 case AST_OP_LT :
l->
val.i = cunsg(
l->
val.i ) < cunsg( r->
val.i )
343 case AST_OP_LE :
l->
val.i = cunsg(
l->
val.i ) <= cunsg( r->
val.i )
344 case AST_OP_GE :
l->
val.i = cunsg(
l->
val.i ) >= cunsg( r->
val.i )
345 case AST_OP_ANDALSO :
l->
val.i =
iif(
l->
val.i <> 0, r->
val.i <> 0, 0 )
346 case AST_OP_ORELSE :
l->
val.i =
iif(
l->
val.i <> 0, -1, r->
val.i <> 0 )
348 if( r->
val.i <> 0 )
then
349 l->
val.i = cunsg(
l->
val.i ) \ cunsg( r->
val.i )
355 if( r->
val.i <> 0 )
then
356 l->
val.i = cunsg(
l->
val.i )
mod cunsg( r->
val.i )
374 byval op as integer,
_
375 byval dtype
as integer,
_
376 byval dclass
as integer _
380 if( dclass <> FB_DATACLASS_INTEGER )
then
385 select case typeGet( dtype )
386 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
393 case AST_OP_ADD, AST_OP_SUB
396 if( typeIsPtr( dtype ) )
then
403 case AST_OP_ANDALSO, AST_OP_ORELSE
407 case AST_OP_EQ, AST_OP_GT, AST_OP_LT, AST_OP_NE, AST_OP_LE, AST_OP_GE
420 byval op as integer,
_
421 byval p as ASTNODE
ptr,
_
422 byval e
as ASTNODE
ptr,
_
423 byval swapped
as integer =
FALSE _
426 dim as integer edtype =
any
427 dim as longint lgt =
any
431 edtype = astGetDataType( e )
434 if( typeGetClass( edtype ) <> FB_DATACLASS_INTEGER )
then
440 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
453 if( typeIsPtr( edtype ) )
then
455 if(
op = AST_OP_SUB )
then
457 if( (edtype <> astGetDataType(
p ))
or _
458 (astGetSubType( e ) <> astGetSubType(
p )) )
then
464 e =
astNewCONV( FB_DATATYPE_INTEGER, NULL, e )
477 if( edtype <> FB_DATATYPE_INTEGER )
then
478 e =
astNewCONV( FB_DATATYPE_INTEGER, NULL, e )
483 case AST_OP_ADD, AST_OP_SUB
485 if( (
op = AST_OP_SUB)
andalso swapped )
then
505 byval op as integer,
_
506 byval l as ASTNODE
ptr,
_
507 byval r
as ASTNODE
ptr,
_
508 byval ex
as FBSYMBOL
ptr,
_
509 byval options
as AST_OPOPT
_
512 dim as ASTNODE
ptr t =
any
517 t =
astNewBOP(
op,
l, t, ex, options
or AST_OPOPT_NOCOERCION )
524 t =
astNewCONV( astGetFullType( r ), r->subtype,
l )
526 t =
astNewBOP(
op, t, r, ex, options
or AST_OPOPT_NOCOERCION )
546 byval op as integer,
_
547 byval l as ASTNODE
ptr,
_
548 byval r
as ASTNODE
ptr,
_
549 byval ex
as FBSYMBOL
ptr,
_
550 byval options
as AST_OPOPT
_
553 dim as ASTNODE
ptr t =
any
556 t =
astNewCONV( astGetFullType( r ), r->subtype,
l )
558 t =
astNewBOP(
op, t, r, ex, options
or AST_OPOPT_NOCOERCION )
567 t =
astNewBOP(
op,
l, t, ex, options
or AST_OPOPT_NOCOERCION )
576 return astNewBOP(
op,
l, t, ex, options
or AST_OPOPT_NOCOERCION )
584 #macro hDoGlobOpOverload
_
589 if( symb.globOpOvlTb(
op).head <> NULL )
then
590 dim as FBSYMBOL
ptr proc =
any
591 dim as FB_ERRMSG err_num =
any
593 proc = symbFindBopOvlProc(
op,
l, r, @err_num )
594 if( proc <> NULL )
then
596 return astBuildCall( proc,
l, r )
598 if( err_num <> FB_ERRMSG_OK )
then
622 byval l as ASTNODE
ptr,
_
623 byval pldtype
as integer ptr,
_
624 byval r
as ASTNODE
ptr,
_
625 byval rdtype
as integer _
628 dim as ASTNODE
ptr ll =
any
631 if(
l->
class <> AST_NODECLASS_DEREF )
then
638 if( ll->
class = AST_NODECLASS_VAR )
then
639 if( symbGetIsWstring( ll->sym ) )
then
647 *pldtype = typeJoin( *pldtype, env.target.wchar )
656 byval newdtype
as integer,
_
657 byref dtype
as integer,
_
658 byref dclass
as integer,
_
659 byref n
as ASTNODE
ptr _
662 dtype = typeJoin( dtype, newdtype )
663 dclass = typeGetClass( newdtype )
671 byval op as integer,
_
672 byval l as ASTNODE
ptr,
_
673 byval r
as ASTNODE
ptr,
_
674 byval ex
as FBSYMBOL
ptr,
_
675 byval options
as AST_OPOPT
_
678 dim as ASTNODE
ptr n =
any
679 dim as integer ldtype0 =
any, rdtype0 =
any
680 dim as integer ldtype =
any, rdtype =
any, dtype =
any
681 dim as integer ldclass =
any, rdclass =
any
682 dim as integer lrank =
any, rrank =
any, intrank =
any, uintrank =
any
683 dim as integer is_str =
any
684 dim as FBSYMBOL
ptr litsym =
any, subtype =
any
689 hDoGlobOpOverload(
op,
l, r )
702 ldtype = astGetFullType(
l )
703 rdtype = astGetFullType( r )
704 ldclass = typeGetClass( ldtype )
705 rdclass = typeGetClass( rdtype )
708 if( (typeGet( ldtype ) = FB_DATATYPE_STRUCT)
or _
709 (typeGet( rdtype ) = FB_DATATYPE_STRUCT) )
then
712 if( (options
and AST_OPOPT_NOCOERCION) <> 0 )
then
717 if( typeGet( ldtype ) = FB_DATATYPE_STRUCT )
then
728 if( typeIsPtr( ldtype ) )
then
730 if( (options
and AST_OPOPT_LPTRARITH) <> 0 )
then
738 elseif( typeIsPtr( rdtype ) )
then
740 if( (options
and AST_OPOPT_RPTRARITH) <> 0 )
then
760 if( typeGet( ldtype ) = FB_DATATYPE_ENUM )
then
763 if( typeGet( rdtype ) = FB_DATATYPE_ENUM )
then
768 if( (typeGet( ldtype ) = FB_DATATYPE_CHAR)
and _
769 (typeGet( rdtype ) = FB_DATATYPE_CHAR) )
then
770 ldclass = FB_DATACLASS_STRING
775 if( (typeGet( ldtype ) = FB_DATATYPE_WCHAR)
or _
776 (typeGet( rdtype ) = FB_DATATYPE_WCHAR) )
then
779 if( typeGetDtAndPtrOnly( ldtype ) <> typeGetDtAndPtrOnly( rdtype ) )
then
780 if( typeGet( ldtype ) = FB_DATATYPE_WCHAR )
then
782 is_str = (rdclass = FB_DATACLASS_STRING)
or (typeGet( rdtype ) = FB_DATATYPE_CHAR)
785 is_str = (ldclass = FB_DATACLASS_STRING)
or (typeGet( ldtype ) = FB_DATATYPE_CHAR)
795 select case typeGet( ldtype )
796 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
798 if( litsym <> NULL )
then
800 case FB_DATATYPE_CHAR, FB_DATATYPE_WCHAR
808 select case as const op
813 if( litsym <> NULL )
then
815 if( (typeGetDtAndPtrOnly( ldtype ) = typeGetDtAndPtrOnly( rdtype ))
or _
816 env.wchar_doconv )
then
822 if( typeGetDtAndPtrOnly( ldtype ) <> typeGetDtAndPtrOnly( rdtype ) )
then
827 ldtype = typeUnsetIsConst( typeJoin( ldtype, FB_DATATYPE_WCHAR ) )
828 ldclass = FB_DATACLASS_INTEGER
829 rdtype = typeJoin( rdtype, ldtype )
837 case AST_OP_EQ, AST_OP_GT, AST_OP_LT, AST_OP_NE, AST_OP_LE, AST_OP_GE
839 if( litsym <> NULL )
then
840 return hWstrLiteralCompare(
op,
l, r )
847 ldtype = typeJoin( ldtype, astGetFullType(
l ) )
848 rdtype = typeJoin( rdtype, astGetFullType( r ) )
849 ldclass = FB_DATACLASS_INTEGER
850 rdclass = FB_DATACLASS_INTEGER
862 if( typeGet( ldtype ) = FB_DATATYPE_WCHAR )
then
874 elseif( (ldclass = FB_DATACLASS_STRING)
or _
875 (rdclass = FB_DATACLASS_STRING) )
then
878 if( ldclass <> rdclass )
then
879 if( ldclass = FB_DATACLASS_STRING )
then
881 if( typeGet( rdtype ) <> FB_DATATYPE_CHAR )
then
886 if( typeGet( ldtype ) <> FB_DATATYPE_CHAR )
then
894 if( typeGet( ldtype ) = FB_DATATYPE_CHAR )
then
895 if( typeGet( rdtype ) = FB_DATATYPE_CHAR )
then
897 if( litsym <> NULL )
then
903 select case as const op
907 if( litsym <> NULL )
then
912 ldtype = typeUnsetIsConst( typeJoin( ldtype, FB_DATATYPE_STRING ) )
913 ldclass = FB_DATACLASS_STRING
914 rdtype = typeJoin( rdtype, ldtype )
922 case AST_OP_EQ, AST_OP_GT, AST_OP_LT, AST_OP_NE, AST_OP_LE, AST_OP_GE
924 if( litsym <> NULL )
then
932 ldtype = typeJoin( ldtype, astGetFullType(
l ) )
933 ldclass = FB_DATACLASS_INTEGER
934 rdtype = typeJoin( rdtype, astGetFullType( r ) )
935 rdclass = FB_DATACLASS_INTEGER
943 elseif( (typeGet( ldtype ) = FB_DATATYPE_CHAR)
or _
944 (typeGet( rdtype ) = FB_DATATYPE_CHAR) )
then
948 if( typeGet( ldtype ) = FB_DATATYPE_CHAR )
then
950 if(
l->
class <> AST_NODECLASS_DEREF )
then
955 ldtype = typeJoin( ldtype, FB_DATATYPE_UBYTE )
959 if( r->
class <> AST_NODECLASS_DEREF )
then
962 rdtype = typeJoin( rdtype, FB_DATATYPE_UBYTE )
1002 if( (env.clopt.lang <> FB_LANG_QB)
and (is_str =
FALSE) )
then
1003 intrank = typeGetIntRank( FB_DATATYPE_INTEGER )
1004 uintrank = typeGetIntRank( FB_DATATYPE_UINT )
1007 if( ldclass = FB_DATACLASS_INTEGER )
then
1008 lrank = typeGetIntRank( typeGetRemapType( ldtype ) )
1011 if( lrank < intrank )
then
1015 if( (intrank < lrank)
and (lrank < uintrank) )
then
1026 if( rdclass = FB_DATACLASS_INTEGER )
then
1027 rrank = typeGetIntRank( typeGetRemapType( rdtype ) )
1030 if( rrank < intrank )
then
1031 hConvOperand( FB_DATATYPE_INTEGER, rdtype, rdclass, r )
1033 if( (intrank < rrank)
and (rrank < uintrank) )
then
1041 select case as const op
1045 if( ldclass <> FB_DATACLASS_FPOINT )
then
1046 ldtype = typeJoin( ldtype, FB_DATATYPE_DOUBLE )
1048 ldclass = FB_DATACLASS_FPOINT
1051 if( rdclass <> FB_DATACLASS_FPOINT )
then
1052 rdtype = typeJoin( rdtype, FB_DATATYPE_DOUBLE )
1054 if( irGetOption( IR_OPT_FPUCONV ) )
then
1058 if( (r->
class <> AST_NODECLASS_VAR)
or (rdtype <> FB_DATATYPE_INTEGER) )
then
1063 rdclass = FB_DATACLASS_FPOINT
1067 case AST_OP_AND, AST_OP_OR, AST_OP_XOR, AST_OP_EQV, AST_OP_IMP,
_
1068 AST_OP_INTDIV, AST_OP_MOD, AST_OP_SHL, AST_OP_SHR
1070 if( ldclass <> FB_DATACLASS_INTEGER )
then
1071 ldtype = typeJoin( ldtype, FB_DATATYPE_INTEGER )
1073 ldclass = FB_DATACLASS_INTEGER
1076 if( rdclass <> FB_DATACLASS_INTEGER )
then
1077 rdtype = typeJoin( rdtype, FB_DATATYPE_INTEGER )
1079 rdclass = FB_DATACLASS_INTEGER
1083 case AST_OP_ATAN2, AST_OP_POW
1085 if( ldclass <> FB_DATACLASS_FPOINT )
then
1086 ldtype = typeJoin( ldtype, FB_DATATYPE_DOUBLE )
1088 ldclass = FB_DATACLASS_FPOINT
1091 if( rdclass <> FB_DATACLASS_FPOINT )
then
1092 rdtype = typeJoin( rdtype, FB_DATATYPE_DOUBLE )
1094 rdclass = FB_DATACLASS_FPOINT
1101 if( ldtype <> rdtype )
then
1104 if( (typeIsPtr( ldtype )
or typeIsPtr( rdtype ))
and _
1105 ((
op = AST_OP_ADD)
or (
op = AST_OP_SUB)) )
then
1107 if( typeIsPtr( ldtype ) )
then
1109 subtype =
l->subtype
1112 subtype = r->subtype
1118 typeMax( ldtype,
l->subtype, rdtype, r->subtype, dtype, subtype )
1120 if( (typeGetDtAndPtrOnly( dtype ) <> typeGetDtAndPtrOnly( ldtype ))
or _
1121 (subtype <>
l->subtype) )
then
1123 if(
l = NULL )
then exit function
1125 ldclass = typeGetClass( dtype )
1128 if( (typeGetDtAndPtrOnly( dtype ) <> typeGetDtAndPtrOnly( rdtype ))
or _
1129 (subtype <> r->subtype) )
then
1132 case AST_OP_SHL, AST_OP_SHR
1137 if( r = NULL )
then exit function
1140 rdclass = typeGetClass( dtype )
1147 subtype =
l->subtype
1151 select case as const op
1152 case AST_OP_EQ, AST_OP_GT, AST_OP_LT, AST_OP_NE, AST_OP_LE, AST_OP_GE,
_
1153 AST_OP_INTDIV, AST_OP_MOD, AST_OP_SHR
1155 dim as FB_WARNINGMSG warning = 0
1158 if( typeIsSigned( ldtype0 ) )
then
1159 if( typeIsSigned( ldtype ) =
FALSE )
then
1160 if( astIsConst(
l ) )
then
1162 if( astConstGetAsInt64(
l ) < 0 )
then
1164 warning = FB_WARNINGMSG_OPERANDSMIXEDSIGNEDNESS
1169 if( fbPdCheckIsSet( FB_PDCHECK_SIGNEDNESS ) )
then
1170 warning = FB_WARNINGMSG_OPERANDSMIXEDSIGNEDNESS
1177 if( (warning = 0)
andalso op <> AST_OP_SHR
andalso typeIsSigned( rdtype0 ) )
then
1178 if( typeIsSigned( rdtype ) =
FALSE )
then
1179 if( astIsConst( r ) )
then
1180 if( astConstGetAsInt64( r ) < 0 )
then
1182 warning = FB_WARNINGMSG_OPERANDSMIXEDSIGNEDNESS
1187 if( fbPdCheckIsSet( FB_PDCHECK_SIGNEDNESS ) )
then
1188 warning = FB_WARNINGMSG_OPERANDSMIXEDSIGNEDNESS
1194 if( warning <> 0 )
then
1201 select case as const op
1203 case AST_OP_EQ, AST_OP_GT, AST_OP_LT, AST_OP_NE, AST_OP_LE, AST_OP_GE,
_
1204 AST_OP_ANDALSO, AST_OP_ORELSE
1205 dtype = FB_DATATYPE_INTEGER
1209 case AST_OP_SHL, AST_OP_SHR
1210 if( astIsCONST( r ) )
then
1212 select case astConstGetAsInt64( r )
1213 case 0 to typeGetBits( ldtype )-1
1223 if( typeGetDtAndPtrOnly( rdtype ) <> FB_DATATYPE_INTEGER )
then
1224 if( typeGetDtAndPtrOnly( rdtype ) <> FB_DATATYPE_UINT )
then
1225 rdtype = typeJoin( rdtype, FB_DATATYPE_INTEGER )
1227 rdclass = FB_DATACLASS_INTEGER
1235 if( astIsCONST(
l )
and astIsCONST( r ) )
then
1238 astGetFullType(
l ) = dtype
1239 l->subtype = subtype
1245 elseif( astIsCONST(
l )
and ldtype = rdtype
and is_str =
FALSE )
then
1247 case AST_OP_ADD, AST_OP_MUL,
_
1248 AST_OP_AND, AST_OP_OR, AST_OP_XOR, AST_OP_EQV,
_
1249 AST_OP_EQ, AST_OP_NE
1283 elseif( astIsCONST( r ) )
then
1287 if(
l->
class = AST_NODECLASS_OFFSET )
then
1291 l->ofs.ofs += r->
val.i
1299 if(
l->
class = AST_NODECLASS_OFFSET )
then
1301 l->ofs.ofs -= r->
val.i
1313 case AST_OP_INTDIV, AST_OP_MOD
1314 if( r->
val.i = 0 )
then
1320 if( r->
val.f = 2.0 )
then
1322 if(
l->
class = AST_NODECLASS_CONV )
then
1323 select case l->
l->
class
1324 case AST_NODECLASS_VAR, AST_NODECLASS_IDX,
_
1325 AST_NODECLASS_FIELD, AST_NODECLASS_DEREF
1329 ldtype = typeJoin( ldtype, astGetFullType(
l ) )
1333 select case l->
class
1334 case AST_NODECLASS_VAR, AST_NODECLASS_IDX,
_
1335 AST_NODECLASS_FIELD, AST_NODECLASS_DEREF
1341 if( typeGetClass( astGetDataType(
l ) ) <> FB_DATACLASS_FPOINT )
then
1356 select case as const op
1361 if( irGetOption( IR_OPT_NOINLINEOPS ) )
then
1367 select case typeGet( dtype )
1368 case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1374 select case typeGet( dtype )
1375 case FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
1380 case AST_OP_ANDALSO, AST_OP_ORELSE
1381 dim cmp_op
as integer
1382 dim cmp_constl
as ASTNODE
ptr
1383 dim cmp_constr
as ASTNODE
ptr
1387 if ldclass = FB_DATACLASS_FPOINT
then
1388 cmp_constl = astNewConstf(0.0, FB_DATATYPE_SINGLE)
1389 cmp_constr = astNewConstf(0.0, FB_DATATYPE_SINGLE)
1395 if op = AST_OP_ANDALSO
then
1402 r =
astNewBOP( AST_OP_NE, r, cmp_constr )
1404 if op = AST_OP_ANDALSO
then
1412 n =
astNewNode( AST_NODECLASS_BOP, dtype, subtype )
1421 if( env.clopt.backend = FB_BACKEND_GCC )
then
1422 options
or= AST_OPOPT_ALLOCRES
1425 n->
op.options = options
1431 #macro hDoSelfOpOverload
_
1437 dim as FBSYMBOL
ptr proc =
any
1438 dim as FB_ERRMSG err_num =
any
1440 proc = symbFindSelfBopOvlProc(
op,
l, r, @err_num )
1441 if( proc <> NULL )
then
1443 function = astBuildCall( proc,
l, r )
1446 if( err_num <> FB_ERRMSG_OK )
then
1457 byval op as integer,
_
1458 byval l as ASTNODE
ptr,
_
1459 byval r
as ASTNODE
ptr,
_
1460 byval ex
as FBSYMBOL
ptr,
_
1461 byval options
as AST_OPOPT
_
1467 hDoSelfOpOverload(
op,
l, r )
1470 op = astGetOpSelfVer(
op )
1474 dim as FBSYMBOL
ptr tmp =
any
1475 dim as ASTNODE
ptr ll =
any, lr =
any
1477 tmp =
symbAddTempVar( typeAddrOf( astGetFullType(
l ) ), astGetSubType(
l ) )
1481 if( ll = NULL )
then
1490 r, ex, options
or AST_OPOPT_ALLOCRES ) )
1492 if( lr = NULL )
then
1496 function = astNewLink( ll, lr )
1513 dim as ASTNODE
ptr l =
any, r =
any
1514 dim as integer op =
any
1515 dim as IRVREG
ptr v1 =
any, v2 =
any, vr =
any
1521 if( (
l = NULL)
or (r = NULL) )
then
1525 if(
l->
class = AST_NODECLASS_CONV )
then
1526 astUpdateCONVFD2FS(
l, n->dtype, TRUE )
1528 if( r->
class = AST_NODECLASS_CONV )
then
1529 astUpdateCONVFD2FS( r, n->dtype, TRUE )
1538 if( ast.doemit )
then
1540 if( (n->
op.options
and AST_OPOPT_ALLOCRES) <> 0 )
then
1541 vr = irAllocVREG( astGetDataType( n ), n->subtype )
1542 vr->vector = n->vector
1545 v1->vector = n->vector
1549 if( n->
op.ex <> NULL )
then
1551 irEmitBOP(
op, v1, v2, NULL, n->
op.ex )
1553 irEmitBOP(
op, v1, v2, vr, NULL )
1557 if( vr = NULL )
then