public void emmitCode ( ByteBuffer buffer , WAMMachine machine , WAMCallPoint callPoint ) throws LinkageException { // Ensure that the size of the instruction listing does not exceed max int (highly unlikely). if ( sizeof ( ) > Integer . MAX_VALUE ) { throw new IllegalStateException ( "The instruction listing size exceeds Integer.MAX_VALUE." ) ; } // Used to keep track of the size of the emitted code, in bytes, as it is written. int length = 0 ; // Insert the compiled code into the byte code machine's code area. for ( WAMInstruction instruction : instructions ) { instruction . emmitCode ( buffer , machine ) ; length += instruction . sizeof ( ) ; } // Keep record of the machine that the code is hosted in, and the call point of the functor within the machine. this . machine = machine ; this . callPoint = callPoint ; // Record the fact that the code is now linked into a machine. this . status = LinkStatus . Linked ; }
Emmits the binary byte code for the clause into a machine writing into the specified byte array . The state of this clause is changed to Linked to indicate that it has been linked into a binary machine .