Changeset 21137

Show
Ignore:
Timestamp:
10/11/08 21:17:13 (5 years ago)
Author:
fujidig
Message:

* dup 命令を実装。
* 配列に負数のインデックスを指定して代入したときにエラーが出なかったのを修正
* run-in-shell での命令列の出力をやめる

Location:
lang/javascript/hsp-on-js/trunk/src
Files:
1 added
9 modified

Legend:

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

    r20137 r21137  
    4242                                exponent = this.readBits(this.offset + precisionBits, exponentBits), significand = 0, 
    4343                                divisor = 2, curByte = this.buffer.length + (-precisionBits-this.offset >> 3) - 1, 
    44                                 byteValue, startBit, i; 
     44                                byteValue, startBit, mask; 
    4545                        this.offset += precisionBits + exponentBits + 1; 
    4646                        do 
  • lang/javascript/hsp-on-js/trunk/src/builtin-funcs.js

    r21095 r21137  
    161161                l3 = l3 ? l3.toIntValue()._value : 0; 
    162162                v.variable.dim(type, l0, l1, l2, l3); 
     163        }, 
     164        0x0e: function dup(dest, src) { 
     165                this.scanArgs(arguments, 'av'); 
     166                dest.variable.value = src.ref(); 
    163167        }, 
    164168        0x11: function stop() { 
  • lang/javascript/hsp-on-js/trunk/src/create-package

    r20799 r21137  
    3333str-buffer.js 
    3434hsp-array.js 
     35reference.js 
    3536label-array.js 
    3637str-array.js 
  • lang/javascript/hsp-on-js/trunk/src/hsp-array.js

    r20926 r21137  
    3535                        if(lastDimension > 3) throw new HSPError(ErrorCode.ARRAY_OVERFLOW); 
    3636                        l3 = indices[3] + 1; 
     37                } 
     38                switch(indices.length) { 
     39                case 4: 
     40                        if(indices[3] < 0) throw new HSPError(ErrorCode.ARRAY_OVERFLOW); 
     41                case 3: 
     42                        if(indices[2] < 0) throw new HSPError(ErrorCode.ARRAY_OVERFLOW); 
     43                case 2: 
     44                        if(indices[1] < 0) throw new HSPError(ErrorCode.ARRAY_OVERFLOW); 
     45                case 1: 
     46                        if(indices[0] < 0) throw new HSPError(ErrorCode.ARRAY_OVERFLOW); 
    3747                } 
    3848                this.l0 = l0; 
     
    110120                throw new HSPError(ErrorCode.TYPE_MISMATCH, 
    111121                                   VarTypeNames[this.getType()]+" 型はメモリ領域の拡張に対応していません");  
     122        }, 
     123        ref: function ref(offset) { 
     124                return new Reference(this, offset); 
    112125        } 
    113126}; 
  • lang/javascript/hsp-on-js/trunk/src/run-in-shell

    r21061 r21137  
    3030str-buffer.js 
    3131hsp-array.js 
     32reference.js 
    3233label-array.js 
    3334str-array.js 
  • lang/javascript/hsp-on-js/trunk/src/run-in-shell.js

    r21061 r21137  
    2424        var sequence = compiler.compile(); 
    2525 
    26         sequence.forEach(function(insn){ 
     26/*      sequence.forEach(function(insn){ 
    2727                print(insn); 
    2828        }); 
     29*/ 
    2930 
    3031        var evaluator = new Evaluator(axdata, sequence); 
  • lang/javascript/hsp-on-js/trunk/src/t.hsp

    r21094 r21137  
    1 a = "abc\ndefg\nhijkl" 
    2 notesel a 
    3 noteadd "123" 
    4 noteadd "456" 
    5 noteadd "DEFG", 1, 1 
    6 notedel 0 
    7 repeat notemax + 2, -1 
    8         noteget ln, cnt 
    9         mes ""+cnt+": <"+ln+">" 
    10 loop 
     1a = 3 
     2dup b, a 
     3mes "b = "+b 
     4b = 5 
     5mes "a = "+a 
    116 
     7mes 
     8 
     9dup c, b 
     10c = 7 
     11mes "a = "+a 
     12mes "b = "+b 
     13mes "c = "+c 
     14 
     15mes 
     16 
     17a = 9.0 : b = 10 
     18mes "a = "+a 
     19mes "b = "+b 
     20mes "c = "+c 
  • lang/javascript/hsp-on-js/trunk/src/variable-agent.js

    r20926 r21137  
    105105                if(offset == null) throw new HSPError(ErrorCode.ARRAY_OVERFLOW); 
    106106                return this.variable.expandByteSize(offset, size); 
     107        }, 
     108        ref: function ref() { 
     109                var offset = this.variable.value.getOffset(this.indices); 
     110                if(offset == null) throw new HSPError(ErrorCode.ARRAY_OVERFLOW); 
     111                return this.variable.ref(offset); 
    107112        } 
    108113}; 
  • lang/javascript/hsp-on-js/trunk/src/variable.js

    r20926 r21137  
    9292        expandByteSize: function expandByteSize(offset, size) { 
    9393                return this.value.expandByteSize(offset, size); 
     94        }, 
     95        ref: function ref(offset) { 
     96                return this.value.ref(offset); 
    9497        } 
    9598};