compileComplexTypeToRegister(opts, result) {
        let program = this._program;
        opts.lastToken = opts.expression.tokens.length - 1;
        while (opts.index <= opts.lastToken) {
            opts.token = opts.expression.tokens[opts.index];
            if (opts.identifier.getType) {
                this.setLastRecordType(opts.identifier.getType().type);
            }
            // Check if it's an object, a method call and if the self pointer needs to be saved on the stack...
            this.compileMethodCallSelfPointer(opts);
            if (opts.token.cls === t.TOKEN_BRACKET_OPEN) {
                result.arrayIndex = true;
                opts              = this.compileArrayIndex(opts, result);
            } else if ((opts.token.cls === t.TOKEN_PARENTHESIS_OPEN) && (opts.identifier instanceof Proc)) {
                this.compileProcCall(opts, result);
                helper.setStackOffsetToPtr(program, this._scope);
                opts.identifierType = {type: t.LEXEME_NUMBER, typePointer: false};
            } else if ((opts.token.cls === t.TOKEN_PARENTHESIS_OPEN) && (opts.identifier.getType().type === t.LEXEME_PROC)) {
                opts.callMethod = true;
                this.compileProcCall(opts, result);
                helper.setStackOffsetToPtr(program, this._scope);
                opts.identifierType = {type: t.LEXEME_NUMBER, typePointer: false};
                result.type         = t.LEXEME_NUMBER;
            } else if (opts.token.cls !== t.TOKEN_DOT) {
                throw errors.createError(err.SYNTAX_ERROR_DOT_EXPECTED, opts.token, '"." Expected got "' + opts.token.lexeme + '".');
            } else {
                helper.assertRecord(opts);
                this.setLastRecordType(opts.identifier.getType().type);
                opts.index++;
                opts.saveSelfPointer = (opts.selfPointerStackOffset !== false) && (opts.index === opts.lastToken);
                opts.typePointer     = opts.identifierType.typePointer;
                opts.identifier      = this.getFieldFromIndexToken(opts); // Get the next field from the expression...
                if (opts.identifier.getType().type instanceof Record) {
                    this.setLastRecordType(opts.identifier.getType().type);
                } else if (opts.identifier.getType().type === t.LEXEME_PROC) {
                    this._lastProcField = opts.identifier.getProc();
                }
                opts                 = this.compileAddFieldOffsetToReg(opts);
                opts.identifierType  = opts.identifier.getType();
                result.dataSize      = opts.identifier.getTotalSize();
                result.type          = opts.identifier;
            }
            opts.index++;
        }
        return result;
    }
/**
     * Compile a record or array or combination of both...
    **/
Compile a record or array or combination of both
Compile a record or array or combination of both
compileComplexTypeToRegister(opts, result) {
        let program = this._program;
        opts.lastToken = opts.expression.tokens.length - 1;
        while (opts.index <= opts.lastToken) {
            opts.token = opts.expression.tokens[opts.index];
            if (opts.identifier.getType) {
                this.setLastRecordType(opts.identifier.getType().type);
            }
            this.compileMethodCallSelfPointer(opts);
            if (opts.token.cls === t.TOKEN_BRACKET_OPEN) {
                result.arrayIndex = true;
                opts              = this.compileArrayIndex(opts, result);
            } else if ((opts.token.cls === t.TOKEN_PARENTHESIS_OPEN) && (opts.identifier instanceof Proc)) {
                this.compileProcCall(opts, result);
                helper.setStackOffsetToPtr(program, this._scope);
                opts.identifierType = {type: t.LEXEME_NUMBER, typePointer: false};
            } else if ((opts.token.cls === t.TOKEN_PARENTHESIS_OPEN) && (opts.identifier.getType().type === t.LEXEME_PROC)) {
                opts.callMethod = true;
                this.compileProcCall(opts, result);
                helper.setStackOffsetToPtr(program, this._scope);
                opts.identifierType = {type: t.LEXEME_NUMBER, typePointer: false};
                result.type         = t.LEXEME_NUMBER;
            } else if (opts.token.cls !== t.TOKEN_DOT) {
                throw errors.createError(err.SYNTAX_ERROR_DOT_EXPECTED, opts.token, '"." Expected got "' + opts.token.lexeme + '".');
            } else {
                helper.assertRecord(opts);
                this.setLastRecordType(opts.identifier.getType().type);
                opts.index++;
                opts.saveSelfPointer = (opts.selfPointerStackOffset !== false) && (opts.index === opts.lastToken);
                opts.typePointer     = opts.identifierType.typePointer;
                opts.identifier      = this.getFieldFromIndexToken(opts); 
                if (opts.identifier.getType().type instanceof Record) {
                    this.setLastRecordType(opts.identifier.getType().type);
                } else if (opts.identifier.getType().type === t.LEXEME_PROC) {
                    this._lastProcField = opts.identifier.getProc();
                }
                opts                 = this.compileAddFieldOffsetToReg(opts);
                opts.identifierType  = opts.identifier.getType();
                result.dataSize      = opts.identifier.getTotalSize();
                result.type          = opts.identifier;
            }
            opts.index++;
        }
        return result;
    }
compileComplexTypeToRegister ( opts , result ) { let program = this . _program ; opts . lastToken = opts . expression . tokens . length - 1 ; while ( opts . index <= opts . lastToken ) { opts . token = opts . expression . tokens [ opts . index ] ; if ( opts . identifier . getType ) { this . setLastRecordType ( opts . identifier . getType ( ) . type ) ; } this . compileMethodCallSelfPointer ( opts ) ; if ( opts . token . cls === t . TOKEN_BRACKET_OPEN ) { result . arrayIndex = true ; opts = this . compileArrayIndex ( opts , result ) ; } else if ( ( opts . token . cls === t . TOKEN_PARENTHESIS_OPEN ) && ( opts . identifier instanceof Proc ) ) { this . compileProcCall ( opts , result ) ; helper . setStackOffsetToPtr ( program , this . _scope ) ; opts . identifierType = { type : t . LEXEME_NUMBER , typePointer : false } ; } else if ( ( opts . token . cls === t . TOKEN_PARENTHESIS_OPEN ) && ( opts . identifier . getType ( ) . type === t . LEXEME_PROC ) ) { opts . callMethod = true ; this . compileProcCall ( opts , result ) ; helper . setStackOffsetToPtr ( program , this . _scope ) ; opts . identifierType = { type : t . LEXEME_NUMBER , typePointer : false } ; result . type = t . LEXEME_NUMBER ; } else if ( opts . token . cls !== t . TOKEN_DOT ) { throw errors . createError ( err . SYNTAX_ERROR_DOT_EXPECTED , opts . token , '"." Expected got "' + opts . token . lexeme + '".' ) ; } else { helper . assertRecord ( opts ) ; this . setLastRecordType ( opts . identifier . getType ( ) . type ) ; opts . index ++ ; opts . saveSelfPointer = ( opts . selfPointerStackOffset !== false ) && ( opts . index === opts . lastToken ) ; opts . typePointer = opts . identifierType . typePointer ; opts . identifier = this . getFieldFromIndexToken ( opts ) ; if ( opts . identifier . getType ( ) . type instanceof Record ) { this . setLastRecordType ( opts . identifier . getType ( ) . type ) ; } else if ( opts . identifier . getType ( ) . type === t . LEXEME_PROC ) { this . _lastProcField = opts . identifier . getProc ( ) ; } opts = this . compileAddFieldOffsetToReg ( opts ) ; opts . identifierType = opts . identifier . getType ( ) ; result . dataSize = opts . identifier . getTotalSize ( ) ; result . type = opts . identifier ; } opts . index ++ ; } return result ; }
Compile a record or array or combination of both...
Compile a record or array or combination of both ...
// Check if it's an object, a method call and if the self pointer needs to be saved on the stack... // Get the next field from the expression...