renamed *.st files to *.moo
This commit is contained in:
parent
68a455e128
commit
7460ce819c
87
moo/kernel/Mill.moo
Normal file
87
moo/kernel/Mill.moo
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
|
class Mill(Object)
|
||||||
|
{
|
||||||
|
dcl registrar.
|
||||||
|
dcl obj.
|
||||||
|
|
||||||
|
method initialize
|
||||||
|
{
|
||||||
|
self.registrar := Dictionary new.
|
||||||
|
}
|
||||||
|
|
||||||
|
method register: name call: callable
|
||||||
|
{
|
||||||
|
| k |
|
||||||
|
(k := self.registrar at: name) isNil ifTrue: [
|
||||||
|
self.registrar at: name put: [
|
||||||
|
self.obj isNil ifTrue: [
|
||||||
|
self.obj := callable value.
|
||||||
|
].
|
||||||
|
self.obj
|
||||||
|
].
|
||||||
|
].
|
||||||
|
|
||||||
|
^k
|
||||||
|
}
|
||||||
|
|
||||||
|
method make: name
|
||||||
|
{
|
||||||
|
| k |
|
||||||
|
|
||||||
|
(k := self.registrar at: name) notNil ifTrue: [
|
||||||
|
^k value.
|
||||||
|
].
|
||||||
|
|
||||||
|
^nil.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyObject(Object)
|
||||||
|
{
|
||||||
|
method(#class) main
|
||||||
|
{
|
||||||
|
| d a |
|
||||||
|
|
||||||
|
(*k := Mill new.
|
||||||
|
k register: #abc call: [ Dictionary new ].
|
||||||
|
a := k make: #abc.
|
||||||
|
##a dump.*)
|
||||||
|
|
||||||
|
d := Dictionary new.
|
||||||
|
d at: #abc put: 20.
|
||||||
|
d at: #dddd put: 40.
|
||||||
|
d at: #jjjj put: 'hello world'.
|
||||||
|
d at: #moo put: 'good?'.
|
||||||
|
d at: #moo put: 'not good?'.
|
||||||
|
|
||||||
|
(* (d at: #abc) dump.
|
||||||
|
(* (d at: #dddd) dump. *)
|
||||||
|
(*d do: [:v | v dump].*)
|
||||||
|
|
||||||
|
d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ].
|
||||||
|
|
||||||
|
##(d includesAssociation: (Association key: #moo value: 'not good?')) dump.
|
||||||
|
'-------------------------' dump.
|
||||||
|
##(System at: #MyObject) dump.
|
||||||
|
(d removeKey: #moo) dump.
|
||||||
|
d removeKey: #abc ifAbsent: [System logNl: '#moo not found'].
|
||||||
|
d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ].
|
||||||
|
|
||||||
|
'-------------------------' dump.
|
||||||
|
(d at: #jjjj) dump.
|
||||||
|
(d at: #jjjja) dump.
|
||||||
|
|
||||||
|
(*
|
||||||
|
System keysAndValuesDo: [:k :v|
|
||||||
|
System logNl: (k asString) & ' => ' & (v asString)
|
||||||
|
].
|
||||||
|
*)
|
||||||
|
|
||||||
|
##System keysDo: [:k| System logNl: (k asString)]
|
||||||
|
|
||||||
|
(*[
|
||||||
|
[Exception hash dump] ensure: ['xxxx' dump].
|
||||||
|
] on: Exception do: [:ex | ('Exception caught - ' & ex asString) dump ].*)
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
#include 'Apex.st'.
|
#include 'Apex.moo'.
|
||||||
#include 'Context.st'.
|
#include 'Context.moo'.
|
||||||
#include 'Except.st'.
|
#include 'Except.moo'.
|
||||||
#include 'Class.st'.
|
#include 'Class.moo'.
|
||||||
#include 'Boolean.st'.
|
#include 'Boolean.moo'.
|
||||||
#include 'Magnitu.st'.
|
#include 'Magnitu.moo'.
|
||||||
#include 'Collect.st'.
|
#include 'Collect.moo'.
|
||||||
#include 'Process.st'.
|
#include 'Process.moo'.
|
||||||
|
|
||||||
|
|
||||||
class FFI(Object)
|
class FFI(Object)
|
||||||
@ -82,5 +82,5 @@ f isNil ifTrue: [ self error: 'No such function' ].
|
|||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
|
|
||||||
#include 'Stdio.st'.
|
#include 'Stdio.moo'.
|
||||||
#include 'Console.st'.
|
#include 'Console.moo'.
|
@ -1,4 +1,4 @@
|
|||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
class MyObject(Object)
|
class MyObject(Object)
|
||||||
{
|
{
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
143
moo/kernel/test-012.moo
Normal file
143
moo/kernel/test-012.moo
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
|
||||||
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
|
#################################################################
|
||||||
|
## MAIN
|
||||||
|
#################################################################
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
extend Apex
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extend SmallInteger
|
||||||
|
{
|
||||||
|
method getTrue: anInteger
|
||||||
|
{
|
||||||
|
^anInteger + 9999.
|
||||||
|
}
|
||||||
|
|
||||||
|
method inc
|
||||||
|
{
|
||||||
|
^self + 1.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestObject(Object)
|
||||||
|
{
|
||||||
|
dcl(#class) Q R.
|
||||||
|
dcl(#classinst) a1 a2.
|
||||||
|
|
||||||
|
method test999
|
||||||
|
{
|
||||||
|
^self.Q
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B.TestObject(Object)
|
||||||
|
{
|
||||||
|
dcl(#class) Q R.
|
||||||
|
dcl(#classinst) a1 a2.
|
||||||
|
|
||||||
|
method test000
|
||||||
|
{
|
||||||
|
^self.Q
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pooldic ABC
|
||||||
|
{
|
||||||
|
#KKK := 20.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class MyObject(TestObject)
|
||||||
|
{
|
||||||
|
method(#class) aaa_123
|
||||||
|
{
|
||||||
|
| v1 |
|
||||||
|
v1 := [
|
||||||
|
| k |
|
||||||
|
k := 99.
|
||||||
|
[
|
||||||
|
[
|
||||||
|
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ', (k asString)) dump ].
|
||||||
|
[ ^ 20 ] ensure: [ ('ensure 1 ', (k asString)) dump. ].
|
||||||
|
] ensure: ['ensure 2' dump ].
|
||||||
|
] ensure: ['ensure 3' dump ].
|
||||||
|
] on: Exception do: [:ex |
|
||||||
|
('EXCETION - ' , ex messageText) dump.
|
||||||
|
## Exception signal: 'qqq'.
|
||||||
|
].
|
||||||
|
^v1
|
||||||
|
}
|
||||||
|
method(#class) main
|
||||||
|
{
|
||||||
|
| v1 |
|
||||||
|
'START OF MAIN' dump.
|
||||||
|
##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump].
|
||||||
|
##['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump].
|
||||||
|
|
||||||
|
##v1 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ].
|
||||||
|
##v1 dump.
|
||||||
|
|
||||||
|
|
||||||
|
##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ].
|
||||||
|
|
||||||
|
"[
|
||||||
|
[ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ].
|
||||||
|
] on: Exception do: [:ex | ('EXCETION - ' , ex messageText) dump. Exception signal: 'qqq'. ]."
|
||||||
|
|
||||||
|
"[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']."
|
||||||
|
|
||||||
|
v1 := [
|
||||||
|
[
|
||||||
|
| k |
|
||||||
|
k := 99.
|
||||||
|
[
|
||||||
|
[
|
||||||
|
[ '@@@@@' dump.
|
||||||
|
Exception signal: 'simulated error'.
|
||||||
|
'^^^^^^' dump. ] ensure: [
|
||||||
|
('ensure 11 ', (k asString)) dump.
|
||||||
|
Exception signal: 'qqq'.
|
||||||
|
].
|
||||||
|
|
||||||
|
##[ ^20 ] ensure: [('ensure 1 ', (k asString)) dump ].
|
||||||
|
|
||||||
|
'KKKKKKKKKKKKKKKKKKKK' dump.
|
||||||
|
] ensure: ['ensure 2' dump ].
|
||||||
|
|
||||||
|
'JJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump.
|
||||||
|
] ensure: ['ensure 3' dump ].
|
||||||
|
] on: Exception do: [:ex |
|
||||||
|
('>>>> EXCETION - ' , ex messageText) dump.
|
||||||
|
ex pass.
|
||||||
|
|
||||||
|
##Exception signal: 'XXXXXXXXXXXXx'.
|
||||||
|
## ex return: 10.
|
||||||
|
## Exception signal: 'qqq'.
|
||||||
|
].
|
||||||
|
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump.
|
||||||
|
]
|
||||||
|
on: PrimitiveFailureException do: [:ex |
|
||||||
|
('PRIMITIVE FAILURE EXCETION AT OUTER - ' , ex messageText) dump.
|
||||||
|
]
|
||||||
|
on: Exception do: [:ex |
|
||||||
|
('>>>> EXCETION AT OUTER - ' , ex messageText) dump.
|
||||||
|
].
|
||||||
|
|
||||||
|
|
||||||
|
## v1 := self aaa_123.
|
||||||
|
'--------------------------------' dump.
|
||||||
|
v1 dump.
|
||||||
|
'--------------------------------' dump.
|
||||||
|
'END OF MAIN' dump.
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include 'Moo.st'.
|
#include 'Moo.moo'.
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
## MAIN
|
## MAIN
|
Loading…
Reference in New Issue
Block a user