Class ToItemCompiler

    • Constructor Detail

      • ToItemCompiler

        public ToItemCompiler()
    • Method Detail

      • compileToBoolean

        public void compileToBoolean​(CompilerService compiler,
                                     Expression expression)
                              throws CannotCompileException
        Description copied from class: ExpressionCompiler
        Generate bytecode to evaluate the expression as a boolean Precondition: none. Postcondition: at execution time, the stack contains an integer (0=false, 1=true) representing the result of the expression
        Specified by:
        compileToBoolean in class ExpressionCompiler
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
        Throws:
        CannotCompileException - if the expression cannot be compiled to bytecode
      • compileToPush

        public void compileToPush​(CompilerService compiler,
                                  Expression expression)
                           throws CannotCompileException
        Description copied from class: ExpressionCompiler
        Generate bytecode to evaluate the expression in push mode Precondition: none. Postcondition: at execution time, the stack is unchanged, and the value of the expression has been written to the current receiver
        Specified by:
        compileToPush in class ExpressionCompiler
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
        Throws:
        CannotCompileException - if the expression cannot be compiled to bytecode
      • returnZeroLengthStringIfNull

        protected void returnZeroLengthStringIfNull​(Expression arg,
                                                    Generator ga,
                                                    GeneratedMethodInfo methodInfo,
                                                    LabelInfo returnLabel,
                                                    int extraPops)
        Utility method for use by subclasses to generate code that causes an empty string to be returned if the first argument is an empty sequence. Precondition: the value of the first argument is on the stack, either as a string or as an item Postcondition: either the control has jumped to the return label with a zero-length string on the stack, or control drops through with the value of the first argument still on the stack (as supplied).
        Parameters:
        arg - the first argument
        ga - the Generator
        methodInfo - the method information
        returnLabel - the label to jump to on completion
        extraPops - items (other than the string being tested) that need to be popped of the stack if jumping to the return label