Class InstanceofComparison


public class InstanceofComparison extends BooleanExpr
Represents an instanceof comparison (or not instanceof)
  • Field Details

    • test

      public Test test
      The test to use
    • expr

      public Expression expr
      The expression to test
    • className

      public String className
      The class name to test against
    • truePath

      public BooleanExpr truePath
      The test to execute if this one is true
    • falsePath

      public BooleanExpr falsePath
      The test to execute if this one is false
  • Constructor Details

    • InstanceofComparison

      public InstanceofComparison(Test test, Expression expr, String className)
      Create an InstanceofComparison for a given test, expression and class name
      Parameters:
      test - The test to perform
      expr - The expression to test
      className - The class name to test against
    • InstanceofComparison

      public InstanceofComparison(Test test, Expression expr, String className, String filename, int lineNumber)
      Create an InstanceofComparison for a given test, expression and class name
      Parameters:
      test - The test to perform
      expr - The expression to test
      className - The class name to test against
      filename - The source filename this expression is associated with
      lineNumber - The source line number this expression is associated with
  • Method Details

    • invert

      public BooleanExpr invert()
      Description copied from class: BooleanExpr
      Invert this expression, which may involve reversing comparisons or changing and to or with inverted tests, etc.
      Specified by:
      invert in class BooleanExpr
      Returns:
      An inverted boolean expression
    • removeNot

      public BooleanExpr removeNot()
      Description copied from class: BooleanExpr
      Remove any not expressions from a tree of boolean expressions by inverting the expression under the not
      Specified by:
      removeNot in class BooleanExpr
      Returns:
      a BooleanExpr with any nested Not constructions removed
    • reset

      public void reset()
      Description copied from class: BooleanExpr
      Resets any values modified during code generation
      Overrides:
      reset in class BooleanExpr
    • computeSequence

      public BooleanExpr computeSequence(BooleanExpr trueNext, BooleanExpr falseNext, List<BooleanExpr> tests)
      Description copied from class: BooleanExpr
      Compute a sequence of tests to determine if this expression is true or false
      Specified by:
      computeSequence in class BooleanExpr
      Parameters:
      trueNext - The next expression to evaluate if this expression is true
      falseNext - The next expression to evaluate if this expression is false
      tests - An accumulator for the tests to be executed
      Returns:
      The beginning of the sequence
    • findCaptured

      public void findCaptured(Environment env)
      Identify any variables captured by the test expression
      Parameters:
      env - The environment chain to be searched
    • generate

      public void generate(ClassGenerator generator, Environment env, BooleanExpr next)
      Generate Java bytecode for this comparison
      Parameters:
      generator - The class generator that is generating the current class
      env - The environment containing all visible variables
      next - The next boolean expr in the chain