Changeset 25739

Show
Ignore:
Timestamp:
12/03/08 11:23:47 (4 years ago)
Author:
fujidig
Message:

* [25644] の修正がだいぶ間違っていたので修正(変数の型と右辺値の型をチェックしても意味がない;一次元のとき配列を拡張していなかった)
* StructArray#newmod? で expand メソッドを使うまでもなさそうだったので修正

Location:
lang/javascript/hsp-on-js/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/hsp-on-js/trunk/src/evaluator.js

    r25644 r25739  
    177177                                } 
    178178                        } else { 
     179                                // 比較演算は必ず int 型の値が返ってくることに依存 
    179180                                push('var variable = '+variableExpr+';'); 
    180181                                if(indicesCount == 0) { 
    181                                         push('if(variable.value.getType() != arg.getType()) variable.reset(arg.getType());'); 
     182                                        push('if(variable.value.getType() != '+VarType.INT+') variable.reset('+VarType.INT+');'); 
    182183                                        push('variable.value.assign(0, variable.value.at(0).'+operateMethodNames[calcCode]+'(arg));'); 
    183184                                } else if(indicesCount == 1) { 
    184185                                        push('var offset = self.scanArg(stack.pop(), "i").toIntValue()._value;'); 
    185                                         push('if(variable.value.getType() != arg.getType()) {'); 
     186                                        push('if(variable.value.getType() != '+VarType.INT+') {'); 
    186187                                        push('    if(offset == 0) {'); 
    187                                         push('        variable.reset(arg.getType());'); 
     188                                        push('        variable.reset('+VarType.INT+');'); 
    188189                                        push('    } else {'); 
    189190                                        push('        throw new HSPError(ErrorCode.INVALID_ARRAYSTORE);'); 
    190191                                        push('    }'); 
    191192                                        push('}'); 
     193                                        push('variable.value.expand1D(offset);'); 
    192194                                        push('variable.value.assign(offset, variable.value.at(offset).'+operateMethodNames[calcCode]+'(arg));'); 
    193195                                } else { 
     
    197199                                        push('array.expand(indices);'); 
    198200                                        push('var offset = array.getOffset(indices);'); 
    199                                         push('if(array.getType() != arg.getType()) {'); 
     201                                        push('if(array.getType() != '+VarType.INT+') {'); 
    200202                                        push('    if(offset == 0) {'); 
    201                                         push('        variable.reset(arg.getType());'); 
     203                                        push('        variable.reset('+VarType.INT+');'); 
    202204                                        push('        array = variable.value;'); 
    203205                                        push('        array.expand(indices);'); 
  • lang/javascript/hsp-on-js/trunk/src/struct-array.js

    r24973 r25739  
    4848                        } 
    4949                } 
    50                 if(index == len) this.expand([len]); 
     50                if(index == len) ++ this.l0; 
    5151                this.searchFrom = index + 1; 
    5252                var members = [];