Class SimpleNodeConstructorCompiler

    • Constructor Detail

      • SimpleNodeConstructorCompiler

        public SimpleNodeConstructorCompiler()
    • Method Detail

      • 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
        Overrides:
        compileToPush in class ToIteratorCompiler
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
        Throws:
        CannotCompileException - if the expression cannot be compiled to bytecode
      • isNoNodeIfEmpty

        protected boolean isNoNodeIfEmpty​(Expression expr)
        Overridable method to ask whether no node should be produced in the case that the content is empty
        Returns:
        true if the rules for this instruction are that when the content is empty, no node is generated
      • checkContent

        protected void checkContent​(CompilerService compiler,
                                    Expression expression)
        Compile code to check the content of the node, and adjust it if necessary On entry the proposed content is on the stack as a UnicodeString; on exit the revised content must be on the stack as a UnicodeString.
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
      • compileNodeName

        protected void compileNodeName​(CompilerService compiler,
                                       Expression expression)
                                throws CannotCompileException
        Compile code to generate the node name (if any) and leave it on the top of the stack. For node kinds that are always unnamed (such as comments), the stack is not changed. For node kinds that may be named or unnamed (namespace nodes), an entry is always added to the stack, which will be "" if the particular node has no name.
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
        Throws:
        CannotCompileException - if the expression cannot be compiled to bytecode
      • pushNode

        protected abstract void pushNode​(CompilerService compiler,
                                         Expression expression)
        Generate code to write the node to the current receiver. On entry the stack holds the current receiver, the node name (for named node kinds only) and the content (for all nodes), in general as instances of UnicodeString
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
      • isNamedNodeKind

        protected boolean isNamedNodeKind()
        Ask whether this instruction generates a kind of node that is named
        Returns:
        true if the instruction generates a kind of node that is named
      • compileToItem

        public void compileToItem​(CompilerService compiler,
                                  Expression expression)
                           throws CannotCompileException
        Description copied from class: ExpressionCompiler
        Generate bytecode to evaluate the expression as an Item Precondition: none. Postcondition: at execution time, the stack contains either an item (the result of the expression), or null (representing an empty sequence).
        Overrides:
        compileToItem in class ToPushCompiler
        Parameters:
        compiler - the compiler service
        expression - the expression to be compiled
        Throws:
        CannotCompileException - if the expression cannot be compiled to bytecode