compileCalculateAndAddIndexToReg(opts) {
        let program = this._program;
        let scope   = this._scope;
        scope.incStackOffset();
        if (this._compiler.getRangeCheck()) {
            // Compile with range checking...
            program
                .addCommand(
                    $.CMD_SET, $.T_NUM_L, scope.getStackOffset(), opts.paramType, opts.indexIdentifier.getOffset(),
                    $.CMD_SET, $.T_NUM_G, $.REG_RANGE0,           $.T_NUM_C,      opts.maxArraySize,
                    $.CMD_SET, $.T_NUM_G, $.REG_RANGE1,           $.T_NUM_L,      scope.getStackOffset(),
                    $.CMD_MOD, $.T_NUM_C, 0,                      $.T_NUM_C,      0
                )
                .addInfoToLastCommand({token: opts.indexToken, scope: this._scope})
                .addCommand(
                    $.CMD_MUL, $.T_NUM_L, scope.getStackOffset(), $.T_NUM_C, opts.arraySize,
                    $.CMD_ADD, $.T_NUM_G, opts.reg,               $.T_NUM_L, scope.getStackOffset()
                );
        } else {
            // Add to offset: offset = [local] * arraySize
            program.addCommand(
                $.CMD_SET, $.T_NUM_L, scope.getStackOffset(), opts.paramType, opts.indexIdentifier.getOffset(),
                $.CMD_MUL, $.T_NUM_L, scope.getStackOffset(), $.T_NUM_C,      opts.arraySize,
                $.CMD_ADD, $.T_NUM_G, opts.reg,               $.T_NUM_L,      scope.getStackOffset()
            );
        }
        scope.decStackOffset();
    }
/**
     * Multiply the index with the array size and add to the register...
    **/
Multiply the index with the array size and add to the register
Multiply the index with the array size and add to the register
compileCalculateAndAddIndexToReg(opts) {
        let program = this._program;
        let scope   = this._scope;
        scope.incStackOffset();
        if (this._compiler.getRangeCheck()) {
            program
                .addCommand(
                    $.CMD_SET, $.T_NUM_L, scope.getStackOffset(), opts.paramType, opts.indexIdentifier.getOffset(),
                    $.CMD_SET, $.T_NUM_G, $.REG_RANGE0,           $.T_NUM_C,      opts.maxArraySize,
                    $.CMD_SET, $.T_NUM_G, $.REG_RANGE1,           $.T_NUM_L,      scope.getStackOffset(),
                    $.CMD_MOD, $.T_NUM_C, 0,                      $.T_NUM_C,      0
                )
                .addInfoToLastCommand({token: opts.indexToken, scope: this._scope})
                .addCommand(
                    $.CMD_MUL, $.T_NUM_L, scope.getStackOffset(), $.T_NUM_C, opts.arraySize,
                    $.CMD_ADD, $.T_NUM_G, opts.reg,               $.T_NUM_L, scope.getStackOffset()
                );
        } else {
            program.addCommand(
                $.CMD_SET, $.T_NUM_L, scope.getStackOffset(), opts.paramType, opts.indexIdentifier.getOffset(),
                $.CMD_MUL, $.T_NUM_L, scope.getStackOffset(), $.T_NUM_C,      opts.arraySize,
                $.CMD_ADD, $.T_NUM_G, opts.reg,               $.T_NUM_L,      scope.getStackOffset()
            );
        }
        scope.decStackOffset();
    }
compileCalculateAndAddIndexToReg ( opts ) { let program = this . _program ; let scope = this . _scope ; scope . incStackOffset ( ) ; if ( this . _compiler . getRangeCheck ( ) ) { program . addCommand ( $ . CMD_SET , $ . T_NUM_L , scope . getStackOffset ( ) , opts . paramType , opts . indexIdentifier . getOffset ( ) , $ . CMD_SET , $ . T_NUM_G , $ . REG_RANGE0 , $ . T_NUM_C , opts . maxArraySize , $ . CMD_SET , $ . T_NUM_G , $ . REG_RANGE1 , $ . T_NUM_L , scope . getStackOffset ( ) , $ . CMD_MOD , $ . T_NUM_C , 0 , $ . T_NUM_C , 0 ) . addInfoToLastCommand ( { token : opts . indexToken , scope : this . _scope } ) . addCommand ( $ . CMD_MUL , $ . T_NUM_L , scope . getStackOffset ( ) , $ . T_NUM_C , opts . arraySize , $ . CMD_ADD , $ . T_NUM_G , opts . reg , $ . T_NUM_L , scope . getStackOffset ( ) ) ; } else { program . addCommand ( $ . CMD_SET , $ . T_NUM_L , scope . getStackOffset ( ) , opts . paramType , opts . indexIdentifier . getOffset ( ) , $ . CMD_MUL , $ . T_NUM_L , scope . getStackOffset ( ) , $ . T_NUM_C , opts . arraySize , $ . CMD_ADD , $ . T_NUM_G , opts . reg , $ . T_NUM_L , scope . getStackOffset ( ) ) ; } scope . decStackOffset ( ) ; }
Multiply the index with the array size and add to the register...
Multiply the index with the array size and add to the register ...
// Compile with range checking... // Add to offset: offset = [local] * arraySize