Skip to content

Commit

Permalink
add bit shift operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
EiichiroIto committed Jul 29, 2020
1 parent ec17899 commit 8677861
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions locale/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -796,3 +796,9 @@ msgstr "%n と %n の論理和"
msgid "%n bitxor %n"
msgstr "%n と %n の排他的論理和"

msgid "%n bit shift left %n"
msgstr "%n の %n ビット左シフト"

msgid "%n bit shift right %n"
msgstr "%n の %n ビット右シフト"

6 changes: 6 additions & 0 deletions locale/ja_HIRA.po
Original file line number Diff line number Diff line change
Expand Up @@ -796,3 +796,9 @@ msgstr "%n と %n のろんりわ"
msgid "%n bitxor %n"
msgstr "%n と %n のはいたてきろんりわ"

msgid "%n bit shift left %n"
msgstr "%n の %n ビットひだりシフト"

msgid "%n bit shift right %n"
msgstr "%n の %n ビットみぎシフト"

Binary file modified microwitch.image
Binary file not shown.
2 changes: 1 addition & 1 deletion src/add bit operations.cs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 29 July 2020 at 10:42:38 am'!!MicrobitCode methodsFor: 'operators blocks' stamp: 'EiichiroIto 7/29/2020 10:37'!xbitandY: aMorph ^ self binary: ' & ' morph: aMorph.! !!MicrobitCode methodsFor: 'operators blocks' stamp: 'EiichiroIto 7/29/2020 10:37'!xbitorY: aMorph ^ self binary: ' | ' morph: aMorph.! !!MicrobitCode methodsFor: 'operators blocks' stamp: 'EiichiroIto 7/29/2020 10:38'!xbitxorY: aMorph ^ self binary: ' ^ ' morph: aMorph.! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 10:32'!x: x bitandY: y ^ x bitAnd: y! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 10:33'!x: x bitorY: y ^ x bitOr: y! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 10:35'!x: x bitxorY: y ^ x bitXor: y! !!ScriptableScratchMorph class methodsFor: 'microwitch'!operatorsBlocks ^ #( 'operators' ('%n + %n' r x:plusY: - -) ('%n - %n' r x:minusY: - -) ('%n * %n' r x:mulY: - -) ('%n / %n' r x:divY: - -) ('%n mod %n' r x:modY: - -) - ('pick random %n to %n' r randomFrom:to: 1 10) ('set random seed to %n' - setRandomSeed: 1234) - ('%s < %s' b less:than: '' '') ('%s = %s' b equal:to: '' '') ('%s > %s' b more:than: '' '') ('%n between %n and %n' b is:between:and: 5 1 10) ('%s is None' b isNone:) - ('%b and %b' b x:andY:) ('%b or %b' b x:orY:) ('not %b' b not:) ('true' b true) ('false' b false) - ('%n bitand %n' r x:bitandY: 2 6) ('%n bitor %n' r x:bitorY: 2 6) ('%n bitxor %n' r x:bitxorY: 2 6) - ('string of %n' r stringOf: 0) ('number of %s' r numberOf: '123') ('join %s %s' r concatenate:with: 'hello ' 'world') ('letter %n of %s' r letter:of: 0 'world') ('length of %s' r stringLength: 'world') ('any of %s' r anyOf: ) - ('round %n' r rounded -) ('abs %n' r abs -) ('abs %n sign %n' r abs:sign: - -) - ('%f of %n' r computeFunction:of: 'sqrt' 10) )! !
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 29 July 2020 at 12:31:41 pm'!!MicrobitCode methodsFor: 'operators blocks'!xbitShiftLeft: aMorph | args a b | args := aMorph blockArgs. a := args first argString: generator. b := args second argString: generator. ^ '(int(', a, ') << int(', b, '))'! !!MicrobitCode methodsFor: 'operators blocks'!xbitShiftRight: aMorph | args a b | args := aMorph blockArgs. a := args first argString: generator. b := args second argString: generator. ^ '(int(', a, ') >> int(', b, '))'! !!MicrobitCode methodsFor: 'operators blocks' stamp: 'EiichiroIto 7/29/2020 10:37'!xbitandY: aMorph ^ self binary: ' & ' morph: aMorph.! !!MicrobitCode methodsFor: 'operators blocks' stamp: 'EiichiroIto 7/29/2020 10:37'!xbitorY: aMorph ^ self binary: ' | ' morph: aMorph.! !!MicrobitCode methodsFor: 'operators blocks' stamp: 'EiichiroIto 7/29/2020 10:38'!xbitxorY: aMorph ^ self binary: ' ^ ' morph: aMorph.! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 12:25'!x: x bitShiftLeft: y ^ x << y! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 12:25'!x: x bitShiftRight: y ^ x >> y! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 10:32'!x: x bitandY: y ^ x bitAnd: y! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 10:33'!x: x bitorY: y ^ x bitOr: y! !!ScriptableScratchMorph methodsFor: 'microwitch' stamp: 'EiichiroIto 7/29/2020 10:35'!x: x bitxorY: y ^ x bitXor: y! !!ScriptableScratchMorph class methodsFor: 'microwitch'!operatorsBlocks ^ #( 'operators' ('%n + %n' r x:plusY: - -) ('%n - %n' r x:minusY: - -) ('%n * %n' r x:mulY: - -) ('%n / %n' r x:divY: - -) ('%n mod %n' r x:modY: - -) - ('pick random %n to %n' r randomFrom:to: 1 10) ('set random seed to %n' - setRandomSeed: 1234) - ('%s < %s' b less:than: '' '') ('%s = %s' b equal:to: '' '') ('%s > %s' b more:than: '' '') ('%n between %n and %n' b is:between:and: 5 1 10) ('%s is None' b isNone:) - ('%b and %b' b x:andY:) ('%b or %b' b x:orY:) ('not %b' b not:) ('true' b true) ('false' b false) - ('%n bitand %n' r x:bitandY: 2 6) ('%n bitor %n' r x:bitorY: 2 6) ('%n bitxor %n' r x:bitxorY: 2 6) ('%n bit shift left %n' r x:bitShiftLeft: 1 5) ('%n bit shift right %n' r x:bitShiftRight: 256 6) - ('string of %n' r stringOf: 0) ('number of %s' r numberOf: '123') ('join %s %s' r concatenate:with: 'hello ' 'world') ('letter %n of %s' r letter:of: 0 'world') ('length of %s' r stringLength: 'world') ('any of %s' r anyOf: ) - ('round %n' r rounded -) ('abs %n' r abs -) ('abs %n sign %n' r abs:sign: - -) - ('%f of %n' r computeFunction:of: 'sqrt' 10) )! !
Expand Down
2 changes: 1 addition & 1 deletion src/microwitch.changes

Large diffs are not rendered by default.

0 comments on commit 8677861

Please sign in to comment.