2015-06-26 15:49:08 +00:00
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
#include "Moo.moo".
|
2015-06-26 15:49:08 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
////////////////////////////////////////////////////////////////#
|
|
|
|
// MAIN
|
|
|
|
////////////////////////////////////////////////////////////////#
|
2015-06-26 15:49:08 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// TODO: use #define to define a class or use #class to define a class.
|
|
|
|
// use #extend to extend a class
|
|
|
|
// using #class for both feels confusing.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
extend Apex
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
extend SmallInteger
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method getTrue: anInteger
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
^anInteger + 9999.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method inc
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
^self + 1.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
class TestObject(Object)
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
2017-04-24 09:20:27 +00:00
|
|
|
var(#class) Q, R.
|
|
|
|
var(#classinst) t1, t2.
|
2015-06-26 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 14:06:07 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
class MyObject(TestObject)
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
2017-04-24 09:20:27 +00:00
|
|
|
var(#class) C, B, A.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method getTrue
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
^true.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method getTrue: anInteger
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
^ anInteger
|
|
|
|
}
|
2017-01-06 09:53:40 +00:00
|
|
|
method getFalse
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method yyy: aBlock
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
| a |
|
|
|
|
a := aBlock value.
|
|
|
|
^a + 99.
|
2015-07-10 14:06:07 +00:00
|
|
|
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//a := Moo.MyCOM.HashTable new.
|
2015-06-26 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method xxx: aBlock
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
| a |
|
|
|
|
a := self yyy: aBlock.
|
2019-06-27 08:06:33 +00:00
|
|
|
"KKKKKKKKKKKKKKKKKKKKKKKKKKKKK" dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
^a.
|
|
|
|
}
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) main2
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
| a b c sum |
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// //(10 add: 20) dump.
|
|
|
|
// (10 + 20) dump.
|
|
|
|
//
|
|
|
|
// a := 10 + 20 + 30.
|
|
|
|
// b := [:x :y | | t z | x := 20. b := 9. x := 10 + 20 ].
|
|
|
|
//
|
|
|
|
// (b value: 10 value: 20) dump.
|
|
|
|
//
|
|
|
|
// thisContext basicSize dump.
|
|
|
|
//
|
|
|
|
// (thisContext basicAt: (8 + 5)) dump.
|
|
|
|
//
|
|
|
|
// ^self.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
|
|
|
a := self new.
|
2019-06-27 06:29:09 +00:00
|
|
|
//a yourself.
|
|
|
|
//b := a getTrue; getFalse.
|
|
|
|
//b := a getTrue; getFalse; getTrue: 20 + 10.
|
|
|
|
//b := a getTrue; getFalse; getTrue: 20 + 10; getTrue: 90 + 20.
|
|
|
|
//b := 3 + 5 getTrue: 20; getTrue: 8 + 1; getTrue: 20; yourself.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
|
|
|
b := 3 + 5 inc getTrue: 20 + (30 getTrue: 20; yourself); yourself.
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//b := [:q | q ] value: a getTrue.
|
2015-06-26 15:49:08 +00:00
|
|
|
b dump.
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//^self.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// ////////////////////////////////////////////////////////////
|
|
|
|
// A := 99.
|
2015-06-26 15:49:08 +00:00
|
|
|
[:x :y | R := y. ] value: 10 value: 6.
|
|
|
|
R := R + 1.
|
|
|
|
R dump.
|
|
|
|
|
|
|
|
sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1))] ].
|
2019-06-27 06:29:09 +00:00
|
|
|
//sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1)) + (sum value: (n - 2))] ].
|
2015-06-26 15:49:08 +00:00
|
|
|
(sum value: R; value: 5) dump.
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//sum := [ :n | sum value: 5 ].
|
|
|
|
//sum value: 5.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
|
|
|
#[ 1 2 3] dump.
|
|
|
|
#[ 4 5 6] dump.
|
2019-06-27 08:06:33 +00:00
|
|
|
#(#abc:def: 2 "string is good" 3 4 #(5 6) #(7 #(8 9)) 10) dump.
|
2017-04-24 09:20:27 +00:00
|
|
|
#(#[] #[]) dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
a := #(#abc:def: -2 "string is good" 3 #[2 3 4] 4 #(5 6) #(7 #(8 #[4 56] "hello" 9)) 10 -93952 #self true false nil #thisContext #super).
|
|
|
|
a at: 3 put: "hello world"; dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
a := self new.
|
|
|
|
(a xxx: [888]) dump.
|
|
|
|
20 dump.
|
|
|
|
|
|
|
|
b := 0.
|
|
|
|
[ b < 9 ] whileTrue: [ b dump. b := b + 1 ].
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
"hello \t\u78966\u8765\u3456\u2723\x20\123world\uD57C\uB85C\uC6B0" dump.
|
|
|
|
C"\n" dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
#abc:def: dump.
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//a := (11 < 10) ifTrue: [5] ifFalse: [20].
|
|
|
|
//a dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) main55
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
|a b c|
|
|
|
|
|
|
|
|
self main2.
|
2019-06-27 06:29:09 +00:00
|
|
|
// b := 0.
|
|
|
|
// [ b < 5 ] whileTrue: [ b dump. b := b + 1 ].
|
2015-06-26 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) getTen
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
^10
|
|
|
|
}
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
2015-06-28 14:20:37 +00:00
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
// this sample demonstrates what happens when a block context returns to the origin"s caller
|
2019-06-27 06:29:09 +00:00
|
|
|
// after the caller has already returned.
|
2015-06-28 14:20:37 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) xxxx
|
2015-06-28 14:20:37 +00:00
|
|
|
{
|
|
|
|
| g1 g2 |
|
|
|
|
t1 dump.
|
|
|
|
t2 := [ |tmp| g1 := 50. g2 := 100. tmp := g1 + g2. tmp dump. ^tmp ].
|
|
|
|
(t1 < 100) ifFalse: [ ^self ].
|
|
|
|
|
|
|
|
t1 := t1 + 1.
|
|
|
|
self xxxx
|
|
|
|
}
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) yyyy
|
2015-06-28 14:20:37 +00:00
|
|
|
{
|
|
|
|
|c1|
|
|
|
|
t1 := 1.
|
|
|
|
c1 :=self xxxx.
|
|
|
|
888 dump.
|
|
|
|
999 dump.
|
|
|
|
^c1.
|
|
|
|
}
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) main66
|
2015-06-28 14:20:37 +00:00
|
|
|
{
|
|
|
|
self yyyy.
|
2019-06-27 06:29:09 +00:00
|
|
|
t2 := t2 value. // can t2 return? it should return somewhere into the method context of yyy. but it has already terminated
|
2015-06-28 14:20:37 +00:00
|
|
|
t2 dump.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) mainj
|
2015-06-28 14:20:37 +00:00
|
|
|
{
|
|
|
|
|k1|
|
|
|
|
t1 := 1.
|
|
|
|
self xxxx.
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
t2 := t2 value. // can t2 return? it should return somewhere into the method context of yyy. but it has already terminated
|
2015-06-28 14:20:37 +00:00
|
|
|
t2 dump.
|
|
|
|
}
|
2019-06-27 06:29:09 +00:00
|
|
|
// ----------------------------------------------------------------------
|
2015-06-28 14:20:37 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) main22
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
2015-06-29 13:52:40 +00:00
|
|
|
|a b c d e f g h i j k sum |
|
2015-06-26 15:49:08 +00:00
|
|
|
|
|
|
|
sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1))] ].
|
|
|
|
(sum value: 5) dump.
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
"-------------------------" dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
b := 0.
|
2015-06-28 14:20:37 +00:00
|
|
|
[ b < 2000 ] whileTrue: [ b dump. b := b + 1 ].
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
"-------------------------" dump.
|
2015-06-28 14:20:37 +00:00
|
|
|
b := 0.
|
|
|
|
[ b < 10 ] whileTrue: [ b dump. b := b + 1 ].
|
2015-06-26 15:49:08 +00:00
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
"-------------------------" dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
a := #[4 5 6 7] at: 3.
|
|
|
|
(#[3 2 1] at: 3) dump.
|
|
|
|
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// thisContext value. // the message value must be unresolvable as thisContext is a method context
|
|
|
|
// [thisContext value] value.
|
2019-06-27 08:06:33 +00:00
|
|
|
"-------------------------" dump.
|
2015-06-26 15:49:08 +00:00
|
|
|
b := 0.
|
|
|
|
[ b := b + 1. b dump. thisContext value] value.
|
|
|
|
|
|
|
|
[self getTen] value dump.
|
|
|
|
}
|
2015-06-28 14:20:37 +00:00
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/*method(#class) abc
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
2015-10-14 13:25:36 +00:00
|
|
|
<primitive: #snd_open>
|
2019-06-19 12:38:09 +00:00
|
|
|
}*/
|
2015-10-08 14:26:04 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) a: a b: b c: c
|
2015-12-27 10:19:36 +00:00
|
|
|
{
|
|
|
|
c dump.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) a: a b: b c: c d: d e: e f: f g: g h: h
|
2015-12-27 10:19:36 +00:00
|
|
|
{
|
|
|
|
h dump.
|
|
|
|
}
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) a: a b: b c: c d: d e: e f: f g: g
|
2015-12-27 10:19:36 +00:00
|
|
|
{
|
|
|
|
g dump.
|
|
|
|
}
|
2016-01-29 04:04:39 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) getABlock
|
2016-01-29 04:04:39 +00:00
|
|
|
{
|
2019-06-27 08:06:33 +00:00
|
|
|
^ [ "a block returned by getABlock" dump. "^ self"]
|
2016-01-29 04:04:39 +00:00
|
|
|
}
|
|
|
|
|
2018-12-20 16:08:56 +00:00
|
|
|
|
|
|
|
method(#class) test_ffi
|
2015-10-03 15:29:03 +00:00
|
|
|
{
|
2015-10-14 13:25:36 +00:00
|
|
|
| ffi |
|
2019-06-27 08:06:33 +00:00
|
|
|
ffi := FFI new: "libc.so.6".
|
2015-10-14 13:25:36 +00:00
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
// ffi call: #printf with: #((str "%d") (int 10) (long 20)).
|
2019-08-09 18:19:13 +00:00
|
|
|
ffi call: #printf signature: "s|ici>i" arguments: #("hello world %d %c %d\n" 11123 $X 9876543).
|
|
|
|
//ffi call: #puts signature: "s>i" arguments: #("hello world").
|
2015-10-14 13:25:36 +00:00
|
|
|
ffi close.
|
2018-12-20 16:08:56 +00:00
|
|
|
}
|
2015-10-30 15:36:37 +00:00
|
|
|
|
2018-12-20 16:08:56 +00:00
|
|
|
method(#class) main
|
|
|
|
{
|
2019-06-27 06:29:09 +00:00
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// getABlock has returned.
|
2019-06-27 08:06:33 +00:00
|
|
|
// aBlock"s home context is getABlock. getABlock has returned
|
|
|
|
// when "aBlock value" is executed. so when aBlock is really
|
2019-06-27 06:29:09 +00:00
|
|
|
// executed, ^self is a double return attempt. should this be made
|
|
|
|
// illegal??
|
2016-01-29 04:04:39 +00:00
|
|
|
|aBlock|
|
|
|
|
aBlock := self getABlock.
|
|
|
|
aBlock value.
|
2019-06-27 06:29:09 +00:00
|
|
|
// ---------------------------------------------------------------
|
2016-01-29 04:04:39 +00:00
|
|
|
|
2018-12-20 16:08:56 +00:00
|
|
|
self test_ffi.
|
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/* -----------------------------
|
2015-10-30 15:36:37 +00:00
|
|
|
PROCESS TESTING
|
2015-10-18 15:06:17 +00:00
|
|
|
| p |
|
2019-06-27 08:06:33 +00:00
|
|
|
"000000000000000000" dump.
|
|
|
|
// p := [ | "xxxxxxxxxxx" dump. "yyyyyyyyyy" dump. ^10. ] newProcess.
|
2015-10-22 02:47:25 +00:00
|
|
|
p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(abc def 10 20).
|
2019-06-27 08:06:33 +00:00
|
|
|
"999999999999999999" dump.
|
2015-10-18 15:06:17 +00:00
|
|
|
p resume.
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
"111111111111111111" dump.
|
|
|
|
"222222222222222222" dump.
|
|
|
|
"333333333333333333" dump.
|
|
|
|
"444444444444444444" dump.
|
2019-06-19 12:38:09 +00:00
|
|
|
---------------------------- */
|
2018-12-20 16:08:56 +00:00
|
|
|
|
2015-12-02 15:24:13 +00:00
|
|
|
|
|
|
|
|
2015-10-30 15:36:37 +00:00
|
|
|
(-2305843009213693952 - 1) dump.
|
2015-11-11 13:31:05 +00:00
|
|
|
|
2015-11-12 06:57:35 +00:00
|
|
|
(1 + 2) dump.
|
2019-06-27 06:29:09 +00:00
|
|
|
//(-2305843009213693952 * 2305843009213693952) dump.
|
|
|
|
// (((-2305843009213693952 - 10) * (-2305843009213693952 - 10) *(-2305843009213693952 - 10) * (-2305843009213693952 - 10) * 255) * ((-2305843009213693952 - 10) * (-2305843009213693952 - 10) *(-2305843009213693952 - 10) * (-2305843009213693952 - 10) * 255)) dump.
|
|
|
|
//((-2305843009213693952 - 10) * (-2305843009213693952 - 10) *(-2305843009213693952 - 10) * (-2305843009213693952 - 10) * 255) dump.
|
2015-11-12 06:57:35 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(-16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF * 1) dump.
|
|
|
|
//((-2305843009213693952 * -1) - 1 + 2) dump.
|
2015-11-13 15:55:56 +00:00
|
|
|
((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) dump.
|
2015-11-20 09:05:55 +00:00
|
|
|
|
2015-11-17 14:13:59 +00:00
|
|
|
|
|
|
|
(2r111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 * 128971234897128931) dump.
|
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/* (-10000 rem: 3) dump.
|
2018-12-20 16:08:56 +00:00
|
|
|
(-10000 mod: 3) dump.
|
|
|
|
(-10000 div: 3) dump.
|
2019-06-19 12:38:09 +00:00
|
|
|
(-10000 mdiv: 3) dump. */
|
2018-12-20 16:08:56 +00:00
|
|
|
|
2015-11-22 14:48:09 +00:00
|
|
|
(7 rem: -3) dump.
|
2018-12-20 16:08:56 +00:00
|
|
|
(7 mod: -3) dump.
|
|
|
|
(7 div: -3) dump.
|
|
|
|
(7 mdiv: -3) dump.
|
2015-11-22 13:32:06 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(777777777777777777777777777777777777777777777777777777777777777777777 rem: -8127348917239812731289371289731298) dump.
|
|
|
|
//(777777777777777777777777777777777777777777777777777777777777777777777 div: -8127348917239812731289371289731298) dump.
|
2015-11-30 14:29:57 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
|
|
|
//(270000000000000000000000000000000000000000000000000000000000000000000 div: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
|
|
|
//(270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
|
|
|
//(270000000000000000000000000000000000000000000000000000000000000000000 mod: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
2015-12-01 12:13:40 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
|
|
|
//(0 div: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
|
|
|
//(0 mdiv: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
|
|
|
//(0 mod: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
|
2015-12-01 12:13:40 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 rem: -1) dump.
|
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 div: -1) dump.
|
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 mdiv: -1) dump.
|
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 mod: -1) dump.
|
2015-12-01 12:13:40 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// (-27029038 mod: 2) asString dump.
|
|
|
|
// (-270290380000000000000000000000000000000000000000000000000000000000000000000000000000000000000 mod: 2) asString dump.
|
|
|
|
//(-16rAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFF) asString dump.
|
|
|
|
// (16r2dd01fc06c265c8163ac729b49d890939826ce3dd div: 16r3b9aca00) dump.
|
2015-12-01 12:13:40 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(0 rem: -50) dump.
|
|
|
|
//(0 div: -50) dump.
|
|
|
|
//(0 mdiv: -50) dump.
|
|
|
|
//(0 mod: -50) dump.
|
2015-11-30 14:29:57 +00:00
|
|
|
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 rem: 5) dump.
|
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 div: 5) dump.
|
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 5) dump.
|
|
|
|
//(-270000000000000000000000000000000000000000000000000000000000000000000 mod: 5) dump.
|
2015-11-30 15:17:41 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(-270 rem: 5) dump.
|
|
|
|
//(-270 div: 5) dump.
|
|
|
|
//(-270 mdiv: 5) dump.
|
|
|
|
//(-270 mod: 5) dump.
|
2015-11-30 15:17:41 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//(16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) dump.
|
2015-12-17 16:11:10 +00:00
|
|
|
|
|
|
|
(2r1111111111111111111111111111111111111111111111111111111111111111 printStringRadix:2) dump.
|
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/* -----------------------
|
2017-11-24 17:40:20 +00:00
|
|
|
|
|
|
|
(16rF0FFFF bitOr: 16r111111) dump.
|
2015-12-10 14:23:09 +00:00
|
|
|
|
|
|
|
(16r11 bitOr: 16r20000000000000000000000000000000FFFFFFFFFFFFFFFF11111100000000000000000001) dump.
|
2015-12-13 16:08:05 +00:00
|
|
|
((16r11 bitOr: 16r20000000000000000000000000000000FFFFFFFFFFFFFFFF11111100000000000000000001) bitOr: 16r1100) dump.
|
|
|
|
((16r11 bitOr: $a) bitOr: 16r1100) dump.
|
|
|
|
(-20000000000000000000000000000000000000000 bitInvert printStringRadix: 2) dump.
|
2015-12-10 14:23:09 +00:00
|
|
|
|
2015-12-13 16:08:05 +00:00
|
|
|
((-2r101010 bitXor: 2r11101) printStringRadix: 2) dump.
|
|
|
|
((2r11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 bitXor: 2r11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111) printStringRadix: 2) dump.
|
|
|
|
|
|
|
|
((2r10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 bitAnd: 2r01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010) printStringRadix: 2) dump.
|
2017-11-24 17:40:20 +00:00
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
--------------------- */
|
2015-12-17 16:11:10 +00:00
|
|
|
|
|
|
|
(16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
|
|
|
(-16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
|
|
|
(16rFFFFFFFFFFFFFFFF bitOr: -16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
|
|
|
(-16rFFFFFFFFFFFFFFFF bitOr: -16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
|
|
|
|
|
|
|
|
|
|
|
((16rFFFFFFF bitXor: -16rFFFFFFF) printStringRadix: 16) dump.
|
|
|
|
((16r1234 bitXor: -16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) printStringRadix: 16) dump.
|
|
|
|
((16r1234 bitXor: 2r1111111111111111111111111111111111111111111111111111111111111) printStringRadix: 16) dump.
|
|
|
|
|
|
|
|
((16r1234 bitXor: 2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
|
|
|
|
((-16r1234 bitXor: 2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
|
|
|
|
((16r1234 bitXor: -2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
|
|
|
|
((-16r1234 bitXor: -2r100000000000000000000000000000000000000000000000000000000000000000000000000000) printStringRadix: 16) dump.
|
|
|
|
|
2015-12-17 16:37:26 +00:00
|
|
|
((2r100000000000000000000000000000000000000000000000000000000000000000000000000000 bitInvert) printStringRadix: 16) dump.
|
2015-12-18 15:58:45 +00:00
|
|
|
((2r1111111 bitInvert) printStringRadix: 16) dump.
|
|
|
|
((2r11001110000000000000000000000000000000000000000000000000000000000000000000000 bitInvert) printStringRadix: 16) dump.
|
|
|
|
|
2015-12-23 15:25:29 +00:00
|
|
|
|
2015-12-18 15:58:45 +00:00
|
|
|
((2r1111 bitShift: 100) printStringRadix: 2) dump.
|
|
|
|
((123123124 bitShift: 100000) printStringRadix: 16) dump.
|
|
|
|
(2r110101010101010101010101010101111111111111111111111111111111111111111111111111111111100000000001111111 printStringRadix: 16) dump.
|
|
|
|
|
|
|
|
(16rFFFFFFFFFF1234567890AAAAAAAAAAAAAAAAAAAAAAAAA22222222222222222F printStringRadix: 32) dump.
|
|
|
|
(32r3VVVVVVVS938LJOI2LALALALALALALALALAL8H248H248H248HF printStringRadix: 16) dump.
|
2015-12-17 16:11:10 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// ((-2r110101010101010101010101010101111111111111111111111111111111111111111111111111111111100000000001111111 bitShift: 16r1FFFFFFFFFFFFFFFF) printStringRadix: 2) dump.
|
2015-12-22 15:50:01 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//((-2r11111111110000000000111110000 bitShift: -31) printStringRadix: 2) dump.
|
|
|
|
//((-536870911 bitShift: -536870912) printStringRadix: 2) dump.
|
2015-12-23 15:25:29 +00:00
|
|
|
((-2r1111 bitShift: -3) printStringRadix: 2) dump.
|
|
|
|
((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -1) printStringRadix: 2) dump.
|
|
|
|
((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -2) printStringRadix: 2) dump.
|
|
|
|
((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -3) printStringRadix: 2) dump.
|
|
|
|
((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -200) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -5) printStringRadix: 2) dump.
|
2015-12-24 14:11:04 +00:00
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -16rFFFFFFFFFFFFFFFF) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: 13) printStringRadix: 2) dump.
|
|
|
|
((2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: 13) printStringRadix: 2) dump.
|
2015-12-23 15:25:29 +00:00
|
|
|
|
2015-12-26 05:11:10 +00:00
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -0) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -1) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -73) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -74) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -75) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -76) printStringRadix: 2) dump.
|
|
|
|
((-2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitShift: -77) printStringRadix: 2) dump.
|
|
|
|
|
|
|
|
|
|
|
|
(2305843009213693951 bitAt: 62) dump.
|
|
|
|
(-2305843009213693951 bitAt: 63) dump.
|
|
|
|
(2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitAt: 129) dump.
|
|
|
|
(2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitAt: 16rFFFFFFFFFFFFFFFF1) dump.
|
2015-12-21 17:12:57 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
//self a: 1 b: 2 c: 3 d: 4 e: 5 f: 6 g: 7.
|
|
|
|
//self a: 1 b: 2 c: 3.
|
2015-12-27 18:02:59 +00:00
|
|
|
|
2016-01-29 04:04:39 +00:00
|
|
|
[1 + [100 + 200] value] value dump.
|
|
|
|
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
"====================" dump.
|
2016-01-29 04:04:39 +00:00
|
|
|
[
|
|
|
|
| a b |
|
2019-06-27 08:06:33 +00:00
|
|
|
"--------------" dump.
|
2016-01-29 04:04:39 +00:00
|
|
|
[a := 20. b := [ a + 20 ]. b value.] value dump.
|
|
|
|
a dump.
|
|
|
|
b dump.
|
|
|
|
] value.
|
2019-06-27 08:06:33 +00:00
|
|
|
"====================" dump.
|
2019-06-19 12:38:09 +00:00
|
|
|
([ :a :b | /*a := 20.*/ b := [ a + 20 ]. b value.] value: 99 value: 100) dump.
|
2019-06-27 08:06:33 +00:00
|
|
|
"====================" dump.
|
2016-01-29 04:04:39 +00:00
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. // not sufficient arguments. it must fail
|
2019-06-27 08:06:33 +00:00
|
|
|
//[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | "Exception" dump].
|
2016-01-29 04:04:39 +00:00
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/*
|
2015-10-08 14:26:04 +00:00
|
|
|
FFI isNil dump.
|
|
|
|
FFI notNil dump.
|
|
|
|
nil isNil dump.
|
|
|
|
nil notNil dump.
|
|
|
|
nil class dump.
|
|
|
|
nil class class class dump.
|
2019-06-19 12:38:09 +00:00
|
|
|
*/
|
2015-10-03 15:29:03 +00:00
|
|
|
}
|
2015-06-26 15:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/* ====================
|
2015-06-26 15:49:08 +00:00
|
|
|
[ a := 20. b := [ a + 20 ]. b value. ] value
|
|
|
|
^ ^ ^ ^
|
|
|
|
p1 p3 p4 p2
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
AC
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
mc1<active>
|
|
|
|
mc1->sender := fake_initial_context.
|
|
|
|
mc1->home := nil.
|
|
|
|
mc1->origin := mc1.
|
|
|
|
|
|
|
|
mc1 p1 -> bc1 is created based on mc1 (mc1 blockCopy:)
|
|
|
|
bc1->caller := nil
|
|
|
|
bc1->origin := mc1.
|
|
|
|
bc1->home := mc1. (the active context is a method context. so just use it as a home).
|
|
|
|
bc1->source := nil.
|
|
|
|
|
|
|
|
mc1 p2 -> bc2 is shallow-copied of bc1. (bc1 value)
|
2016-01-29 04:04:39 +00:00
|
|
|
bc2->caller := mc1. (mc1 is the active context at p2 point)
|
2015-06-26 15:49:08 +00:00
|
|
|
bc2->origin := bc1->origin.
|
|
|
|
bc2->home := bc1->home.
|
|
|
|
bc2->source := bc1.
|
|
|
|
|
|
|
|
bc2 bc3 is created based on bc2. (bc2 blockCopy:)
|
|
|
|
bc3->caller := nil
|
|
|
|
bc3->origin := bc2->origin
|
2016-01-29 04:04:39 +00:00
|
|
|
bc3->home := bc2. (the active context is a block context).
|
2015-06-26 15:49:08 +00:00
|
|
|
bc3->source := nil.
|
|
|
|
|
|
|
|
bc2 bc4 is shallow-copied of bc3. (bc3 value)
|
2016-01-29 04:04:39 +00:00
|
|
|
bc4->caller := bc2. (bc2 is the active context at p2 point)
|
2015-06-26 15:49:08 +00:00
|
|
|
bc4->origin := bc3->origin
|
|
|
|
bc4->home := bc3->home
|
|
|
|
bc4->source = bc3.
|
|
|
|
|
|
|
|
bc4.
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2019-06-27 08:06:33 +00:00
|
|
|
"home" is set when the context is created by blockCopy.
|
|
|
|
"caller" is set when the context is activated.
|
|
|
|
all "origin" fields point to mc1 as a result.
|
2015-06-26 15:49:08 +00:00
|
|
|
self represents the receiver. that is bc->origin->receiver which is mc1->receiver.
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method ifTrue: trueBlock
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
^trueBlock value.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method whileTrue: aBlock
|
2015-06-26 15:49:08 +00:00
|
|
|
{
|
|
|
|
(self value) ifTrue: [aBlock value. self whileTrue: aBlock].
|
|
|
|
}
|
|
|
|
|
|
|
|
[ b < 10 ] whileTrue: [ b dump. b := b + 1 ].
|
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
========== */
|