@@ -188,6 +188,12 @@ signature module Semantic {
188188
189189 class AddressType extends Type ;
190190
191+ /** Gets the type of an SSA variable. */
192+ Type getSsaType ( SsaVariable var ) ;
193+
194+ /** Gets the type of an expression. */
195+ Type getExprType ( Expr e ) ;
196+
191197 class SsaVariable {
192198 Expr getAUse ( ) ;
193199
@@ -285,24 +291,6 @@ signature module LangSig<Semantic Sem, DeltaSig D> {
285291 default predicate javaCompatibility ( ) { none ( ) }
286292}
287293
288- signature module UtilSig< Semantic Sem, DeltaSig DeltaParam> {
289- /**
290- * Gets the type used to track the specified source variable's range information.
291- *
292- * Usually, this just `e.getType()`, but the language can override this to track immutable boxed
293- * primitive types as the underlying primitive type.
294- */
295- Sem:: Type getTrackedTypeForSsaVariable ( Sem:: SsaVariable var ) ;
296-
297- /**
298- * Gets the type used to track the specified expression's range information.
299- *
300- * Usually, this just `e.getSemType()`, but the language can override this to track immutable boxed
301- * primitive types as the underlying primitive type.
302- */
303- Sem:: Type getTrackedType ( Sem:: Expr e ) ;
304- }
305-
306294signature module BoundSig< LocationSig Location, Semantic Sem, DeltaSig D> {
307295 class SemBound {
308296 string toString ( ) ;
@@ -326,11 +314,10 @@ signature module OverflowSig<Semantic Sem, DeltaSig D> {
326314module RangeStage<
327315 LocationSig Location, Semantic Sem, DeltaSig D, BoundSig< Location , Sem , D > Bounds,
328316 OverflowSig< Sem , D > OverflowParam, LangSig< Sem , D > LangParam, SignAnalysisSig< Sem > SignAnalysis,
329- ModulusAnalysisSig< Sem > ModulusAnalysisParam, UtilSig < Sem , D > UtilParam >
317+ ModulusAnalysisSig< Sem > ModulusAnalysisParam>
330318{
331319 private import Bounds
332320 private import LangParam
333- private import UtilParam
334321 private import D
335322 private import OverflowParam
336323 private import SignAnalysis
@@ -375,8 +362,8 @@ module RangeStage<
375362 */
376363 private class SafeCastExpr extends ConvertOrBoxExpr {
377364 SafeCastExpr ( ) {
378- Sem:: conversionCannotOverflow ( getTrackedType ( pragma [ only_bind_into ] ( this .getOperand ( ) ) ) ,
379- pragma [ only_bind_out ] ( getTrackedType ( this ) ) )
365+ Sem:: conversionCannotOverflow ( Sem :: getExprType ( pragma [ only_bind_into ] ( this .getOperand ( ) ) ) ,
366+ pragma [ only_bind_out ] ( Sem :: getExprType ( this ) ) )
380367 }
381368 }
382369
@@ -386,14 +373,14 @@ module RangeStage<
386373 private class NarrowingCastExpr extends ConvertOrBoxExpr {
387374 NarrowingCastExpr ( ) {
388375 not this instanceof SafeCastExpr and
389- typeBound ( getTrackedType ( this ) , _, _)
376+ typeBound ( Sem :: getExprType ( this ) , _, _)
390377 }
391378
392379 /** Gets the lower bound of the resulting type. */
393- float getLowerBound ( ) { typeBound ( getTrackedType ( this ) , result , _) }
380+ float getLowerBound ( ) { typeBound ( Sem :: getExprType ( this ) , result , _) }
394381
395382 /** Gets the upper bound of the resulting type. */
396- float getUpperBound ( ) { typeBound ( getTrackedType ( this ) , _, result ) }
383+ float getUpperBound ( ) { typeBound ( Sem :: getExprType ( this ) , _, result ) }
397384 }
398385
399386 cached
@@ -556,8 +543,8 @@ module RangeStage<
556543 ) and
557544 (
558545 if
559- getTrackedTypeForSsaVariable ( v ) instanceof Sem:: IntegerType or
560- getTrackedTypeForSsaVariable ( v ) instanceof Sem:: AddressType
546+ Sem :: getSsaType ( v ) instanceof Sem:: IntegerType or
547+ Sem :: getSsaType ( v ) instanceof Sem:: AddressType
561548 then
562549 upper = true and strengthen = - 1
563550 or
@@ -666,7 +653,7 @@ module RangeStage<
666653 private predicate unequalFlowStepIntegralSsa (
667654 Sem:: SsaVariable v , SsaReadPosition pos , Sem:: Expr e , D:: Delta delta , SemReason reason
668655 ) {
669- getTrackedTypeForSsaVariable ( v ) instanceof Sem:: IntegerType and
656+ Sem :: getSsaType ( v ) instanceof Sem:: IntegerType and
670657 exists ( Sem:: Guard guard , boolean testIsTrue |
671658 pos .hasReadOfVar ( v ) and
672659 guard = eqFlowCond ( v , e , delta , false , testIsTrue ) and
@@ -677,12 +664,12 @@ module RangeStage<
677664
678665 /** Holds if `e >= 1` as determined by sign analysis. */
679666 private predicate strictlyPositiveIntegralExpr ( Sem:: Expr e ) {
680- semStrictlyPositive ( e ) and getTrackedType ( e ) instanceof Sem:: IntegerType
667+ semStrictlyPositive ( e ) and Sem :: getExprType ( e ) instanceof Sem:: IntegerType
681668 }
682669
683670 /** Holds if `e <= -1` as determined by sign analysis. */
684671 private predicate strictlyNegativeIntegralExpr ( Sem:: Expr e ) {
685- semStrictlyNegative ( e ) and getTrackedType ( e ) instanceof Sem:: IntegerType
672+ semStrictlyNegative ( e ) and Sem :: getExprType ( e ) instanceof Sem:: IntegerType
686673 }
687674
688675 /**
@@ -764,7 +751,7 @@ module RangeStage<
764751 * therefore only valid for non-negative numbers.
765752 */
766753 private predicate boundFlowStepDiv ( Sem:: Expr e2 , Sem:: Expr e1 , D:: Delta factor ) {
767- getTrackedType ( e2 ) instanceof Sem:: IntegerType and
754+ Sem :: getExprType ( e2 ) instanceof Sem:: IntegerType and
768755 exists ( Sem:: ConstantIntegerExpr c , D:: Delta k |
769756 k = D:: fromInt ( c .getIntValue ( ) ) and D:: toFloat ( k ) > 0
770757 |
@@ -1101,7 +1088,7 @@ module RangeStage<
11011088 (
11021089 expr instanceof Sem:: NegateExpr or
11031090 expr instanceof Sem:: PreDecExpr or
1104- getTrackedType ( expr .( Sem:: DivExpr ) ) instanceof Sem:: FloatingPointType
1091+ Sem :: getExprType ( expr .( Sem:: DivExpr ) ) instanceof Sem:: FloatingPointType
11051092 )
11061093 or
11071094 positively = true and
0 commit comments