From f9ec6a2196a61956ae5cd783c5e63e635be805a2 Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 28 Feb 2019 21:14:17 +0000 Subject: [PATCH] fcl-passrc: fixed $warn identifier error --- compiler/packages/fcl-passrc/src/pscanner.pp | 4 +- compiler/packages/pastojs/src/fppas2js.pp | 56 +++++++++++++++----- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/compiler/packages/fcl-passrc/src/pscanner.pp b/compiler/packages/fcl-passrc/src/pscanner.pp index 85902c9..311f887 100644 --- a/compiler/packages/fcl-passrc/src/pscanner.pp +++ b/compiler/packages/fcl-passrc/src/pscanner.pp @@ -3273,10 +3273,8 @@ begin DoLog(mtWarning,nIllegalStateForWarnDirective,SIllegalStateForWarnDirective,[Identifier]); exit; end; - end; - - if Number>=0 then SetWarnMsgState(Number,State); + end; end; procedure TPascalScanner.HandleDefine(Param: String); diff --git a/compiler/packages/pastojs/src/fppas2js.pp b/compiler/packages/pastojs/src/fppas2js.pp index 4f5fbbc..c59c744 100644 --- a/compiler/packages/pastojs/src/fppas2js.pp +++ b/compiler/packages/pastojs/src/fppas2js.pp @@ -6749,9 +6749,7 @@ begin Result:=Call; exit; end; - eopAnd, - eopOr, - eopXor: + eopAnd: begin if aResolver<>nil then begin @@ -6767,19 +6765,49 @@ begin UseBitwiseOp:=(GetExpressionValueType(El.left,AContext)=jstNumber) or (GetExpressionValueType(El.right,AContext)=jstNumber); if UseBitwiseOp then - Case El.OpCode of - eopAnd : C:=TJSBitwiseAndExpression; - eopOr : C:=TJSBitwiseOrExpression; - eopXor : C:=TJSBitwiseXOrExpression; + C:=TJSBitwiseAndExpression + else + C:=TJSLogicalAndExpression; + end; + eopOr: + begin + if aResolver<>nil then + begin + UseBitwiseOp:=((LeftResolved.BaseType in btAllJSInteger) + or (RightResolved.BaseType in btAllJSInteger)); + if UseBitwiseOp + and ((LeftResolved.BaseType in [btIntDouble,btUIntDouble]) + or (RightResolved.BaseType in [btIntDouble,btUIntDouble])) then + aResolver.LogMsg(20190228220145,mtWarning,nBitWiseOperationsAre32Bit, + sBitWiseOperationsAre32Bit,[],El); end else - Case El.OpCode of - eopAnd : C:=TJSLogicalAndExpression; - eopOr : C:=TJSLogicalOrExpression; - eopXor : C:=TJSBitwiseXOrExpression; - else - DoError(20161024191234,nBinaryOpcodeNotSupported,sBinaryOpcodeNotSupported,['logical XOR'],El); - end; + UseBitwiseOp:=(GetExpressionValueType(El.left,AContext)=jstNumber) + or (GetExpressionValueType(El.right,AContext)=jstNumber); + if UseBitwiseOp then + C:=TJSBitwiseOrExpression + else + C:=TJSLogicalOrExpression; + end; + eopXor: + begin + if aResolver<>nil then + begin + UseBitwiseOp:=((LeftResolved.BaseType in btAllJSInteger) + or (RightResolved.BaseType in btAllJSInteger)); + if UseBitwiseOp + and ((LeftResolved.BaseType in [btIntDouble,btUIntDouble]) + or (RightResolved.BaseType in [btIntDouble,btUIntDouble])) then + aResolver.LogMsg(20190228220225,mtWarning,nBitWiseOperationsAre32Bit, + sBitWiseOperationsAre32Bit,[],El); + end + else + UseBitwiseOp:=(GetExpressionValueType(El.left,AContext)=jstNumber) + or (GetExpressionValueType(El.right,AContext)=jstNumber); + if UseBitwiseOp then + C:=TJSBitwiseXOrExpression + else + C:=TJSBitwiseXOrExpression; end; eopPower: begin