no more ## comment. // as a signle-line comment starter.

This commit is contained in:
hyunghwan.chung
2019-06-27 06:29:09 +00:00
parent 613e33d186
commit fcb987891e
35 changed files with 946 additions and 887 deletions

View File

@ -1,12 +1,19 @@
## Top-level elemtns ### Top-level elements
* #include * #include
* #pragma * #pragma
* class * class
* interface * interface
* pooldic * pooldic
### Comments
## Literal notations ~~~
#! comment text
// comment text
/* comment text */
~~~
### Literal notations
* 200 decimal integer * 200 decimal integer
* 2r1100 binary integer * 2r1100 binary integer
* 16rFF00 hexadecimal integer * 16rFF00 hexadecimal integer
@ -49,3 +56,32 @@ The following are not literals.
* S%{} String with dynamic expression * S%{} String with dynamic expression
* S%{ 65 asCharacter, 64 asCharacter } * S%{ 65 asCharacter, 64 asCharacter }
### Class
~~~
class MyClass(Object)
{
method show: this
{
}
}
~~~
### Flow Control
~~~
k := if (i < 20) { 30 } else { 40 }.
~~~
~~~
while (true)
{
}.
~~~
~~~
1 to: 20 do: [:count | ... ].
~~~

View File

@ -19,7 +19,7 @@ class(#limited) Error(Apex)
ERANGE := #\E20. ERANGE := #\E20.
ELIMIT := #\E9999. ELIMIT := #\E9999.
## add more items... // add more items...
} }
} }
@ -39,7 +39,7 @@ pooldic Error.Code
ERANGE := #\E20. ERANGE := #\E20.
ELIMIT := #\E9999. ELIMIT := #\E9999.
## add more items... // add more items...
} */ } */
/*pooldic Error.Code2 /*pooldic Error.Code2
@ -54,20 +54,20 @@ pooldic Error.Code
extend Apex extend Apex
{ {
## ------------------------------------------------------- // -------------------------------------------------------
## ------------------------------------------------------- // -------------------------------------------------------
method(#dual) dump method(#dual) dump
{ {
<primitive: #_dump> <primitive: #_dump>
} }
## ------------------------------------------------------- // -------------------------------------------------------
## ------------------------------------------------------- // -------------------------------------------------------
method(#dual) yourself { ^self } method(#dual) yourself { ^self }
## ------------------------------------------------------- // -------------------------------------------------------
## INSTANTIATION & INITIALIZATION // INSTANTIATION & INITIALIZATION
## ------------------------------------------------------- // -------------------------------------------------------
method(#class,#primitive,#lenient) _basicNew. method(#class,#primitive,#lenient) _basicNew.
method(#class,#primitive,#lenient) _basicNew: size. method(#class,#primitive,#lenient) _basicNew: size.
@ -90,7 +90,7 @@ extend Apex
{ {
| x | | x |
x := self basicNew. x := self basicNew.
x initialize. ## TODO: assess if it's good to call 'initialize' from new x initialize. // TODO: assess if it's good to call 'initialize' from new
^x. ^x.
} }
@ -98,7 +98,7 @@ extend Apex
{ {
| x | | x |
x := self basicNew: anInteger. x := self basicNew: anInteger.
x initialize. ## TODO: assess if it's good to call 'initialize' from new. x initialize. // TODO: assess if it's good to call 'initialize' from new.
^x. ^x.
} }
@ -108,15 +108,15 @@ extend Apex
^self. ^self.
} }
## ------------------------------------------------------- // -------------------------------------------------------
## ------------------------------------------------------- // -------------------------------------------------------
method(#dual,#primitive,#lenient) _shallowCopy. method(#dual,#primitive,#lenient) _shallowCopy.
method(#dual,#primitive) shallowCopy. method(#dual,#primitive) shallowCopy.
method(#dual,#primitive,#lenient) _copy. ## alias to _shallowCopy method(#dual,#primitive,#lenient) _copy. // alias to _shallowCopy
method(#dual,#primitive) copy. ## alias to shallowCopy method(#dual,#primitive) copy. // alias to shallowCopy
## ------------------------------------------------------- // -------------------------------------------------------
## ------------------------------------------------------- // -------------------------------------------------------
method(#dual,#primitive,#lenient) _basicSize. method(#dual,#primitive,#lenient) _basicSize.
method(#dual,#primitive) basicSize. method(#dual,#primitive) basicSize.
@ -148,8 +148,8 @@ extend Apex
* IDENTITY TEST * IDENTITY TEST
* ------------------------------------------------------------------ */ * ------------------------------------------------------------------ */
## check if the receiver is identical to anObject. // check if the receiver is identical to anObject.
## this doesn't compare the contents // this doesn't compare the contents
method(#dual, #primitive) == anObject. method(#dual, #primitive) == anObject.
method(#dual) ~~ anObject method(#dual) ~~ anObject
@ -182,14 +182,14 @@ extend Apex
method(#dual) isNil method(#dual) isNil
{ {
## ^self == nil. // ^self == nil.
^false ^false
} }
method(#dual) notNil method(#dual) notNil
{ {
## ^(self == nil) not // ^(self == nil) not
## ^self ~= nil. // ^self ~= nil.
^true. ^true.
} }
@ -203,8 +203,8 @@ extend Apex
^true ^true
} }
## ------------------------------------------------------- // -------------------------------------------------------
## ------------------------------------------------------- // -------------------------------------------------------
method(#class) inheritsFrom: aClass method(#class) inheritsFrom: aClass
{ {
@ -242,13 +242,13 @@ extend Apex
^(self isMemberOf: aClass) or: [self class inheritsFrom: aClass]. ^(self isMemberOf: aClass) or: [self class inheritsFrom: aClass].
} }
## ------------------------------------------------------- // -------------------------------------------------------
## ------------------------------------------------------- // -------------------------------------------------------
method(#dual,#primitive) respondsTo: selector. method(#dual,#primitive) respondsTo: selector.
## ------------------------------------------------------- // -------------------------------------------------------
## ------------------------------------------------------- // -------------------------------------------------------
method(#dual,#variadic,#primitive) perform(selector). method(#dual,#variadic,#primitive) perform(selector).
@ -306,10 +306,10 @@ class UndefinedObject(Apex)
method handleException: exception method handleException: exception
{ {
('### EXCEPTION NOT HANDLED #### ' & exception class name & ' - ' & exception messageText) dump. ('//# EXCEPTION NOT HANDLED //// ' & exception class name & ' - ' & exception messageText) dump.
## TODO: debug the current process???? " // TODO: debug the current process???? "
## TODO: ensure to execute ensure blocks as well.... // TODO: ensure to execute ensure blocks as well....
####Processor activeProcess terminate. ////Processor activeProcess terminate.
} }
} }
@ -362,28 +362,28 @@ extend Error
exctx := (exctx sender) findExceptionContext. exctx := (exctx sender) findExceptionContext.
}. }.
## ----------------------------------------------------------------- // -----------------------------------------------------------------
## FATAL ERROR - no exception handler. // FATAL ERROR - no exception handler.
## ----------------------------------------------------------------- // -----------------------------------------------------------------
##thisContext unwindTo: nil return: nil. //thisContext unwindTo: nil return: nil.
##thisContext unwindTo: (Processor activeProcess initialContext) return: nil. //thisContext unwindTo: (Processor activeProcess initialContext) return: nil.
## TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... // TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE...
System logNl: '== BACKTRACE =='. System logNl: '== BACKTRACE =='.
ctx := thisContext. ctx := thisContext.
while (ctx notNil) while (ctx notNil)
{ {
if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }. if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }.
## TODO: include blockcontext??? // TODO: include blockcontext???
ctx := ctx sender. ctx := ctx sender.
}. }.
System logNl: '== END OF BACKTRACE =='. System logNl: '== END OF BACKTRACE =='.
thisContext unwindTo: (thisProcess initialContext) return: nil. thisContext unwindTo: (thisProcess initialContext) return: nil.
('### ERROR NOT HANDLED #### ' & self class name & ' - ' & self asString) dump. ('//# ERROR NOT HANDLED //// ' & self class name & ' - ' & self asString) dump.
## TODO: debug the current process???? " // TODO: debug the current process???? "
##Processor activeProcess terminate. //Processor activeProcess terminate.
thisProcess terminate. thisProcess terminate.
} }
} }

View File

@ -4,10 +4,10 @@ interface ClassInterface
method superclass. method superclass.
} }
## //
## the Class object should be a variable-pointer object because // the Class object should be a variable-pointer object because
## it needs to accomodate class instance variables. // it needs to accomodate class instance variables.
## //
class(#pointer,#limited) Class(Apex) [ClassInterface] class(#pointer,#limited) Class(Apex) [ClassInterface]
{ {
var spec, selfspec, superclass, subclasses, name, modname. var spec, selfspec, superclass, subclasses, name, modname.
@ -24,8 +24,8 @@ class(#pointer,#limited) Class(Apex) [ClassInterface]
method specNumInstVars method specNumInstVars
{ {
## shift right by 8 bits. // shift right by 8 bits.
## see MOO_CLASS_SPEC_NAMED_INSTVARS in moo-prv.h for details. // see MOO_CLASS_SPEC_NAMED_INSTVARS in moo-prv.h for details.
^self.spec bitShift: -8 ^self.spec bitShift: -8
} }

View File

@ -26,9 +26,9 @@ class Collection(Object)
self subclassResponsibility: #add:. self subclassResponsibility: #add:.
} }
## =================================================================== // ===================================================================
## ENUMERATING // ENUMERATING
## =================================================================== // ===================================================================
method do: block method do: block
{ {
@ -38,7 +38,7 @@ class Collection(Object)
method collect: block method collect: block
{ {
| coll | | coll |
##coll := self class new: self basicSize. //coll := self class new: self basicSize.
coll := self class new. coll := self class new.
self do: [ :el | coll add: (block value: el) ]. self do: [ :el | coll add: (block value: el) ].
^coll ^coll
@ -51,7 +51,7 @@ class Collection(Object)
method detect: block ifNone: exception_block method detect: block ifNone: exception_block
{ {
## returns the first element for which the block evaluates to true. // returns the first element for which the block evaluates to true.
self do: [ :el | if (block value: el) { ^el } ]. self do: [ :el | if (block value: el) { ^el } ].
^exception_block value. ^exception_block value.
} }
@ -59,7 +59,7 @@ class Collection(Object)
method select: condition_block method select: condition_block
{ {
| coll | | coll |
##coll := self class new: self basicSize. //coll := self class new: self basicSize.
coll := self class new. coll := self class new.
self do: [ :el | if (condition_block value: el) { coll add: el } ]. self do: [ :el | if (condition_block value: el) { coll add: el } ].
^coll ^coll
@ -68,7 +68,7 @@ class Collection(Object)
method reject: condition_block method reject: condition_block
{ {
| coll | | coll |
##coll := self class new: self basicSize. //coll := self class new: self basicSize.
coll := self class new. coll := self class new.
self do: [ :el | ifnot (condition_block value: el) { coll add: el } ]. self do: [ :el | ifnot (condition_block value: el) { coll add: el } ].
^coll ^coll
@ -80,7 +80,7 @@ class Collection(Object)
} }
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class SequenceableCollection(Collection) class SequenceableCollection(Collection)
{ {
method do: aBlock method do: aBlock
@ -113,7 +113,7 @@ class SequenceableCollection(Collection)
method swap: anIndex with: anotherIndex method swap: anIndex with: anotherIndex
{ {
## the subclass must implement at: and at:put for this to work. // the subclass must implement at: and at:put for this to work.
| tmp | | tmp |
tmp := self at: anIndex. tmp := self at: anIndex.
@ -123,7 +123,7 @@ class SequenceableCollection(Collection)
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class(#pointer) Array(SequenceableCollection) class(#pointer) Array(SequenceableCollection)
{ {
method size method size
@ -158,8 +158,8 @@ class(#pointer) Array(SequenceableCollection)
method copy: anArray from: start to: end method copy: anArray from: start to: end
{ {
## copy elements from an array 'anArray' starting from // copy elements from an array 'anArray' starting from
## the index 'start' to the index 'end'. // the index 'start' to the index 'end'.
| s i ss | | s i ss |
@ -192,8 +192,8 @@ class(#pointer) Array(SequenceableCollection)
method copyFrom: start to: end method copyFrom: start to: end
{ {
## returns a copy of the receiver starting from the element // returns a copy of the receiver starting from the element
## at index 'start' to the element at index 'end'. // at index 'start' to the element at index 'end'.
| newsz | | newsz |
newsz := end - start + 1. newsz := end - start + 1.
^(self class new: newsz) copy: self from: start to: end ^(self class new: newsz) copy: self from: start to: end
@ -255,7 +255,7 @@ class(#pointer) Array(SequenceableCollection)
} }
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class(#character) String(Array) class(#character) String(Array)
{ {
@ -299,7 +299,7 @@ class(#character) String(Array)
method(#primitive,#variadic,#class) format(fmt). method(#primitive,#variadic,#class) format(fmt).
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class(#character,#final,#limited,#immutable) Symbol(String) class(#character,#final,#limited,#immutable) Symbol(String)
{ {
@ -312,7 +312,7 @@ class(#character,#final,#limited,#immutable) Symbol(String)
size := self basicSize. size := self basicSize.
str := String basicNew: size. str := String basicNew: size.
##0 priorTo: size do: [:i | str at: i put: (self at: i) ]. //0 priorTo: size do: [:i | str at: i put: (self at: i) ].
i := 0. i := 0.
while (i < size) while (i < size)
{ {
@ -337,24 +337,24 @@ class(#character,#final,#limited,#immutable) Symbol(String)
} }
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class(#byte) ByteArray(Array) class(#byte) ByteArray(Array)
{ {
## TODO: is it ok for ByteArray to inherit from Array? // TODO: is it ok for ByteArray to inherit from Array?
## method asByteString // method asByteString
## { // {
## } // }
method decodeToCharacter method decodeToCharacter
{ {
## TODO: support other encodings. it only supports utf8 as of now. // TODO: support other encodings. it only supports utf8 as of now.
<primitive: #_utf8_to_uc> <primitive: #_utf8_to_uc>
self primitiveFailed(thisContext method). self primitiveFailed(thisContext method).
/* /*
### TODO: implement this in moo also.. //# TODO: implement this in moo also..
| firstByte | | firstByte |
firstByte := self at: 0. firstByte := self at: 0.
if ((firstByte bitAnd:2r10000000) == 0) { 1 } if ((firstByte bitAnd:2r10000000) == 0) { 1 }
@ -371,13 +371,13 @@ class(#byte) ByteString(Array)
{ {
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class OrderedCollection(SequenceableCollection) class OrderedCollection(SequenceableCollection)
{ {
var buffer. var buffer.
var(#get) firstIndex. var(#get) firstIndex.
var(#get) lastIndex. ## this is the last index plus 1. var(#get) lastIndex. // this is the last index plus 1.
method(#class) new method(#class) new
{ {
@ -416,7 +416,7 @@ class OrderedCollection(SequenceableCollection)
method at: index put: obj method at: index put: obj
{ {
## replace an existing element. it doesn't grow the buffer. // replace an existing element. it doesn't grow the buffer.
| i | | i |
i := index + self.firstIndex. i := index + self.firstIndex.
if ((i >= self.firstIndex) and (i < self.lastIndex)) { ^self.buffer at: i put: obj }. if ((i >= self.firstIndex) and (i < self.lastIndex)) { ^self.buffer at: i put: obj }.
@ -554,19 +554,19 @@ class OrderedCollection(SequenceableCollection)
method removeAtIndex: index method removeAtIndex: index
{ {
## remove the element at the given position. // remove the element at the given position.
| obj | | obj |
obj := self at: index. ## the range is checed by the at: method. obj := self at: index. // the range is checed by the at: method.
self __remove_index(index + self.firstIndex). self __remove_index(index + self.firstIndex).
^obj ^obj
} }
method remove: obj ifAbsent: error_block method remove: obj ifAbsent: error_block
{ {
## remove the first element equivalent to the given object. // remove the first element equivalent to the given object.
## and returns the removed element. // and returns the removed element.
## if no matching element is found, it evaluates error_block // if no matching element is found, it evaluates error_block
## and return the evaluation result. // and return the evaluation result.
| i cand | | i cand |
i := self.firstIndex. i := self.firstIndex.
while (i < self.lastIndex) while (i < self.lastIndex)
@ -578,9 +578,9 @@ class OrderedCollection(SequenceableCollection)
^error_block value. ^error_block value.
} }
## ------------------------------------------------ // ------------------------------------------------
## ENUMERATING // ENUMERATING
## ------------------------------------------------ // ------------------------------------------------
method collect: aBlock method collect: aBlock
{ {
| coll | | coll |
@ -591,7 +591,7 @@ class OrderedCollection(SequenceableCollection)
method do: aBlock method do: aBlock
{ {
##^self.firstIndex to: (self.lastIndex - 1) do: [:i | aBlock value: (self.buffer at: i)]. //^self.firstIndex to: (self.lastIndex - 1) do: [:i | aBlock value: (self.buffer at: i)].
| i | | i |
i := self.firstIndex. i := self.firstIndex.
@ -624,9 +624,9 @@ class OrderedCollection(SequenceableCollection)
}. }.
} }
## ------------------------------------------------ // ------------------------------------------------
## PRIVATE METHODS // PRIVATE METHODS
## ------------------------------------------------ // ------------------------------------------------
method __grow_and_shift(grow_size, shift_count) method __grow_and_shift(grow_size, shift_count)
{ {
| newcon | | newcon |
@ -652,10 +652,10 @@ class OrderedCollection(SequenceableCollection)
method __ensure_tail_room(size) method __ensure_tail_room(size)
{ {
| tmp | | tmp |
tmp := (self.buffer size) - self.lastIndex. ## remaining capacity tmp := (self.buffer size) - self.lastIndex. // remaining capacity
if (tmp < size) if (tmp < size)
{ {
tmp := size - tmp + 8. ## grow by this amount tmp := size - tmp + 8. // grow by this amount
self __grow_and_shift(tmp, 0). self __grow_and_shift(tmp, 0).
} }
} }
@ -666,8 +666,8 @@ class OrderedCollection(SequenceableCollection)
if (index <= 0) if (index <= 0)
{ {
## treat a negative index as the indicator to // treat a negative index as the indicator to
## grow space in the front side. // grow space in the front side.
reqsize := index * -1 + 1. reqsize := index * -1 + 1.
if (reqsize >= self.firstIndex) { self __ensure_head_room(reqsize) }. if (reqsize >= self.firstIndex) { self __ensure_head_room(reqsize) }.
self.firstIndex := self.firstIndex + index - 1. self.firstIndex := self.firstIndex + index - 1.
@ -705,10 +705,10 @@ class OrderedCollection(SequenceableCollection)
method __remove_index(index) method __remove_index(index)
{ {
## remove an element at the given index from the internal buffer's // remove an element at the given index from the internal buffer's
## angle. as it is for internal use only, no check is performed // angle. as it is for internal use only, no check is performed
## about the range of index. the given index must be equal to or // about the range of index. the given index must be equal to or
## grater than self.firstIndex and less than self.lastIndex. // grater than self.firstIndex and less than self.lastIndex.
self.buffer self.buffer
replaceFrom: index replaceFrom: index
to: self.lastIndex - 2 to: self.lastIndex - 2
@ -735,18 +735,18 @@ class OrderedCollection(SequenceableCollection)
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class Set(Collection) class Set(Collection)
{ {
## The set class stores unordered elemenents and disallows duplicates. // The set class stores unordered elemenents and disallows duplicates.
## It is implemented as an open-addressed hash table currently. // It is implemented as an open-addressed hash table currently.
var tally, bucket. var tally, bucket.
method(#class) new method(#class) new
{ {
^self new: 16. ### TODO: default size. ^self new: 16. //# TODO: default size.
} }
method(#class) new: capacity method(#class) new: capacity
@ -781,7 +781,7 @@ class Set(Collection)
| newbuc newsz ass index i | | newbuc newsz ass index i |
/* expand the bucket */ /* expand the bucket */
newsz := bs + 16. ## TODO: make this sizing operation configurable. newsz := bs + 16. // TODO: make this sizing operation configurable.
newbuc := Array new: newsz. newbuc := Array new: newsz.
i := 0. i := 0.
while (i < bs) while (i < bs)
@ -812,7 +812,7 @@ class Set(Collection)
index := (index + 1) rem: bs. index := (index + 1) rem: bs.
}. }.
^index. ## the item at this index is nil. ^index. // the item at this index is nil.
} }
method __find_index: anObject method __find_index: anObject
@ -872,9 +872,9 @@ class Set(Collection)
{ {
| index absent bs | | index absent bs |
## you cannot add nil to a set. however, the add: method doesn't // you cannot add nil to a set. however, the add: method doesn't
## raise an exception for this. the includes: for nil returns // raise an exception for this. the includes: for nil returns
## false naturally for the way it's implemented. // false naturally for the way it's implemented.
if (anObject isNil) { ^anObject }. if (anObject isNil) { ^anObject }.
index := self __find_index_for_add: anObject. index := self __find_index_for_add: anObject.
@ -934,12 +934,12 @@ class Set(Collection)
method collect: aBlock method collect: aBlock
{ {
## override the default implementation to avoid frequent growth // override the default implementation to avoid frequent growth
## of the new collection being constructed. the block tends to // of the new collection being constructed. the block tends to
## include expression that will produce a unique value for each // include expression that will produce a unique value for each
## element. so sizing the returning collection to the same size // element. so sizing the returning collection to the same size
## as the receiver is likely to help. however, this assumption // as the receiver is likely to help. however, this assumption
## isn't always true. // isn't always true.
| coll | | coll |
coll := self class new: self capacity. coll := self class new: self capacity.
@ -948,10 +948,10 @@ class Set(Collection)
} }
} }
## TODO: implement IdentitySet // TODO: implement IdentitySet
##class IdentitySet(Set) //class IdentitySet(Set)
##{ //{
##} //}
class AssociativeCollection(Collection) class AssociativeCollection(Collection)
{ {
@ -1078,7 +1078,7 @@ class AssociativeCollection(Collection)
method at: key put: value method at: key put: value
{ {
## returns the affected/inserted association // returns the affected/inserted association
^self __find: key or_upsert: true with: value. ^self __find: key or_upsert: true with: value.
} }
@ -1152,7 +1152,7 @@ class AssociativeCollection(Collection)
self.bucket at: x put: nil. self.bucket at: x put: nil.
self.tally := self.tally - 1. self.tally := self.tally - 1.
## return the affected association // return the affected association
^v ^v
} }
@ -1204,9 +1204,9 @@ class AssociativeCollection(Collection)
^self __find: (anAssociation key) or_upsert: true with: (anAssociation value) ^self __find: (anAssociation key) or_upsert: true with: (anAssociation value)
} }
## =================================================================== // ===================================================================
## ENUMERATING // ENUMERATING
## =================================================================== // ===================================================================
method collect: aBlock method collect: aBlock
{ {
@ -1220,9 +1220,9 @@ class AssociativeCollection(Collection)
{ {
| coll | | coll |
coll := self class new. coll := self class new.
## TODO: using at:put: here isn't really right. implement add: to be able to insert the assocication without // TODO: using at:put: here isn't really right. implement add: to be able to insert the assocication without
## creating another new association. // creating another new association.
##self associationsDo: [ :ass | if (aBlock value: ass value) { coll add: ass } ]. //self associationsDo: [ :ass | if (aBlock value: ass value) { coll add: ass } ].
self associationsDo: [ :ass | if (aBlock value: ass value) { coll at: (ass key) put: (ass value) } ]. self associationsDo: [ :ass | if (aBlock value: ass value) { coll at: (ass key) put: (ass value) } ].
^coll ^coll
} }
@ -1287,9 +1287,9 @@ class Dictionary(AssociativeCollection)
* for the dictionary expression notation - %{ } * for the dictionary expression notation - %{ }
*/ */
## TODO: implement Dictionary as a Hashed List/Table or Red-Black Tree // TODO: implement Dictionary as a Hashed List/Table or Red-Black Tree
## Do not inherit Set upon reimplementation // Do not inherit Set upon reimplementation
## //
method(#class) new: capacity method(#class) new: capacity
{ {
^super new: (capacity + 10). ^super new: (capacity + 10).
@ -1322,7 +1322,7 @@ class Dictionary(AssociativeCollection)
{ {
/* found */ /* found */
self.bucket at: index put: assoc. self.bucket at: index put: assoc.
^self. ## it must return self for the instructions generated by the compiler. ^self. // it must return self for the instructions generated by the compiler.
}. }.
index := (index + 1) rem: bs. index := (index + 1) rem: bs.
}. }.
@ -1354,14 +1354,14 @@ class(#limited) Namespace(AssociativeCollection)
var name, nsup. var name, nsup.
method name { ^self.name } method name { ^self.name }
## method name: name { self.name := name } // method name: name { self.name := name }
/* nsup points to either the class associated with this namespace or directly /* nsup points to either the class associated with this namespace or directly
* the upper namespace placed above this namespace. when it points to a class, * the upper namespace placed above this namespace. when it points to a class,
* you should inspect the nsup field of the class to reach the actual upper * you should inspect the nsup field of the class to reach the actual upper
* namespace */ * namespace */
method nsup { ^self.nsup } method nsup { ^self.nsup }
## method nsup: nsup { self.nsup := nsup } // method nsup: nsup { self.nsup := nsup }
method at: key method at: key
{ {
@ -1386,10 +1386,10 @@ class MethodDictionary(AssociativeCollection)
extend Apex extend Apex
{ {
## ------------------------------------------------------- // -------------------------------------------------------
## Association has been defined now. let's add association // Association has been defined now. let's add association
## creating methods // creating methods
## ------------------------------------------------------- // -------------------------------------------------------
method(#class) -> object method(#class) -> object
{ {
@ -1402,7 +1402,7 @@ extend Apex
} }
} }
## ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
class Link(Object) class Link(Object)
{ {
@ -1567,9 +1567,9 @@ class LinkedList(Collection)
extend Collection extend Collection
{ {
## =================================================================== // ===================================================================
## CONVERSION // CONVERSION
## =================================================================== // ===================================================================
method asOrderedCollection method asOrderedCollection
{ {
| coll | | coll |

View File

@ -1,4 +1,4 @@
## TODO: move Pointe to a separate file // TODO: move Pointe to a separate file
class Point(Object) class Point(Object)
{ {
var x, y. var x, y.
@ -65,23 +65,23 @@ class Console(Object) from 'con'
*/ */
## method(#class) input // method(#class) input
## { // {
## ^self new _open: filename mode: mode // ^self new _open: filename mode: mode
## } // }
method(#class) output method(#class) output
{ {
| c | | c |
c := self new. c := self new.
c _open. ## TODO error check - if ((e := c _open) isError) { ^e }. c _open. // TODO error check - if ((e := c _open) isError) { ^e }.
^c ^c
} }
## method(#class) error // method(#class) error
## { // {
## } // }
method close method close
{ {

View File

@ -61,8 +61,8 @@ class(#pointer,#final,#limited) MethodContext(Context)
self.ip := anInteger. self.ip := anInteger.
} }
## it is similar to the pc: method but it doesn't // it is similar to the pc: method but it doesn't
## push the return value to the stack. // push the return value to the stack.
method(#primitive) goto: pc. method(#primitive) goto: pc.
method sp method sp
@ -111,18 +111,18 @@ class(#pointer,#final,#limited) BlockContext(Context)
^self.home vargAt: index ^self.home vargAt: index
} }
## TODO: how can i pass variadic arguments to newProcess // TODO: how can i pass variadic arguments to newProcess
## method(#variadic) fork() -> how to pass them to newProcess??? // method(#variadic) fork() -> how to pass them to newProcess???
method fork method fork
{ {
## crate a new process in the runnable state // crate a new process in the runnable state
^self newProcess resume. ^self newProcess resume.
} }
## create a new process in the suspended state // create a new process in the suspended state
method(#variadic,#primitive) newProcess(). method(#variadic,#primitive) newProcess().
## evaluate the block // evaluate the block
method(#variadic,#primitive) value(). method(#variadic,#primitive) value().
method value: a method value: a
@ -154,19 +154,19 @@ class(#pointer,#final,#limited) BlockContext(Context)
method ifTrue: aBlock method ifTrue: aBlock
{ {
##^(self value) ifTrue: aBlock. //^(self value) ifTrue: aBlock.
^if (self value) { aBlock value }. ^if (self value) { aBlock value }.
} }
method ifFalse: aBlock method ifFalse: aBlock
{ {
##^(self value) ifFalse: aBlock. //^(self value) ifFalse: aBlock.
^if (self value) { /* nothing */ } else { aBlock value }. ^if (self value) { /* nothing */ } else { aBlock value }.
} }
method ifTrue: trueBlock ifFalse: falseBlock method ifTrue: trueBlock ifFalse: falseBlock
{ {
##^(self value) ifTrue: trueBlock ifFalse: falseBlock //^(self value) ifTrue: trueBlock ifFalse: falseBlock
^if (self value) { trueBlock value } else { falseBlock value }. ^if (self value) { trueBlock value } else { falseBlock value }.
} }
@ -254,7 +254,7 @@ class(#pointer,#final,#limited) BlockContext(Context)
* -------------------------------------------------- * --------------------------------------------------
| pc | | pc |
pc := thisContext pcplus1. pc := thisContext pcplus1.
(self value) ifTrue: [ ^nil ]. ## ^self (self value) ifTrue: [ ^nil ]. // ^self
aBlock value. aBlock value.
thisContext goto: pc. thisContext goto: pc.
* -------------------------------------------------- */ * -------------------------------------------------- */
@ -279,7 +279,7 @@ class(#pointer,#final,#limited) BlockContext(Context)
* -------------------------------------------------- * --------------------------------------------------
| pc | | pc |
pc := thisContext pcplus1. pc := thisContext pcplus1.
(self value) ifTrue: [ ^nil ]. ## ^self (self value) ifTrue: [ ^nil ]. // ^self
thisContext goto: pc. thisContext goto: pc.
* -------------------------------------------------- */ * -------------------------------------------------- */
while ((self value) == false) { }. while ((self value) == false) { }.
@ -314,7 +314,7 @@ class(#pointer,#final,#limited) BlockContext(Context)
class(#pointer) CompiledMethod(Object) class(#pointer) CompiledMethod(Object)
{ {
## var owner, name, preamble, preamble_data_1, preamble_data_2, ntmprs, nargs, code, source. // var owner, name, preamble, preamble_data_1, preamble_data_2, ntmprs, nargs, code, source.
var owner, name, preamble, preamble_data_1, preamble_data_2, ntmprs, nargs, source. var owner, name, preamble, preamble_data_1, preamble_data_2, ntmprs, nargs, source.
method preamble method preamble

View File

@ -1,9 +1,9 @@
## //
## TODO: is it better to inherit from Object??? // TODO: is it better to inherit from Object???
## or treat Exception specially like UndefinedObject or Class??? // or treat Exception specially like UndefinedObject or Class???
## //
class Exception(Apex) class Exception(Apex)
{ {
var signalContext, handlerContext. var signalContext, handlerContext.
@ -47,11 +47,11 @@ TODO: can i convert 'thisProcess primError' to a relevant exception?
self.signalContext := thisContext. self.signalContext := thisContext.
exctx := (thisContext sender) findExceptionContext. exctx := (thisContext sender) findExceptionContext.
##[exctx notNil] whileTrue: [ //[exctx notNil] whileTrue: [
while (exctx notNil) while (exctx notNil)
{ {
exblk := exctx findExceptionHandlerFor: (self class). exblk := exctx findExceptionHandlerFor: (self class).
##if (exblk notNil and: [actpos := exctx basicSize - 1. exctx basicAt: actpos]) //if (exblk notNil and: [actpos := exctx basicSize - 1. exctx basicAt: actpos])
if ((exblk notNil) and (exctx basicAt: (actpos := exctx basicSize - 1))) if ((exblk notNil) and (exctx basicAt: (actpos := exctx basicSize - 1)))
{ {
self.handlerContext := exctx. self.handlerContext := exctx.
@ -63,28 +63,28 @@ TODO: can i convert 'thisProcess primError' to a relevant exception?
exctx := (exctx sender) findExceptionContext. exctx := (exctx sender) findExceptionContext.
}. }.
## ----------------------------------------------------------------- // -----------------------------------------------------------------
## FATAL ERROR - no exception handler. // FATAL ERROR - no exception handler.
## ----------------------------------------------------------------- // -----------------------------------------------------------------
##thisContext unwindTo: nil return: nil. //thisContext unwindTo: nil return: nil.
##thisContext unwindTo: (Processor activeProcess initialContext) return: nil. //thisContext unwindTo: (Processor activeProcess initialContext) return: nil.
## TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... // TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE...
System logNl: '== BACKTRACE =='. System logNl: '== BACKTRACE =='.
ctx := thisContext. ctx := thisContext.
while (ctx notNil) while (ctx notNil)
{ {
if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }. if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }.
## TODO: include blockcontext??? // TODO: include blockcontext???
ctx := ctx sender. ctx := ctx sender.
}. }.
System logNl: '== END OF BACKTRACE =='. System logNl: '== END OF BACKTRACE =='.
thisContext unwindTo: (thisProcess initialContext) return: nil. thisContext unwindTo: (thisProcess initialContext) return: nil.
('### EXCEPTION NOT HANDLED(Exception) #### ' & self class name & ' - ' & self messageText) dump. ('//# EXCEPTION NOT HANDLED(Exception) //// ' & self class name & ' - ' & self messageText) dump.
## TODO: debug the current process???? " // TODO: debug the current process???? "
##Processor activeProcess terminate. //Processor activeProcess terminate.
thisProcess terminate. thisProcess terminate.
} }
@ -96,7 +96,7 @@ System logNl: '== END OF BACKTRACE =='.
method pass method pass
{ {
## pass the exception to the outer context // pass the exception to the outer context
((self.handlerContext sender) findExceptionContext) handleException: self. ((self.handlerContext sender) findExceptionContext) handleException: self.
} }
@ -107,7 +107,7 @@ System logNl: '== END OF BACKTRACE =='.
method retry method retry
{ {
## TODO: verify if return:to: causes unnecessary stack growth. // TODO: verify if return:to: causes unnecessary stack growth.
if (self.handlerContext notNil) if (self.handlerContext notNil)
{ {
self.handlerContext pc: 0. self.handlerContext pc: 0.
@ -117,8 +117,8 @@ System logNl: '== END OF BACKTRACE =='.
method resume: value method resume: value
{ {
## TODO: verify if return:to: causes unnecessary stack growth. // TODO: verify if return:to: causes unnecessary stack growth.
## is this correct??? // is this correct???
| ctx | | ctx |
if ((self.signalContext notNil) and (self.handlerContext notNil)) if ((self.signalContext notNil) and (self.handlerContext notNil))
{ {
@ -135,7 +135,7 @@ System logNl: '== END OF BACKTRACE =='.
} }
} }
##============================================================================ //============================================================================
extend Context extend Context
{ {
method isExceptionContext method isExceptionContext
@ -167,11 +167,11 @@ extend Context
method unwindTo: context return: retval method unwindTo: context return: retval
{ {
## ------------------------------------------------------------------- // -------------------------------------------------------------------
## <<private>> // <<private>>
## private: called by VM upon unwinding as well as by // private: called by VM upon unwinding as well as by
## Exception<<signal and Error<<signal // Exception<<signal and Error<<signal
## ------------------------------------------------------------------- // -------------------------------------------------------------------
| ctx stop eb pending_pos | | ctx stop eb pending_pos |
@ -194,35 +194,35 @@ extend Context
stop := (ctx == context). stop := (ctx == context).
ctx := ctx sender. ctx := ctx sender.
## stop ifFalse: [ stop := ctx isNil ]. // stop ifFalse: [ stop := ctx isNil ].
}. }.
^retval ^retval
} }
} }
##============================================================================ //============================================================================
pooldic MethodContext.Preamble pooldic MethodContext.Preamble
{ {
## this must follow MOO_METHOD_PREAMBLE_EXCEPTION in moo.h // this must follow MOO_METHOD_PREAMBLE_EXCEPTION in moo.h
EXCEPTION := 13. EXCEPTION := 13.
## this must follow MOO_METHOD_PREAMBLE_ENSURE in moo.h // this must follow MOO_METHOD_PREAMBLE_ENSURE in moo.h
ENSURE := 14. ENSURE := 14.
} }
pooldic MethodContext.Index pooldic MethodContext.Index
{ {
## [ value-block ] ensure: [ ensure-block ] // [ value-block ] ensure: [ ensure-block ]
## assuming ensure block is a parameter the ensure: method to a // assuming ensure block is a parameter the ensure: method to a
## block context, the first parameter is placed after the fixed // block context, the first parameter is placed after the fixed
## instance variables of the method context. As MethodContex has // instance variables of the method context. As MethodContex has
## instance variables, the ensure block must be at the 9th position // instance variables, the ensure block must be at the 9th position
## which translates to index 8 // which translates to index 8
ENSURE := 8. ENSURE := 8.
## [ ... ] on: Exception: do: [:ex | ... ] // [ ... ] on: Exception: do: [:ex | ... ]
FIRST_ON := 8. FIRST_ON := 8.
} }
@ -263,12 +263,12 @@ extend MethodContext
* those must be skipped from scanning. */ * those must be skipped from scanning. */
size := self basicSize. size := self basicSize.
##8 priorTo: size by: 2 do: [ :i | //8 priorTo: size by: 2 do: [ :i |
## exc := self basicAt: i. // exc := self basicAt: i.
## if ((exception_class == exc) or: [exception_class inheritsFrom: exc]) { ^self basicAt: (i + 1) }. // if ((exception_class == exc) or: [exception_class inheritsFrom: exc]) { ^self basicAt: (i + 1) }.
##] //]
## start scanning from the position of the first parameter // start scanning from the position of the first parameter
i := MethodContext.Index.FIRST_ON. i := MethodContext.Index.FIRST_ON.
while (i < size) while (i < size)
{ {
@ -304,9 +304,9 @@ extend MethodContext
excblk := self findExceptionHandlerFor: (exception class). excblk := self findExceptionHandlerFor: (exception class).
if ((excblk isNil) or ((self basicAt: actpos) not)) if ((excblk isNil) or ((self basicAt: actpos) not))
{ {
## self is an exception context but doesn't have a matching // self is an exception context but doesn't have a matching
## exception handler or the exception context is already // exception handler or the exception context is already
## in the middle of evaluation. // in the middle of evaluation.
^(self.sender findExceptionContext) handleException: exception. ^(self.sender findExceptionContext) handleException: exception.
}. }.
@ -324,7 +324,7 @@ extend MethodContext
self basicAt: actpos put: true self basicAt: actpos put: true
]. ].
##(self.sender isNil) ifTrue: [ "TODO: CANNOT RETURN" ]. //(self.sender isNil) ifTrue: [ "TODO: CANNOT RETURN" ].
/* ----------------------------------------------------------------- /* -----------------------------------------------------------------
* return to self.sender which is a caller of the exception context (on:do:) * return to self.sender which is a caller of the exception context (on:do:)
@ -336,7 +336,7 @@ extend MethodContext
} }
} }
##============================================================================ //============================================================================
extend BlockContext extend BlockContext
{ {
method on: anException do: anExceptionBlock method on: anException do: anExceptionBlock
@ -347,9 +347,9 @@ extend BlockContext
/* ------------------------------- /* -------------------------------
thisContext isExceptionContext dump. thisContext isExceptionContext dump.
(thisContext basicSize) dump. (thisContext basicSize) dump.
(thisContext basicAt: 8) dump. ## this should be anException (thisContext basicAt: 8) dump. // this should be anException
(thisContext basicAt: 9) dump. ## this should be anExceptionBlock (thisContext basicAt: 9) dump. // this should be anExceptionBlock
(thisContext basicAt: 10) dump. ## this should be handlerActive (thisContext basicAt: 10) dump. // this should be handlerActive
'on:do: ABOUT TO EVALUE THE RECEIVER BLOCK' dump. 'on:do: ABOUT TO EVALUE THE RECEIVER BLOCK' dump.
---------------------------------- */ ---------------------------------- */
exception_active := true. exception_active := true.
@ -403,7 +403,7 @@ thisContext isExceptionContext dump.
} }
##============================================================================ //============================================================================
class PrimitiveFailureException(Exception) class PrimitiveFailureException(Exception)
{ {
var errcode. var errcode.
@ -504,27 +504,27 @@ extend Apex
if (msg isNil) { msg := ec asString }. if (msg isNil) { msg := ec asString }.
if (method notNil) { msg := msg & ' - ' & (method owner name) & '>>' & (method name) }. if (method notNil) { msg := msg & ' - ' & (method owner name) & '>>' & (method name) }.
### TODO: convert an exception to a more specific one depending on the error code. //# TODO: convert an exception to a more specific one depending on the error code.
###if (ec == Error.Code.ERANGE) { self index: index outOfRange: (self basicSize) } //#if (ec == Error.Code.ERANGE) { self index: index outOfRange: (self basicSize) }
### elsif (ec == Error.Code.EPERM) { self messageProhibited: method name } //# elsif (ec == Error.Code.EPERM) { self messageProhibited: method name }
### elsif (ec == Error.Code.ENOIMPL) { self subclassResponsibility: method name }. //# elsif (ec == Error.Code.ENOIMPL) { self subclassResponsibility: method name }.
(PrimitiveFailureException /* in: method */ withErrorCode: ec) signal: msg. (PrimitiveFailureException /* in: method */ withErrorCode: ec) signal: msg.
} }
method(#dual) doesNotUnderstand: message_name method(#dual) doesNotUnderstand: message_name
{ {
## TODO: implement this properly // TODO: implement this properly
| class_name ctx | | class_name ctx |
class_name := if (self class == Class) { self name } else { self class name }. class_name := if (self class == Class) { self name } else { self class name }.
## TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... // TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE...
System logNl: '== BACKTRACE =='. System logNl: '== BACKTRACE =='.
ctx := thisContext. ctx := thisContext.
while (ctx notNil) while (ctx notNil)
{ {
if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }. if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }.
## TODO: include blockcontext??? // TODO: include blockcontext???
ctx := ctx sender. ctx := ctx sender.
}. }.
System logNl: '== END OF BACKTRACE =='. System logNl: '== END OF BACKTRACE =='.

View File

@ -52,7 +52,7 @@ class FFI(Object)
f := self.ffi getsym(name). f := self.ffi getsym(name).
if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }. if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }.
self.funcs at: name put: f. self.funcs at: name put: f.
f. ## need this as at:put: returns an association f. // need this as at:put: returns an association
]. */ ]. */
f := self.funcs at: name ifAbsent: [ nil ]. f := self.funcs at: name ifAbsent: [ nil ].

View File

@ -1,4 +1,4 @@
###include 'Moo.moo'. //#include 'Moo.moo'.
#include 'Socket.moo'. #include 'Socket.moo'.
/* ------------------------------------------- /* -------------------------------------------
@ -219,7 +219,7 @@ class Fcgi.ParamRecord(Fcgi.Record)
if (aString notNil) if (aString notNil)
{ {
### TODO: implement this... //# TODO: implement this...
/* /*
(aString subStrings: %(char)) do: [:each | (aString subStrings: %(char)) do: [:each |
equal := each indexOf: $=. equal := each indexOf: $=.
@ -288,7 +288,7 @@ class FcgiConnReg(Object)
method initialize method initialize
{ {
| i size | | i size |
self.connections := Array new: 32. ## TODO: make it dynamic self.connections := Array new: 32. // TODO: make it dynamic
i := self.connections size. i := self.connections size.
if (i <= 0) if (i <= 0)
@ -336,9 +336,9 @@ class FcgiConnReg(Object)
method do: block method do: block
{ {
| index size conn | | index size conn |
## the following loop won't evaluate the given block for an element added after // the following loop won't evaluate the given block for an element added after
## resizing of self.connections at present, there is no self.connections resizing // resizing of self.connections at present, there is no self.connections resizing
## impelemented. so no worry on this. // impelemented. so no worry on this.
size := self.connections size. size := self.connections size.
index := 0. index := 0.
while (index < size) while (index < size)
@ -406,39 +406,39 @@ class FcgiSocket(SyncSocket)
'IM RUNNING SERVICE...............' dump. 'IM RUNNING SERVICE...............' dump.
## typedef struct { // typedef struct {
## unsigned char version; // unsigned char version;
## unsigned char type; // unsigned char type;
## unsigned char requestIdB1; // unsigned char requestIdB1;
## unsigned char requestIdB0; // unsigned char requestIdB0;
## unsigned char contentLengthB1; // unsigned char contentLengthB1;
## unsigned char contentLengthB0; // unsigned char contentLengthB0;
## unsigned char paddingLength; // unsigned char paddingLength;
## unsigned char reserved; // unsigned char reserved;
## } FCGI_Header; // } FCGI_Header;
/* /*
ver := self.bs next. ver := self.bs next.
type := self.bs next. type := self.bs next.
reqid := (self.bs next bitShift: 8) bitAnd: (self.bs next). ## can i implement nextUint16?? reqid := (self.bs next bitShift: 8) bitAnd: (self.bs next). // can i implement nextUint16??
clen := (self.bs next bitShift: 8) bitAnd: (self.bs next). clen := (self.bs next bitShift: 8) bitAnd: (self.bs next).
plen := self.bs next. plen := self.bs next.
self.bs next. ## eat up the reserved byte. self.bs next. // eat up the reserved byte.
*/ */
## typedef struct { // typedef struct {
## unsigned char roleB1; // unsigned char roleB1;
## unsigned char roleB0; // unsigned char roleB0;
## unsigned char flags; // unsigned char flags;
## unsigned char reserved[5]; // unsigned char reserved[5];
## } FCGI_BeginRequestBody; // } FCGI_BeginRequestBody;
## typedef struct { // typedef struct {
## unsigned char appStatusB3; // unsigned char appStatusB3;
## unsigned char appStatusB2; // unsigned char appStatusB2;
## unsigned char appStatusB1; // unsigned char appStatusB1;
## unsigned char appStatusB0; // unsigned char appStatusB0;
## unsigned char protocolStatus; // unsigned char protocolStatus;
## unsigned char reserved[3]; // unsigned char reserved[3];
## } FCGI_EndRequestBody; // } FCGI_EndRequestBody;
/* /*
if (type == Fcgi.Type.BEGIN_REQUEST) if (type == Fcgi.Type.BEGIN_REQUEST)
@ -516,7 +516,7 @@ cliaddr dump.
method acceptedSocketClass method acceptedSocketClass
{ {
##^if (self currentAddress port == 80) { FcgiSocket } else { FcgiSocket }. //^if (self currentAddress port == 80) { FcgiSocket } else { FcgiSocket }.
^FcgiSocket. ^FcgiSocket.
} }
@ -569,7 +569,7 @@ class FcgiServer(Object)
listener listen: 128. listener listen: 128.
] on: Exception do: [:ex | ] on: Exception do: [:ex |
listener close. listener close.
## ex pass. // ex pass.
Exception signal: ('unable to add new listener - ' & ex messageText). Exception signal: ('unable to add new listener - ' & ex messageText).
]. ].
} }
@ -598,7 +598,7 @@ class FcgiServer(Object)
{ {
| listener | | listener |
if (laddr class == Array) if (laddr class == Array)
##if (laddr respondsTo: #do:) ## can i check if the message receives a block and the block accepts 1 argument? //if (laddr respondsTo: #do:) // can i check if the message receives a block and the block accepts 1 argument?
{ {
laddr do: [:addr | self __add_new_listener: addr ]. laddr do: [:addr | self __add_new_listener: addr ].
} }
@ -647,7 +647,7 @@ class MyObject(Object)
}. }.
]. ].
clisck onEvent: #data_out do: [ :csck | clisck onEvent: #data_out do: [ :csck |
##csck writeBytesFrom: #[ $a, $b, C'\n' ]. //csck writeBytesFrom: #[ $a, $b, C'\n' ].
]. ].
clisck onEvent: #closed do: [ :csck | clisck onEvent: #closed do: [ :csck |
'Socket CLOSED....' dump. 'Socket CLOSED....' dump.
@ -713,7 +713,7 @@ class MyObject(Object)
{ {
ss := thisProcess handleAsyncEvent. ss := thisProcess handleAsyncEvent.
if (ss isError) { break }. if (ss isError) { break }.
###if (ss == st) { thisProcess removeAsyncSemaphore: st }. //#if (ss == st) { thisProcess removeAsyncSemaphore: st }.
}. }.
] ]
ensure: ensure:
@ -767,7 +767,7 @@ thisProcess terminate.
/* /*
[ [
addr := SocketAddress fromString: '1.2.3.4:5555'. addr := SocketAddress fromString: '1.2.3.4:5555'.
##addr := SocketAddress fromString: '127.0.0.1:22'. //addr := SocketAddress fromString: '127.0.0.1:22'.
fcgi := SyncSocket family: (addr family) type: Socket.Type.STREAM. fcgi := SyncSocket family: (addr family) type: Socket.Type.STREAM.
fcgi timeout: 5. fcgi timeout: 5.
fcgi connect: addr. fcgi connect: addr.

View File

@ -1,4 +1,4 @@
###include 'Moo.moo'. //#include 'Moo.moo'.
#include 'Socket.moo'. #include 'Socket.moo'.
class HttpConnReg(Object) class HttpConnReg(Object)
@ -10,7 +10,7 @@ class HttpConnReg(Object)
method initialize method initialize
{ {
| i size | | i size |
self.connections := Array new: 32. ## TODO: make it dynamic self.connections := Array new: 32. // TODO: make it dynamic
i := self.connections size. i := self.connections size.
if (i <= 0) if (i <= 0)
@ -58,9 +58,9 @@ class HttpConnReg(Object)
method do: block method do: block
{ {
| index size conn | | index size conn |
## the following loop won't evaluate the given block for an element added after // the following loop won't evaluate the given block for an element added after
## resizing of self.connections at present, there is no self.connections resizing // resizing of self.connections at present, there is no self.connections resizing
## impelemented. so no worry on this. // impelemented. so no worry on this.
size := self.connections size. size := self.connections size.
index := 0. index := 0.
while (index < size) while (index < size)
@ -199,7 +199,7 @@ cliaddr dump.
method acceptedSocketClass method acceptedSocketClass
{ {
##^if (self currentAddress port == 80) { HttpSocket } else { HttpSocket }. //^if (self currentAddress port == 80) { HttpSocket } else { HttpSocket }.
^HttpSocket. ^HttpSocket.
} }
@ -252,7 +252,7 @@ class HttpServer(Object)
listener listen: 128. listener listen: 128.
] on: Exception do: [:ex | ] on: Exception do: [:ex |
listener close. listener close.
## ex pass. // ex pass.
Exception signal: ('unable to add new listener - ' & ex messageText). Exception signal: ('unable to add new listener - ' & ex messageText).
]. ].
} }
@ -281,7 +281,7 @@ class HttpServer(Object)
{ {
| listener | | listener |
if (laddr class == Array) if (laddr class == Array)
##if (laddr respondsTo: #do:) ## can i check if the message receives a block and the block accepts 1 argument? //if (laddr respondsTo: #do:) // can i check if the message receives a block and the block accepts 1 argument?
{ {
laddr do: [:addr | self __add_new_listener: addr ]. laddr do: [:addr | self __add_new_listener: addr ].
} }
@ -330,7 +330,7 @@ class MyObject(Object)
}. }.
]. ].
clisck onEvent: #data_out do: [ :csck | clisck onEvent: #data_out do: [ :csck |
##csck writeBytesFrom: #[ $a, $b, C'\n' ]. //csck writeBytesFrom: #[ $a, $b, C'\n' ].
]. ].
clisck onEvent: #closed do: [ :csck | clisck onEvent: #closed do: [ :csck |
'Socket CLOSED....' dump. 'Socket CLOSED....' dump.
@ -396,7 +396,7 @@ class MyObject(Object)
{ {
ss := thisProcess handleAsyncEvent. ss := thisProcess handleAsyncEvent.
if (ss isError) { break }. if (ss isError) { break }.
###if (ss == st) { thisProcess removeAsyncSemaphore: st }. //#if (ss == st) { thisProcess removeAsyncSemaphore: st }.
}. }.
] ]
ensure: ensure:
@ -446,7 +446,7 @@ class MyObject(Object)
/* /*
[ [
addr := SocketAddress fromString: '1.2.3.4:5555'. addr := SocketAddress fromString: '1.2.3.4:5555'.
##addr := SocketAddress fromString: '127.0.0.1:22'. //addr := SocketAddress fromString: '127.0.0.1:22'.
httpd := SyncSocket family: (addr family) type: Socket.Type.STREAM. httpd := SyncSocket family: (addr family) type: Socket.Type.STREAM.
httpd timeout: 5. httpd timeout: 5.
httpd connect: addr. httpd connect: addr.

View File

@ -12,13 +12,13 @@ class Magnitude(Object)
method min: aMagnitude method min: aMagnitude
{ {
##^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude] //^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
^if (self < aMagnitude) { self } else { aMagnitude }. ^if (self < aMagnitude) { self } else { aMagnitude }.
} }
method max: aMagnitude method max: aMagnitude
{ {
##^self > aMagnitude ifTrue: [self] ifFalse: [aMagnitude] //^self > aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
^if (self > aMagnitude) { self } else { aMagnitude }. ^if (self > aMagnitude) { self } else { aMagnitude }.
} }
@ -67,8 +67,8 @@ class Association(Magnitude)
class(#limited) Character(Magnitude) class(#limited) Character(Magnitude)
{ {
## method(#primitive,#class) codePoint: code. // method(#primitive,#class) codePoint: code.
## method(#primitive) codePoint. // method(#primitive) codePoint.
method asCharacter { ^self } method asCharacter { ^self }
method(#primitive) asError. method(#primitive) asError.
@ -86,7 +86,7 @@ class(#limited) Character(Magnitude)
method digitValue method digitValue
{ {
##<primitive: #Character_digitValue> //<primitive: #Character_digitValue>
if ((self >= $0) and (self <= $9)) if ((self >= $0) and (self <= $9))
{ {
@ -101,7 +101,7 @@ class(#limited) Character(Magnitude)
^self asInteger - $a asInteger + 10 ^self asInteger - $a asInteger + 10
}. }.
##Exception signal: 'not a digit character'. //Exception signal: 'not a digit character'.
^-1 ^-1
} }
} }
@ -140,36 +140,36 @@ class(#limited) Number(Magnitude)
method div: aNumber method div: aNumber
{ {
## integer division rounded toward zero // integer division rounded toward zero
<primitive: #_number_div> <primitive: #_number_div>
self primitiveFailed. self primitiveFailed.
} }
method rem: aNumber method rem: aNumber
{ {
## integer remainder rounded toward zero // integer remainder rounded toward zero
<primitive: #Integer_rem> <primitive: #Integer_rem>
self primitiveFailed. self primitiveFailed.
} }
method mdiv: aNumber method mdiv: aNumber
{ {
## integer division quotient // integer division quotient
<primitive: #_number_mdiv> <primitive: #_number_mdiv>
self primitiveFailed. self primitiveFailed.
} }
method mod: aNumber method mod: aNumber
{ {
## integer division remainder // integer division remainder
<primitive: #Integer_mod> <primitive: #Integer_mod>
self primitiveFailed. self primitiveFailed.
} }
##method / aNumber //method / aNumber
##{ //{
## ## fraction? fixed-point decimal? floating-point? // // fraction? fixed-point decimal? floating-point?
##} //}
method = aNumber method = aNumber
{ {
@ -367,7 +367,7 @@ class(#limited) Integer(Number)
{ {
method timesRepeat: aBlock method timesRepeat: aBlock
{ {
## 1 to: self by: 1 do: [ :count | aBlock value ]. // 1 to: self by: 1 do: [ :count | aBlock value ].
| count | | count |
count := 0. count := 0.
while (count < self) { aBlock value. count := count + 1 } while (count < self) { aBlock value. count := count + 1 }
@ -375,10 +375,10 @@ class(#limited) Integer(Number)
method asInteger { ^self } method asInteger { ^self }
## integer has the scale of 0. // integer has the scale of 0.
method scale { ^0 } method scale { ^0 }
## non-zero positive scale converts integer to fixed-point decimal // non-zero positive scale converts integer to fixed-point decimal
method(#primitive) scale: ndigits. method(#primitive) scale: ndigits.
} }

View File

@ -46,7 +46,7 @@ class MyObject(Object)
/*k := Mill new. /*k := Mill new.
k register: #abc call: [ Dictionary new ]. k register: #abc call: [ Dictionary new ].
a := k make: #abc. a := k make: #abc.
##a dump.*/ //a dump.*/
d := Dictionary new. d := Dictionary new.
d at: #abc put: 20. d at: #abc put: 20.
@ -61,9 +61,9 @@ class MyObject(Object)
d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ]. d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ].
##(d includesAssociation: (Association key: #moo value: 'not good?')) dump. //(d includesAssociation: (Association key: #moo value: 'not good?')) dump.
'-------------------------' dump. '-------------------------' dump.
##(System at: #MyObject) dump. //(System at: #MyObject) dump.
(d removeKey: #moo) dump. (d removeKey: #moo) dump.
d removeKey: #abc ifAbsent: [System logNl: '#moo not found']. d removeKey: #abc ifAbsent: [System logNl: '#moo not found'].
d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ]. d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ].
@ -78,7 +78,7 @@ class MyObject(Object)
]. ].
*/ */
##System keysDo: [:k| System logNl: (k asString)] //System keysDo: [:k| System logNl: (k asString)]
/*[ /*[
[Exception hash dump] ensure: ['xxxx' dump]. [Exception hash dump] ensure: ['xxxx' dump].
@ -148,7 +148,7 @@ class MyObject(Object)
] value) dump. ] value) dump.
a := 5. a := 5.
##((a < 20) ifTrue: [ 1. if (a < 20) { ^^50 }. 90. ]) dump. //((a < 20) ifTrue: [ 1. if (a < 20) { ^^50 }. 90. ]) dump.
([true] whileTrue: [ ([true] whileTrue: [
[true] whileTrue: [ [true] whileTrue: [
[ [
@ -169,16 +169,16 @@ class MyObject(Object)
a := if(false) { 10 } elsif (false) { 20 } elsif (false) { 30} else { 40}. a := if(false) { 10 } elsif (false) { 20 } elsif (false) { 30} else { 40}.
##a := if(false) { 999 } else { 888 }. //a := if(false) { 999 } else { 888 }.
a dump. a dump.
a := 5. a := 5.
a := while (true) a := while (true)
{ {
a := a + 1. a := a + 1.
##if (a > 20) { break if (true) { break. }. }. //if (a > 20) { break if (true) { break. }. }.
if (a > 20) { if (a > 20) {
^if (true) { break } else {10}. ## return gets ignored for break. ^if (true) { break } else {10}. // return gets ignored for break.
}. }.
a dump. a dump.
}. }.
@ -188,13 +188,13 @@ class MyObject(Object)
do { do {
a := do { a := do {
('in loop.....' & a asString) dump. ('in loop.....' & a asString) dump.
##if (a > 5) { break }. //if (a > 5) { break }.
a := a + 1. a := a + 1.
} while(a < 10). } while(a < 10).
} while (false). } while (false).
a dump. a dump.
## these should be elimited by the compiler. // these should be elimited by the compiler.
nil. nil.
1. 1.
0. 0.
@ -203,14 +203,14 @@ class MyObject(Object)
thisContext. thisContext.
nil. nil.
nil. nil.
## end of elimination. // end of elimination.
## PROBLEM: the following double loop will exhaust the stack // PROBLEM: the following double loop will exhaust the stack
while (true) while (true)
{ {
while (true) while (true)
{ {
##[:j :q | (j + q) dump] value: (if (true) { 20 }) value: (if (true) { break }). //[:j :q | (j + q) dump] value: (if (true) { 20 }) value: (if (true) { break }).
(1 + (if (false) {} else { break })) dump. (1 + (if (false) {} else { break })) dump.
}. }.
}. }.
@ -240,14 +240,14 @@ class MyObject(Object)
a do: [ :v | v dump]. a do: [ :v | v dump].
/* /*
## how to handle return inside 'if' like the following??? // how to handle return inside 'if' like the following???
## what happens to the stack? // what happens to the stack?
a := if ((k := 20) == 10) {99} else { 100}. a := if ((k := 20) == 10) {99} else { 100}.
k dump. k dump.
a dump. a dump.
*/ */
'---------- END ------------' dump. '---------- END ------------' dump.
##System sleepForSecs: 20. //System sleepForSecs: 20.
} }
@ -256,21 +256,21 @@ class MyObject(Object)
{ {
|a i| |a i|
###self main_xx. //#self main_xx.
a := 100. a := 100.
## PROBLEM: the following double loop will exhaust the stack // PROBLEM: the following double loop will exhaust the stack
/* /*
while (true) while (true)
{ {
##111 dump. //111 dump.
while (true) while (true)
{ {
##[:j :q | (j + q) dump] value: (if (true) { 20 }) value: (if (true) { break }). //[:j :q | (j + q) dump] value: (if (true) { 20 }) value: (if (true) { break }).
(1 + (if (false) {} else { break })) dump. (1 + (if (false) {} else { break })) dump.
##break. //break.
##[:j :q | (j + q) dump] value: 10 value: 20. //[:j :q | (j + q) dump] value: 10 value: 20.
##if (false) {} else { break }. //if (false) {} else { break }.
}. }.
}.*/ }.*/
@ -281,14 +281,14 @@ class MyObject(Object)
'bbb' -> 30, 'bbb' -> 30,
#bbb -> 40, #bbb -> 40,
Association key: 12343 value: 129908123, Association key: 12343 value: 129908123,
##5 -> 99, //5 -> 99,
'ccc' -> 890 'ccc' -> 890
}. }.
/*a removeKey: 'bbb'. /*a removeKey: 'bbb'.
a remove: :(#bbb).*/ a remove: :(#bbb).*/
##1 to: 100 do: [ :i | a at: i put: (i * 2) ]. //1 to: 100 do: [ :i | a at: i put: (i * 2) ].
a keysAndValuesDo: [:k :v | a keysAndValuesDo: [:k :v |
k dump. k dump.
v dump. v dump.
@ -310,11 +310,11 @@ class MyObject(Object)
/* basicAt: 12 to access the nsdic field. use a proper method once it's defined in Class */ /* basicAt: 12 to access the nsdic field. use a proper method once it's defined in Class */
## (System nsdic) keysAndValuesDo: [:k :v | // (System nsdic) keysAndValuesDo: [:k :v |
## k dump. // k dump.
## v dump. // v dump.
## '------------' dump. // '------------' dump.
## ]. // ].
(System at: #Processor) dump. (System at: #Processor) dump.
@ -337,8 +337,8 @@ while (i > 0)
a getUint32(0) dump. a getUint32(0) dump.
a getUint32(1) dump. a getUint32(1) dump.
##a dump. //a dump.
##System free(a). //System free(a).
a free. a free.
System sleepForSecs: 2. System sleepForSecs: 2.
@ -365,6 +365,6 @@ a free.
/* /*
pooldic XXD { pooldic XXD {
#abc := #(1 2 3). #abc := #(1 2 3).
#def := %( 1, 3, 4 ). ## syntax error - literal expected where %( is #def := %( 1, 3, 4 ). // syntax error - literal expected where %( is
} }
*/ */

View File

@ -12,4 +12,4 @@
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
#include 'FFI.moo'. #include 'FFI.moo'.
#include 'Stdio.moo'. #include 'Stdio.moo'.
## #include 'Console.moo'. // #include 'Console.moo'.

View File

@ -20,30 +20,30 @@ class(#pointer,#final,#limited) Process(Object)
method terminate method terminate
{ {
## search from the top context of the process down to intial_context and find ensure blocks and execute them. // search from the top context of the process down to intial_context and find ensure blocks and execute them.
## if a different process calls 'terminate' on a process, // if a different process calls 'terminate' on a process,
## the ensureblock is not executed in the context of the // the ensureblock is not executed in the context of the
## process being terminated, but in the context of terminatig process. // process being terminated, but in the context of terminatig process.
## //
## 1) process termianted by another process // 1) process termianted by another process
## p := [ // p := [
## [ 1 to: 10000 by: 1 do: [:ex | System logNl: i asString] ] ensure: [System logNl: 'ensured....'] // [ 1 to: 10000 by: 1 do: [:ex | System logNl: i asString] ] ensure: [System logNl: 'ensured....']
## ] newProcess. // ] newProcess.
## p resume. // p resume.
## p terminate. // p terminate.
## //
## 2) process terminated by itself // 2) process terminated by itself
## p := [ // p := [
## [ thisProcess terminate. ] ensure: [System logNl: 'ensured....'] // [ thisProcess terminate. ] ensure: [System logNl: 'ensured....']
## ] newProcess. // ] newProcess.
## p resume. // p resume.
## p terminate. // p terminate.
## ---------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------
## the process must be frozen first. while unwinding is performed, // the process must be frozen first. while unwinding is performed,
## the process must not be scheduled. // the process must not be scheduled.
## ---------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------
##if (Processor activeProcess ~~ self) { self suspend }. //if (Processor activeProcess ~~ self) { self suspend }.
if (thisProcess ~~ self) { self suspend }. if (thisProcess ~~ self) { self suspend }.
self.currentContext unwindTo: self.initialContext return: nil. self.currentContext unwindTo: self.initialContext return: nil.
^self _terminate ^self _terminate
@ -75,13 +75,13 @@ class Semaphore(Object)
var waiting_head := nil, var waiting_head := nil,
waiting_tail := nil. waiting_tail := nil.
var count := 0. ## semaphore signal count var count := 0. // semaphore signal count
var subtype := nil. ## nil, io, timed var subtype := nil. // nil, io, timed
var heapIndex := nil, ## overlaps as ioIndex var heapIndex := nil, // overlaps as ioIndex
fireTimeSec := nil, ## overlaps as ioHandle fireTimeSec := nil, // overlaps as ioHandle
fireTimeNsec := nil. ## overlaps as ioType fireTimeNsec := nil. // overlaps as ioType
var(#get,#set) signalAction := nil. var(#get,#set) signalAction := nil.
@ -89,7 +89,7 @@ class Semaphore(Object)
_grm_next := nil, _grm_next := nil,
_grm_prev := nil. _grm_prev := nil.
## ================================================================== // ==================================================================
method(#primitive) signal. method(#primitive) signal.
method(#primitive) _wait. method(#primitive) _wait.
@ -102,7 +102,7 @@ class Semaphore(Object)
^k ^k
} }
## ================================================================== // ==================================================================
method(#primitive) signalAfterSecs: secs. method(#primitive) signalAfterSecs: secs.
method(#primitive) signalAfterSecs: secs nanosecs: nanosecs. method(#primitive) signalAfterSecs: secs nanosecs: nanosecs.
@ -111,7 +111,7 @@ class Semaphore(Object)
method(#primitive) signalOnGCFin. method(#primitive) signalOnGCFin.
method(#primitive) unsignal. method(#primitive) unsignal.
## ================================================================== // ==================================================================
method heapIndex: index method heapIndex: index
{ {
@ -122,9 +122,9 @@ class Semaphore(Object)
^self.heapIndex. ^self.heapIndex.
} }
## ------------------------------------------ // ------------------------------------------
## TODO: either put fireTimeNsec into implementation of fireTime, and related methods. // TODO: either put fireTimeNsec into implementation of fireTime, and related methods.
## ------------------------------------------ // ------------------------------------------
method fireTime method fireTime
{ {
^self.fireTimeSec ^self.fireTimeSec
@ -175,7 +175,7 @@ TODO: how to prohibit wait and signal???
class SemaphoreGroup(Object) class SemaphoreGroup(Object)
{ {
## the first two variables must match those of Semaphore. // the first two variables must match those of Semaphore.
var waiting_head := nil, var waiting_head := nil,
waiting_tail := nil. waiting_tail := nil.
@ -207,7 +207,7 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit
x := self _wait. x := self _wait.
if (x notError) if (x notError)
{ {
## TODO: is it better to check if x is an instance of Semaphore/SemaphoreGroup? // TODO: is it better to check if x is an instance of Semaphore/SemaphoreGroup?
if (x signalAction notNil) { x signalAction value: x }. if (x signalAction notNil) { x signalAction value: x }.
}. }.
^x ^x
@ -217,26 +217,26 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit
{ {
| s r | | s r |
## create an internal semaphore for timeout notification. // create an internal semaphore for timeout notification.
s := Semaphore new. s := Semaphore new.
self addSemaphore: s. self addSemaphore: s.
[ [
## arrange the processor to notify upon timeout. // arrange the processor to notify upon timeout.
s signalAfterSecs: seconds. s signalAfterSecs: seconds.
## wait on the semaphore group. // wait on the semaphore group.
r := self wait. r := self wait.
## if the internal semaphore has been signaled, // if the internal semaphore has been signaled,
## arrange to return nil to indicate timeout. // arrange to return nil to indicate timeout.
if (r == s) { r := nil } ## timed out if (r == s) { r := nil } // timed out
elsif (r signalAction notNil) { r signalAction value: r }. ## run the signal action block elsif (r signalAction notNil) { r signalAction value: r }. // run the signal action block
] ensure: [ ] ensure: [
## System<<unsignal: doesn't thrown an exception even if the semaphore s is not // System<<unsignal: doesn't thrown an exception even if the semaphore s is not
## register with System<<signal:afterXXX:. otherwise, i would do like this line // register with System<<signal:afterXXX:. otherwise, i would do like this line
## commented out. // commented out.
## [ s unsignal ] ensure: [ self removeSemaphore: s ]. // [ s unsignal ] ensure: [ self removeSemaphore: s ].
s unsignal. s unsignal.
self removeSemaphore: s self removeSemaphore: s
@ -318,7 +318,7 @@ class SemaphoreHeap(Object)
self.size := self.size - 1. self.size := self.size - 1.
if (anIndex == self.size) if (anIndex == self.size)
{ {
## the last item // the last item
self.arr at: self.size put: nil. self.arr at: self.size put: nil.
} }
else else
@ -366,13 +366,13 @@ class SemaphoreHeap(Object)
if (item notYoungerThan: par) { break }. if (item notYoungerThan: par) { break }.
## item is younger than the parent. // item is younger than the parent.
## move the parent down // move the parent down
self.arr at: cindex put: par. self.arr at: cindex put: par.
par heapIndex: cindex. par heapIndex: cindex.
}. }.
## place the item as high as it can // place the item as high as it can
self.arr at: cindex put: item. self.arr at: cindex put: item.
item heapIndex: cindex. item heapIndex: cindex.

View File

@ -1,22 +1,22 @@
#include 'Moo.moo'. #include 'Moo.moo'.
##interface IPAddressInterface //interface IPAddressInterface
##{ //{
##} //}
## class XXX(Object,IPAddressInterface) {} // class XXX(Object,IPAddressInterface) {}
class(#byte) IPAddress(Object) class(#byte) IPAddress(Object)
{ {
} }
### TODO: extend the compiler //# TODO: extend the compiler
### #byte(4) basic size if 4 bytes. basicNew: xxx creates an instance of the size 4 + xxx. //# #byte(4) basic size if 4 bytes. basicNew: xxx creates an instance of the size 4 + xxx.
### -> extend to support fixed 4 bytes by throwing an error in basicNew:. //# -> extend to support fixed 4 bytes by throwing an error in basicNew:.
### -> #byte(4,fixed)? //# -> #byte(4,fixed)?
### -> #byte -> byte variable/flexible //# -> #byte -> byte variable/flexible
### -> #byte(4) -> byte variable with the mimimum size of 4 //# -> #byte(4) -> byte variable with the mimimum size of 4
### -> (TODO)-> #byte(4,10) -> byte variable with the mimum size of 4 and maximum size of 10 => basicNew: should be allowed with upto 6. //# -> (TODO)-> #byte(4,10) -> byte variable with the mimum size of 4 and maximum size of 10 => basicNew: should be allowed with upto 6.
### -> #byte(4,4) -> it can emulated fixed byte size. -> do i have space in spec to store the upper bound? //# -> #byte(4,4) -> it can emulated fixed byte size. -> do i have space in spec to store the upper bound?
class(#byte(4)) IP4Address(IPAddress) class(#byte(4)) IP4Address(IPAddress)
{ {
@ -70,7 +70,7 @@ class(#byte(4)) IP4Address(IPAddress)
else else
{ {
^Error.Code.EINVAL ^Error.Code.EINVAL
### goto @label@. //# goto @label@.
}. }.
} }
while (true). while (true).
@ -98,10 +98,10 @@ class(#byte(16)) IP6Address(IP4Address)
^self basicNew: 16. ^self basicNew: 16.
}*/ }*/
##method(#class) fromString: str //method(#class) fromString: str
##{ //{
## ^self new fromString: str. // ^self new fromString: str.
##} //}
method __fromString: str method __fromString: str
{ {
@ -111,7 +111,7 @@ class(#byte(16)) IP6Address(IP4Address)
size := str size. size := str size.
mysize := self basicSize. mysize := self basicSize.
## handle leading :: specially // handle leading :: specially
if ((size > 0) and ((str at: pos) == $:)) if ((size > 0) and ((str at: pos) == $:))
{ {
pos := pos + 1. pos := pos + 1.
@ -143,17 +143,17 @@ class(#byte(16)) IP6Address(IP4Address)
curseg := pos. curseg := pos.
if (saw_xdigit not) if (saw_xdigit not)
{ {
## no multiple double colons are allowed // no multiple double colons are allowed
if (colonpos >= 0) { ^Error.Code.EINVAL }. if (colonpos >= 0) { ^Error.Code.EINVAL }.
## capture the target position when the double colons // capture the target position when the double colons
## are encountered. // are encountered.
colonpos := tgpos. colonpos := tgpos.
continue. continue.
} }
elsif (pos >= size) elsif (pos >= size)
{ {
## a colon can't be the last character // a colon can't be the last character
^Error.Code.EINVAL ^Error.Code.EINVAL
}. }.
@ -169,14 +169,14 @@ class(#byte(16)) IP6Address(IP4Address)
if ((ch == $.) and (tgpos + 4 <= mysize)) if ((ch == $.) and (tgpos + 4 <= mysize))
{ {
##if ((super __fromString: (str copyFrom: curseg) offset:0 offset: tgpos) isError) { ^Error.Code.EINVAL }. //if ((super __fromString: (str copyFrom: curseg) offset:0 offset: tgpos) isError) { ^Error.Code.EINVAL }.
if ((super __fromString: str offset: curseg offset: tgpos) isError) { ^Error.Code.EINVAL }. if ((super __fromString: str offset: curseg offset: tgpos) isError) { ^Error.Code.EINVAL }.
tgpos := tgpos + 4. tgpos := tgpos + 4.
saw_xdigit := false. saw_xdigit := false.
break. break.
}. }.
## invalid character in the address // invalid character in the address
^Error.Code.EINVAL. ^Error.Code.EINVAL.
}. }.
@ -190,9 +190,9 @@ class(#byte(16)) IP6Address(IP4Address)
if (colonpos >= 0) if (colonpos >= 0)
{ {
## double colon position // double colon position
self basicShiftFrom: colonpos to: (colonpos + (mysize - tgpos)) count: (tgpos - colonpos). self basicShiftFrom: colonpos to: (colonpos + (mysize - tgpos)) count: (tgpos - colonpos).
##tgpos := tgpos + (mysize - tgpos). //tgpos := tgpos + (mysize - tgpos).
} }
elsif (tgpos ~~ mysize) elsif (tgpos ~~ mysize)
{ {
@ -208,9 +208,9 @@ class(#byte(16)) IP6Address(IP4Address)
} }
} }
##method toString //method toString
##{ //{
##} //}
} }
class(#byte) SocketAddress(Object) from 'sck.addr' class(#byte) SocketAddress(Object) from 'sck.addr'
@ -226,11 +226,11 @@ class(#byte) SocketAddress(Object) from 'sck.addr'
class Socket(Object) from 'sck' class Socket(Object) from 'sck'
{ {
## the handle must be the first field in this object to match // the handle must be the first field in this object to match
## the internal representation used by various modules. (e.g. sck) // the internal representation used by various modules. (e.g. sck)
var(#get) handle := -1. var(#get) handle := -1.
## TODO: generate these family and type from the C header // TODO: generate these family and type from the C header
pooldic Family pooldic Family
{ {
INET := 2. INET := 2.
@ -244,8 +244,8 @@ class Socket(Object) from 'sck'
} }
method(#primitive) open(family, type, proto). method(#primitive) open(family, type, proto).
## map the open primitive again with a different name for strict internal use only. // map the open primitive again with a different name for strict internal use only.
## this method is supposed to be used to handle an accepted socket in server sockets. // this method is supposed to be used to handle an accepted socket in server sockets.
method(#primitive) __open(handle). method(#primitive) __open(handle).
method(#primitive) _close. method(#primitive) _close.
@ -265,16 +265,16 @@ class Socket(Object) from 'sck'
method(#class) __with_handle: handle method(#class) __with_handle: handle
{ {
###self addToBeFinalized. //#self addToBeFinalized.
^(super new) __open(handle) ^(super new) __open(handle)
} }
method(#class) family: family type: type method(#class) family: family type: type
{ {
###self addToBeFinalized. //#self addToBeFinalized.
## new is prohibited. so use _basicNew with initialize. // new is prohibited. so use _basicNew with initialize.
##^(self new) open(family, type, 0) //^(self new) open(family, type, 0)
^(super new) open(family, type, 0) ^(super new) open(family, type, 0)
} }
@ -292,7 +292,7 @@ class Socket(Object) from 'sck'
method onSocketClosed method onSocketClosed
{ {
## do nothing. // do nothing.
} }
} }
@ -307,16 +307,16 @@ class SyncSocket(Socket)
/* /*
method(#class) __with_handle: handle method(#class) __with_handle: handle
{ {
###self addToBeFinalized. //#self addToBeFinalized.
^(super new) __open(handle) ^(super new) __open(handle)
} }
method(#class) family: family type: type method(#class) family: family type: type
{ {
###self addToBeFinalized. //#self addToBeFinalized.
## new is prohibited. so use _basicNew with initialize. // new is prohibited. so use _basicNew with initialize.
##^(self new) open(family, type, 0) //^(self new) open(family, type, 0)
^(super new) open(family, type, 0) ^(super new) open(family, type, 0)
} }
*/ */
@ -335,7 +335,7 @@ class SyncSocket(Socket)
method beWatched method beWatched
{ {
## do nothing. i don't want to be watched. // do nothing. i don't want to be watched.
} }
method timeout: secs method timeout: secs
@ -370,10 +370,10 @@ class SyncSocket(Socket)
{ {
| soerr | | soerr |
## an exception is thrown upon exception failure. // an exception is thrown upon exception failure.
if ((super _connect: addr) <= -1) if ((super _connect: addr) <= -1)
{ {
## connection in progress // connection in progress
while (true) while (true)
{ {
self __wait_for_output. self __wait_for_output.
@ -549,9 +549,9 @@ class AsyncSocket(Socket)
Exception signal: 'Not allowed to write again'. Exception signal: 'Not allowed to write again'.
}. }.
## n >= 0: written // n >= 0: written
## n <= -1: tolerable error (e.g. EAGAIN) // n <= -1: tolerable error (e.g. EAGAIN)
## exception: fatal error // exception: fatal error
pos := offset. pos := offset.
rem := length. rem := length.
@ -583,9 +583,9 @@ class AsyncSocket(Socket)
^self writeBytesFrom: bytes offset: 0 length: (bytes size) ^self writeBytesFrom: bytes offset: 0 length: (bytes size)
} }
##method onSocketClosed //method onSocketClosed
##{ //{
##} //}
method onSocketDataIn method onSocketDataIn
{ {
@ -612,7 +612,7 @@ class AsyncClientSocket(AsyncSocket)
soerr := self _socketError. soerr := self _socketError.
if (soerr >= 0) if (soerr >= 0)
{ {
## finalize connection if not in progress // finalize connection if not in progress
sem unsignal. sem unsignal.
thisProcess removeAsyncSemaphore: sem. thisProcess removeAsyncSemaphore: sem.
@ -644,7 +644,7 @@ class AsyncClientSocket(AsyncSocket)
} }
else else
{ {
## connected immediately // connected immediately
'IMMEDIATELY CONNECTED.....' dump. 'IMMEDIATELY CONNECTED.....' dump.
self onSocketConnected: true. self onSocketConnected: true.
@ -656,7 +656,7 @@ class AsyncClientSocket(AsyncSocket)
method onSocketConnected method onSocketConnected
{ {
## do nothing special. the subclass may override this method. // do nothing special. the subclass may override this method.
} }
} }
@ -672,7 +672,7 @@ class AsyncServerSocket(AsyncSocket)
cliaddr := SocketAddress new. cliaddr := SocketAddress new.
fd := self _accept: cliaddr. fd := self _accept: cliaddr.
##if (fd >= 0) //if (fd >= 0)
if (fd notNil) if (fd notNil)
{ {
clisck := (self acceptedSocketClass) __with_handle: fd. clisck := (self acceptedSocketClass) __with_handle: fd.
@ -699,13 +699,13 @@ class AsyncServerSocket(AsyncSocket)
{ {
| n | | n |
## If listen is called before the socket handle is // If listen is called before the socket handle is
## added to the multiplexer, a spurious hangup event might // added to the multiplexer, a spurious hangup event might
## be generated. At least, such behavior was observed // be generated. At least, such behavior was observed
## in linux with epoll in the level trigger mode. // in linux with epoll in the level trigger mode.
## self.inreadysem signalOnInput: self.handle. // self.inreadysem signalOnInput: self.handle.
## thisProcess addAsyncSemaphore: self.inreadysem. // thisProcess addAsyncSemaphore: self.inreadysem.
## self _listen: backlog. // self _listen: backlog.
n := self _listen: backlog. n := self _listen: backlog.
self.inreadysem signalOnInput: self.handle. self.inreadysem signalOnInput: self.handle.
@ -715,8 +715,8 @@ class AsyncServerSocket(AsyncSocket)
method onSocketAccepted: clisck from: cliaddr method onSocketAccepted: clisck from: cliaddr
{ {
## close the accepted client socket immediately. // close the accepted client socket immediately.
## a subclass must override this to avoid it. // a subclass must override this to avoid it.
clisck close. clisck close.
} }
@ -741,7 +741,7 @@ class ListenerSocket(Socket)
cliaddr := SocketAddress new. cliaddr := SocketAddress new.
fd := self _accept: cliaddr. fd := self _accept: cliaddr.
##if (fd >= 0) //if (fd >= 0)
if (fd notNil) if (fd notNil)
{ {
clisck := (self acceptedSocketClass) __with_handle: fd. clisck := (self acceptedSocketClass) __with_handle: fd.
@ -773,13 +773,13 @@ class ListenerSocket(Socket)
{ {
| n | | n |
## If listen is called before the socket handle is // If listen is called before the socket handle is
## added to the multiplexer, a spurious hangup event might // added to the multiplexer, a spurious hangup event might
## be generated. At least, such behavior was observed // be generated. At least, such behavior was observed
## in linux with epoll in the level trigger mode. // in linux with epoll in the level trigger mode.
## self.inreadysem signalOnInput: self.handle. // self.inreadysem signalOnInput: self.handle.
## thisProcess addAsyncSemaphore: self.inreadysem. // thisProcess addAsyncSemaphore: self.inreadysem.
## self _listen: backlog. // self _listen: backlog.
n := self _listen: backlog. n := self _listen: backlog.
@ -795,8 +795,8 @@ class ListenerSocket(Socket)
method onSocketAccepted: clisck from: cliaddr method onSocketAccepted: clisck from: cliaddr
{ {
## close the accepted client socket immediately. // close the accepted client socket immediately.
## a subclass must override this to avoid it. // a subclass must override this to avoid it.
clisck close. clisck close.
} }

View File

@ -66,8 +66,8 @@ class Stdio2(Stdio)
{ {
method(#class) new method(#class) new
{ {
##self prohibited //self prohibited
##raise exception. prohibited... //raise exception. prohibited...
^(super new). ^(super new).
} }
} }

View File

@ -2,7 +2,7 @@ class Stream(Object)
{ {
method(#class) new method(#class) new
{ {
## you must use dedicated class methods for instantiation // you must use dedicated class methods for instantiation
self messageProhibited: #new. self messageProhibited: #new.
} }
@ -18,13 +18,13 @@ class Stream(Object)
method next method next
{ {
## return the next object in the receiver // return the next object in the receiver
^self subclassResponsibility: #next. ^self subclassResponsibility: #next.
} }
method nextPut: object method nextPut: object
{ {
## insert an object at the next position in the receiver // insert an object at the next position in the receiver
^self subclassResponsibility: #next. ^self subclassResponsibility: #next.
} }
@ -100,7 +100,7 @@ class PositionableStream(Stream)
method position: pos method position: pos
{ {
##if (pos >= 0 and //if (pos >= 0 and
} }
method reset method reset
@ -126,7 +126,7 @@ class ExternalStream(ReadWriteStream)
} }
/* /*
## mimic java's interface... // mimic java's interface...
interface ByteStreamable interface ByteStreamable
{ {
readBytesInto: readBytesInto:
@ -134,7 +134,7 @@ interface ByteStreamable
} }
*/ */
### TODO: specify interface inside [] //# TODO: specify interface inside []
/* /*
difficulty: how to ensure that the class implements the defined interface? difficulty: how to ensure that the class implements the defined interface?
@ -188,7 +188,7 @@ extension String: StringConvertible {
Let me think about it.. Let me think about it..
*/ */
class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] class ByteStreamAdapter(Object) //# [ByteStreamable, ByteXXX]
{ {
var bsobj. var bsobj.
var inbuf. var inbuf.
@ -239,12 +239,12 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
{ {
| v | | v |
v := self.bsobj readBytesInto: self.inbuf. v := self.bsobj readBytesInto: self.inbuf.
## if the streamable object is not blocking, it may return an // if the streamable object is not blocking, it may return an
## error object when data is not ready. // error object when data is not ready.
if (v isError) { ^v }. if (v isError) { ^v }.
if (v == 0) if (v == 0)
{ {
## end of input // end of input
self.indown := true. self.indown := true.
^v ^v
}. }.
@ -262,9 +262,9 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
if (self.inpos >= self.inlen) if (self.inpos >= self.inlen)
{ {
v := self __fill_inbuf. v := self __fill_inbuf.
if (v isError) { ^v }. ## TODO: change error handling if (v isError) { ^v }. // TODO: change error handling
if (v <= 0) { ^nil }. if (v <= 0) { ^nil }.
####if (self.inpos >= self.inlen) { ^nil }. ////if (self.inpos >= self.inlen) { ^nil }.
}. }.
v := self.inbuf at: self.inpos. v := self.inbuf at: self.inpos.
@ -274,15 +274,15 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
method next: count into: byte_array startingAt: pos method next: count into: byte_array startingAt: pos
{ {
## return the count bytes // return the count bytes
| taken avail needed v incapa | | taken avail needed v incapa |
if (self.indown) { ^0 }. if (self.indown) { ^0 }.
## i assume the given byte array is large enough // i assume the given byte array is large enough
## to store as many as count bytes starting at the pos position. // to store as many as count bytes starting at the pos position.
## if the parameters cannot meet this assumption, you will get // if the parameters cannot meet this assumption, you will get
## into various system exceptions. // into various system exceptions.
needed := count. needed := count.
incapa := self.inbuf size. incapa := self.inbuf size.
@ -293,11 +293,11 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
{ {
if (needed >= incapa) if (needed >= incapa)
{ {
## don't rely on the internal buffer if the number of bytes // don't rely on the internal buffer if the number of bytes
## needed are equal to or greater than the capacity of the // needed are equal to or greater than the capacity of the
## buffer. // buffer.
v := self.bsobj readBytesInto: byte_array offset: pos length: needed. v := self.bsobj readBytesInto: byte_array offset: pos length: needed.
if (v isError or v <= 0) { break }. ## <<< TODO: change the error handling if (v isError or v <= 0) { break }. // <<< TODO: change the error handling
pos := pos + v. pos := pos + v.
needed := needed - v. needed := needed - v.
continue. continue.
@ -305,7 +305,7 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
else else
{ {
v := self __fill_inbuf. v := self __fill_inbuf.
if (v isError or v <= 0) { break }. ## <<< TODO: change the error handling if (v isError or v <= 0) { break }. // <<< TODO: change the error handling
}. }.
}. }.
@ -333,13 +333,13 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
free := outcapa - self.outlen. free := outcapa - self.outlen.
if (free <= 0) if (free <= 0)
{ {
self flush. ## TODO: error handling... self flush. // TODO: error handling...
}. }.
if (self.outlen <= 0 and rem >= outcapa) if (self.outlen <= 0 and rem >= outcapa)
{ {
consumed := self.bsobj writeBytesFrom: byte_array offset: pos length: rem. consumed := self.bsobj writeBytesFrom: byte_array offset: pos length: rem.
if (consumed <= 0) { break }. ## TODO: error handling. also handle exceptions if (consumed <= 0) { break }. // TODO: error handling. also handle exceptions
} }
else else
{ {
@ -363,7 +363,7 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
while (pos < self.outlen) while (pos < self.outlen)
{ {
v := self.bsobj writeBytesFrom: self.outbuf offset: pos length: (self.outlen - pos). v := self.bsobj writeBytesFrom: self.outbuf offset: pos length: (self.outlen - pos).
if (v <= 0) { break }. ## TODO: error handling. also handle exceptions if (v <= 0) { break }. // TODO: error handling. also handle exceptions
pos := pos + v. pos := pos + v.
}. }.

View File

@ -1,12 +1,12 @@
## TODO: consider if System can replace Apex itself. // TODO: consider if System can replace Apex itself.
## System, being the top class, seems to give very natural way of // System, being the top class, seems to give very natural way of
## offering global system-level functions and interfaces. // offering global system-level functions and interfaces.
## //
## class System(nil) { ... } // class System(nil) { ... }
## class Object(System) { .... } // class Object(System) { .... }
## System at: # // System at: #
## System logNl: 'xxxxx'. // System logNl: 'xxxxx'.
## System getUint8(ptr,offset) // System getUint8(ptr,offset)
class System(Apex) class System(Apex)
{ {
@ -14,10 +14,10 @@ class System(Apex)
pooldic Log pooldic Log
{ {
## ----------------------------------------------------------- // -----------------------------------------------------------
## defines log levels // defines log levels
## these items must follow defintions in moo.h // these items must follow defintions in moo.h
## ----------------------------------------------------------- // -----------------------------------------------------------
DEBUG := 1. DEBUG := 1.
INFO := 2. INFO := 2.
@ -47,19 +47,19 @@ class System(Apex)
self.asyncsg := SemaphoreGroup new. self.asyncsg := SemaphoreGroup new.
class := self at: class_name. ## System at: class_name. class := self at: class_name. // System at: class_name.
if (class isError) if (class isError)
{ {
self error: ('Cannot find the class - ' & class_name). self error: ('Cannot find the class - ' & class_name).
}. }.
## start the gc finalizer process // start the gc finalizer process
[ self __gc_finalizer ] fork. [ self __gc_finalizer ] fork.
## TODO: change the method signature to variadic and pass extra arguments to perform??? // TODO: change the method signature to variadic and pass extra arguments to perform???
ret := class perform: method_name. ret := class perform: method_name.
#### System logNl: '======= END of startup ==============='. //// System logNl: '======= END of startup ==============='.
^ret. ^ret.
} }
@ -77,14 +77,14 @@ class System(Apex)
{ {
while ((tmp := self _popCollectable) notError) while ((tmp := self _popCollectable) notError)
{ {
## TODO: Do i have to protected this in an exception handler??? // TODO: Do i have to protected this in an exception handler???
if (tmp respondsTo: #finalize) { tmp finalize }. if (tmp respondsTo: #finalize) { tmp finalize }.
}. }.
##if (Processor total_count == 1) //if (Processor total_count == 1)
if (Processor should_exit) if (Processor should_exit)
{ {
## exit from this loop when there are no other processes running except this finalizer process // exit from this loop when there are no other processes running except this finalizer process
if (gc) if (gc)
{ {
System logNl: 'Exiting the GC finalization process ' & (thisProcess id) asString. System logNl: 'Exiting the GC finalization process ' & (thisProcess id) asString.
@ -100,10 +100,10 @@ class System(Apex)
gc := false. gc := false.
}. }.
##System logNl: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^gc_waiting....'. //System logNl: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^gc_waiting....'.
##System sleepForSecs: 1. ## TODO: wait on semaphore instead.. //System sleepForSecs: 1. // TODO: wait on semaphore instead..
gcfin_sem wait. gcfin_sem wait.
##System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX gc_waitED....'. //System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX gc_waitED....'.
} }
] ensure: [ ] ensure: [
gcfin_sem unsignal. gcfin_sem unsignal.
@ -116,12 +116,12 @@ class System(Apex)
method(#class,#primitive) gc. method(#class,#primitive) gc.
method(#class,#primitive) return: object to: context. method(#class,#primitive) return: object to: context.
## ======================================================================================= // =======================================================================================
method(#class) sleepForSecs: secs method(#class) sleepForSecs: secs
{ {
## ----------------------------------------------------- // -----------------------------------------------------
## put the calling process to sleep for given seconds. // put the calling process to sleep for given seconds.
## ----------------------------------------------------- // -----------------------------------------------------
| s | | s |
s := Semaphore new. s := Semaphore new.
s signalAfterSecs: secs. s signalAfterSecs: secs.
@ -130,20 +130,20 @@ class System(Apex)
method(#class) sleepForSecs: secs nanosecs: nanosecs method(#class) sleepForSecs: secs nanosecs: nanosecs
{ {
## ----------------------------------------------------- // -----------------------------------------------------
## put the calling process to sleep for given seconds. // put the calling process to sleep for given seconds.
## ----------------------------------------------------- // -----------------------------------------------------
| s | | s |
s := Semaphore new. s := Semaphore new.
s signalAfterSecs: secs nanosecs: nanosecs. s signalAfterSecs: secs nanosecs: nanosecs.
s wait. s wait.
} }
## the following methods may not look suitable to be placed // the following methods may not look suitable to be placed
## inside a system dictionary. but they are here for quick and dirty // inside a system dictionary. but they are here for quick and dirty
## output production from the moo code. // output production from the moo code.
## System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'. // System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'.
## //
method(#class,#variadic,#primitive) log(level,msg1). method(#class,#variadic,#primitive) log(level,msg1).
/* /*
@ -156,30 +156,30 @@ TODO: how to pass all variadic arguments to another variadic methods???
method(#class) atLevel: level log: message method(#class) atLevel: level log: message
{ {
<primitive: #System_log> <primitive: #System_log>
## do nothing upon logging failure // do nothing upon logging failure
} }
method(#class) atLevel: level log: message and: message2 method(#class) atLevel: level log: message and: message2
{ {
<primitive: #System_log> <primitive: #System_log>
## do nothing upon logging failure // do nothing upon logging failure
} }
method(#class) atLevel: level log: message and: message2 and: message3 method(#class) atLevel: level log: message and: message2 and: message3
{ {
<primitive: #System_log> <primitive: #System_log>
## do nothing upon logging failure // do nothing upon logging failure
} }
method(#class) atLevel: level logNl: message method(#class) atLevel: level logNl: message
{ {
## the #_log primitive accepts an array. // the #_log primitive accepts an array.
## so the following lines should work also. // so the following lines should work also.
## | x | // | x |
## x := Array new: 2. // x := Array new: 2.
## x at: 0 put: message. // x at: 0 put: message.
## x at: 1 put: S'\n'. // x at: 1 put: S'\n'.
## ^self atLevel: level log: x. // ^self atLevel: level log: x.
^self atLevel: level log: message and: S'\n'. ^self atLevel: level log: message and: S'\n'.
} }
@ -235,11 +235,11 @@ TODO: how to pass all variadic arguments to another variadic methods???
method(#class,#primitive) free: rawptr. method(#class,#primitive) free: rawptr.
/* raw memory access */ /* raw memory access */
method(#class,#primitive) getInt8 (rawptr, offset). ## <primitive: #System__getInt8> method(#class,#primitive) getInt8 (rawptr, offset). // <primitive: #System__getInt8>
method(#class,#primitive) getInt16 (rawptr, offset). method(#class,#primitive) getInt16 (rawptr, offset).
method(#class,#primitive) getInt32 (rawptr, offset). method(#class,#primitive) getInt32 (rawptr, offset).
method(#class,#primitive) getInt64 (rawptr, offset). method(#class,#primitive) getInt64 (rawptr, offset).
method(#class,#primitive) getUint8 (rawptr, offset). ## <primitive: #System__getUint8> method(#class,#primitive) getUint8 (rawptr, offset). // <primitive: #System__getUint8>
method(#class,#primitive) getUint16 (rawptr, offset). method(#class,#primitive) getUint16 (rawptr, offset).
method(#class,#primitive) getUint32 (rawptr, offset). method(#class,#primitive) getUint32 (rawptr, offset).
method(#class,#primitive) getUint64 (rawptr, offset). method(#class,#primitive) getUint64 (rawptr, offset).

View File

@ -29,15 +29,15 @@ method(#dual,#liberal) def(x, z) { ^nil }
class X11(Object) [X11able,selfns.X11able3] from 'x11' class X11(Object) [X11able,selfns.X11able3] from 'x11'
{ {
## ===================================================================== // =====================================================================
## this part of the class must match the internal // this part of the class must match the internal
## definition struct x11_t defined in _x11.h // definition struct x11_t defined in _x11.h
## --------------------------------------------------------------------- // ---------------------------------------------------------------------
var display_base := nil. var display_base := nil.
## ===================================================================== // =====================================================================
var shell_container := nil. var shell_container := nil.
var window_registrar. ## all windows registered var window_registrar. // all windows registered
var event_loop_sem, event_loop_proc. var event_loop_sem, event_loop_proc.
var llevent_blocks. var llevent_blocks.
@ -45,7 +45,7 @@ class X11(Object) [X11able,selfns.X11able3] from 'x11'
method(#dual) abc { ^nil } method(#dual) abc { ^nil }
method(#dual,#liberal) def(x, z) { ^nil } method(#dual,#liberal) def(x, z) { ^nil }
###method(#dual) abc3 { ^nil } //#method(#dual) abc3 { ^nil }
interface X11able3 interface X11able3
{ {
@ -108,8 +108,8 @@ TODO: TODO: compiler enhancement
method(#primitive) _destroy_window(window_handle). method(#primitive) _destroy_window(window_handle).
method(#primitive) _create_gc (window_handle). method(#primitive) _create_gc (window_handle).
method(#primitive) _destroy_gc (gc). ## note this one accepts a GC object. method(#primitive) _destroy_gc (gc). // note this one accepts a GC object.
method(#primitive) _apply_gc (gc). ## note this one accepts a GC object, not a GC handle. method(#primitive) _apply_gc (gc). // note this one accepts a GC object, not a GC handle.
method(#primitive) _draw_rectangle(window_handle, gc_handle, x, y, width, height). method(#primitive) _draw_rectangle(window_handle, gc_handle, x, y, width, height).
method(#primitive) _fill_rectangle(window_handle, gc_handle, x, y, width, height). method(#primitive) _fill_rectangle(window_handle, gc_handle, x, y, width, height).
@ -126,15 +126,15 @@ TODO: TODO: compiler enhancement
method __destroy_window(window_handle) method __destroy_window(window_handle)
{ {
| w | | w |
###('DESTROY ' & window_handle asString) dump. //#('DESTROY ' & window_handle asString) dump.
w := self _destroy_window(window_handle). w := self _destroy_window(window_handle).
if (w notError) { self.window_registrar removeKey: window_handle } if (w notError) { self.window_registrar removeKey: window_handle }
} }
} }
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
## Event // Event
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
pooldic X11.LLEventType pooldic X11.LLEventType
{ {
KEY_PRESS := 2. KEY_PRESS := 2.
@ -179,7 +179,7 @@ class X11.MouseEvent(X11.Event)
var(#get,#set) var(#get,#set)
x := 0, x := 0,
y := 0, y := 0,
button := 0. ## X11.MouseButton button := 0. // X11.MouseButton
} }
class X11.MouseWheelEvent(X11.Event) class X11.MouseWheelEvent(X11.Event)
@ -201,9 +201,9 @@ class X11.ExposeEvent(X11.Event)
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
## X11 Context // X11 Context
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
pooldic X11.GCLineStyle pooldic X11.GCLineStyle
{ {
SOLID := 0. SOLID := 0.
@ -221,7 +221,7 @@ pooldic X11.GCFillStyle
class X11.GC(Object) class X11.GC(Object)
{ {
## note these fields must match the x11_gc_t structure defined in _x11.h // note these fields must match the x11_gc_t structure defined in _x11.h
var(#get) widget := nil, gcHandle := nil. var(#get) widget := nil, gcHandle := nil.
@ -293,9 +293,9 @@ widget windowHandle dump.
} }
} }
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
## X11 Widgets // X11 Widgets
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
class X11.Widget(Object) class X11.Widget(Object)
{ {
@ -505,7 +505,7 @@ class X11.Composite(X11.Widget)
{ {
super onPaintEvent: event. super onPaintEvent: event.
self.children do: [:child | self.children do: [:child |
## TODO: adjust event relative to each child... // TODO: adjust event relative to each child...
child onPaintEvent: event. child onPaintEvent: event.
] ]
} }
@ -521,16 +521,16 @@ class X11.Shell(X11.Composite)
self.title := title. self.title := title.
} }
#### TODO: //// TODO:
#### redefine x:, y:, width:, height: to return actual geometry values... //// redefine x:, y:, width:, height: to return actual geometry values...
#### ////
method title: title method title: title
{ {
self.title := title. self.title := title.
if (self.windowHandle notNil) if (self.windowHandle notNil)
{ {
## set window title of this window. // set window title of this window.
} }
} }
@ -554,9 +554,9 @@ class X11.Shell(X11.Composite)
} }
} }
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
## X11 server // X11 server
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
extend X11 extend X11
{ {
method(#class) new method(#class) new
@ -667,7 +667,7 @@ extend X11
{ {
if (llevent isError) if (llevent isError)
{ {
##System logNl: ('Error while getting a event from server ' & self.cid asString). //System logNl: ('Error while getting a event from server ' & self.cid asString).
ongoing := false. ongoing := false.
break. break.
} }
@ -681,7 +681,7 @@ extend X11
'CLOSING X11 EVENT LOOP' dump. 'CLOSING X11 EVENT LOOP' dump.
self.event_loop_sem unsignal. self.event_loop_sem unsignal.
## TODO: LOOK HERE FOR RACE CONDITION // TODO: LOOK HERE FOR RACE CONDITION
self.event_loop_sem := nil. self.event_loop_sem := nil.
self.event_loop_proc := nil. self.event_loop_proc := nil.
@ -694,7 +694,7 @@ extend X11
{ {
if (self.event_loop_sem notNil) if (self.event_loop_sem notNil)
{ {
## TODO: handle race-condition with the part maked 'LOOK HERE FOR RACE CONDITION' // TODO: handle race-condition with the part maked 'LOOK HERE FOR RACE CONDITION'
self.event_loop_proc terminate. self.event_loop_proc terminate.
self.event_loop_proc := nil. self.event_loop_proc := nil.
self.event_loop_sem := nil. self.event_loop_sem := nil.
@ -810,7 +810,7 @@ class MyObject(Object)
comp1 add: (X11.Label new text: '간다'; width: 100; height: 100). comp1 add: (X11.Label new text: '간다'; width: 100; height: 100).
comp1 add: (X11.Label new text: 'crayon'; x: 90; y: 90; width: 100; height: 100). comp1 add: (X11.Label new text: 'crayon'; x: 90; y: 90; width: 100; height: 100).
## self.shell1 add: (X11.Label new text: 'xxxxxxxx'; width: 100; height: 100). // self.shell1 add: (X11.Label new text: 'xxxxxxxx'; width: 100; height: 100).
self.shell1 add: (X11.Button new text: '크레용crayon'; x: 90; y: 90; width: 100; height: 100). self.shell1 add: (X11.Button new text: '크레용crayon'; x: 90; y: 90; width: 100; height: 100).
self.shell2 add: (X11.Button new text: 'crayon'; x: 90; y: 90; width: 100; height: 100). self.shell2 add: (X11.Button new text: 'crayon'; x: 90; y: 90; width: 100; height: 100).
@ -819,7 +819,7 @@ class MyObject(Object)
self.shell2 realize. self.shell2 realize.
self.shell3 realize. self.shell3 realize.
self.disp1 enterEventLoop. ## this is not a blocking call. it spawns another process. self.disp1 enterEventLoop. // this is not a blocking call. it spawns another process.
self.disp2 enterEventLoop. self.disp2 enterEventLoop.
comp1 := Fx new. comp1 := Fx new.

View File

@ -1,6 +1,6 @@
## //
## TEST CASES for namespacing // TEST CASES for namespacing
## //
#include 'Moo.moo'. #include 'Moo.moo'.
@ -56,7 +56,7 @@ class MyObject.System.Horse (Donkey)
method(#class) myns2 { [^selfns] value } method(#class) myns2 { [^selfns] value }
method(#class) donkey1 { ^Donkey } method(#class) donkey1 { ^Donkey }
method(#class) donkey2 { ^selfns.Donkey } ## should return same as MyObject.System.Donkey method(#class) donkey2 { ^selfns.Donkey } // should return same as MyObject.System.Donkey
method(#class) donkey3 { ^MyObject.Donkey } method(#class) donkey3 { ^MyObject.Donkey }
method(#class) horse1 { ^Horse } method(#class) horse1 { ^Horse }
@ -98,13 +98,13 @@ class MyObject.System.Stallion (selfns.Donkey)
method(#class) party { ^Party } method(#class) party { ^Party }
method(#class) system1 { ^System } ## Single word. can be looked up in the current workspace. method(#class) system1 { ^System } // Single word. can be looked up in the current workspace.
method(#class) system2 { ^System.System } ## Dotted. The search begins at the top. method(#class) system2 { ^System.System } // Dotted. The search begins at the top.
} }
extend MyObject extend MyObject
{ {
## TODO: support import in extend?? // TODO: support import in extend??
method(#class) makeBlock(a,b) method(#class) makeBlock(a,b)
{ {
@ -116,7 +116,7 @@ extend MyObject
|a b | |a b |
a := self makeBlock (12, 22). a := self makeBlock (12, 22).
b := self makeBlock (99, 4). b := self makeBlock (99, 4).
^(a value: 5) * (b value: 6). ## (12 * 5 + 22) * (99 * 6 + 4) => 49036 ^(a value: 5) * (b value: 6). // (12 * 5 + 22) * (99 * 6 + 4) => 49036
} }
method(#class) testBigintDiv: divd_base divisor: divr_base count: count method(#class) testBigintDiv: divd_base divisor: divr_base count: count
@ -162,133 +162,133 @@ extend MyObject
| tc limit | | tc limit |
tc := %( tc := %(
## 0 - 4 // 0 - 4
[MyObject.Donkey v == 901982], [MyObject.Donkey v == 901982],
[selfns.MyObject.Donkey v == 901982], [selfns.MyObject.Donkey v == 901982],
[MyObject.System.Donkey v == 89123], [MyObject.System.Donkey v == 89123],
[MyObject.System.Horse v == 89123], [MyObject.System.Horse v == 89123],
[selfns.MyObject.System.Donkey v == 89123], [selfns.MyObject.System.Donkey v == 89123],
## 5 - 9 // 5 - 9
[MyObject.System.Horse donkey1 == MyObject.System.Donkey], [MyObject.System.Horse donkey1 == MyObject.System.Donkey],
[MyObject.System.Horse donkey2 == MyObject.System.Donkey], [MyObject.System.Horse donkey2 == MyObject.System.Donkey],
[MyObject.System.Horse donkey2 v == 89123], [MyObject.System.Horse donkey2 v == 89123],
[MyObject.System.Horse donkey3 v == 901982], [MyObject.System.Horse donkey3 v == 901982],
[MyObject.System.Horse horse1 == MyObject.System.Horse], [MyObject.System.Horse horse1 == MyObject.System.Horse],
## 10 - 14 // 10 - 14
[MyObject.System.Horse horse2 == MyObject.System.Horse], [MyObject.System.Horse horse2 == MyObject.System.Horse],
[MyObject.System.Horse superclass == MyObject.System.Donkey], [MyObject.System.Horse superclass == MyObject.System.Donkey],
[MyObject.System.Donkey superclass == MyObject], [MyObject.System.Donkey superclass == MyObject],
[selfns == System nsdic], [selfns == System nsdic],
[MyObject.System.Horse myns1 == MyObject.System], [MyObject.System.Horse myns1 == MyObject.System],
## 15 - 19 // 15 - 19
[MyObject.System.Horse myns2 == MyObject.System], [MyObject.System.Horse myns2 == MyObject.System],
[MyObject.System == self.System], [MyObject.System == self.System],
[MyObject.System.Donkey == self.System.Donkey], [MyObject.System.Donkey == self.System.Donkey],
[MyObject.System.Stallion superclass == self.System.Donkey], [MyObject.System.Stallion superclass == self.System.Donkey],
[MyObject.Donkey.Party party1 == 5555], [MyObject.Donkey.Party party1 == 5555],
## 20 - 24 // 20 - 24
[MyObject.Donkey.Party party2 == MyObject.Donkey.Party], [MyObject.Donkey.Party party2 == MyObject.Donkey.Party],
[MyObject.Donkey.Party party3 == 5555], [MyObject.Donkey.Party party3 == 5555],
[MyObject.Donkey.Party party4 == MyObject.Donkey.Party.Party], [MyObject.Donkey.Party party4 == MyObject.Donkey.Party.Party],
[MyObject.Donkey.Party cat1 == MyObject], [MyObject.Donkey.Party cat1 == MyObject],
[MyObject.Code.FASTER2X == 40], [MyObject.Code.FASTER2X == 40],
## 25 - 29 // 25 - 29
[MyObject.Code.FASTER2X == MyObject.Code.FASTER], [MyObject.Code.FASTER2X == MyObject.Code.FASTER],
[((MyObject.Code.FASTER3X at: 3) at: 1) == MyObject.Donkey], [((MyObject.Code.FASTER3X at: 3) at: 1) == MyObject.Donkey],
[MyObject.System.Stallion new x == MyObject.Code.FASTER3X], [MyObject.System.Stallion new x == MyObject.Code.FASTER3X],
[MyObject.System.Stallion party == MyObject.Donkey.Party], [MyObject.System.Stallion party == MyObject.Donkey.Party],
[MyObject.System.Stallion system1 == MyObject.System.System], [MyObject.System.Stallion system1 == MyObject.System.System],
## 30 - 34 // 30 - 34
[MyObject.System.Stallion system2 == System.System], [MyObject.System.Stallion system2 == System.System],
[MyObject.System.System.System.System f == XX.FFFF], [MyObject.System.System.System.System f == XX.FFFF],
[MyObject.System.System a == XX.AAAA], [MyObject.System.System a == XX.AAAA],
[MyObject.System.System.System.System a == nil] , [MyObject.System.System.System.System a == nil] ,
[MyObject.System.System.System.System new kk == #KK], [MyObject.System.System.System.System new kk == #KK],
## 35 - 39 // 35 - 39
[MyObject.System.System.System KING == #KING], [MyObject.System.System.System KING == #KING],
[self testMakeBlock == 49036], [self testMakeBlock == 49036],
[ ((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = 65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716033 ], [ ((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = 65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716033 ],
[ "%d" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716033' ], [ "%d" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '65185151242703554760590262029100101153646988597309960020356494379340201592426774597868716033' ],
[ "%#b" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '2r100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001' ], [ "%#b" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '2r100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001' ],
## 40 - 44 // 40 - 44
[ "%#x" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '16r20000000000000000000000000000000000000000000000000000000000000000000000000001' ], [ "%#x" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '16r20000000000000000000000000000000000000000000000000000000000000000000000000001' ],
[ (7 div: -3) = -2 ], [ (7 div: -3) = -2 ],
[ (7 rem: -3) = 1 ], [ (7 rem: -3) = 1 ],
[ (7 mdiv: -3) = -3 ], [ (7 mdiv: -3) = -3 ],
[ (7 mod: -3) = -2 ], [ (7 mod: -3) = -2 ],
## 45-49 // 45-49
[ ([ (7 div: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ ([ (7 div: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ],
[ ([ (7 rem: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ ([ (7 rem: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ],
[ ([ (7 mdiv: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ ([ (7 mdiv: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ],
[ ([ (7 mod: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ], [ ([ (7 mod: 0) = -2 ] on: Exception do: [:ex | ex messageText ]) = 'divide by zero' ],
[ (270000000000000000000000000000000000000000000000000000000000000000000 div: 50000000000000000000000000000000000000000000000000000000000000000000) = 5 ], [ (270000000000000000000000000000000000000000000000000000000000000000000 div: 50000000000000000000000000000000000000000000000000000000000000000000) = 5 ],
## 50-54 // 50-54
[ (270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ], [ (270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ],
[ (270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 50000000000000000000000000000000000000000000000000000000000000000000) = 5], [ (270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 50000000000000000000000000000000000000000000000000000000000000000000) = 5],
[ (270000000000000000000000000000000000000000000000000000000000000000000 mod: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ], [ (270000000000000000000000000000000000000000000000000000000000000000000 mod: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ],
[ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ],
[ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ],
## 55-59 // 55-59
[ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ],
[ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ],
[ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd div: 16r3b9aca00) = 4184734490355220618401938634485367707982 ], [ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd div: 16r3b9aca00) = 4184734490355220618401938634485367707982 ],
[ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd rem: 16r3b9aca00) = 394876893 ], [ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd rem: 16r3b9aca00) = 394876893 ],
[ (16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) = 16r1111111111111111111111111111111111111111 ], [ (16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) = 16r1111111111111111111111111111111111111111 ],
## 60-64 // 60-64
[(100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0], [(100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0],
[(100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = 100213123891273912837891273189237], [(100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = 100213123891273912837891273189237],
[(-100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0], [(-100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0],
[(-100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = -100213123891273912837891273189237], [(-100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = -100213123891273912837891273189237],
[(-100213123891273912837891273189237 mdiv: 1238971238971894573289472398477891263781263781263) = -1], [(-100213123891273912837891273189237 mdiv: 1238971238971894573289472398477891263781263781263) = -1],
## 65-69 // 65-69
[(-100213123891273912837891273189237 mod: 1238971238971894573289472398477891263781263781263) = 1238971238971894473076348507203978425889990592026], [(-100213123891273912837891273189237 mod: 1238971238971894573289472398477891263781263781263) = 1238971238971894473076348507203978425889990592026],
[(-123897123897189421321312312321312312132 div: -123897123897189421321312312321312312132) = 1], [(-123897123897189421321312312321312312132 div: -123897123897189421321312312321312312132) = 1],
[(-123897123897189421321312312321312312132 rem: -123897123897189421321312312321312312132) = 0], [(-123897123897189421321312312321312312132 rem: -123897123897189421321312312321312312132) = 0],
[(-123897123897189421321312312321312312132 mdiv: -123897123897189421321312312321312312132) = 1], [(-123897123897189421321312312321312312132 mdiv: -123897123897189421321312312321312312132) = 1],
[(-123897123897189421321312312321312312132 mod: -123897123897189421321312312321312312132) = 0], [(-123897123897189421321312312321312312132 mod: -123897123897189421321312312321312312132) = 0],
## 70-74 // 70-74
[ (-0.1233 * 999999.123) = -123299.8918 ], [ (-0.1233 * 999999.123) = -123299.8918 ],
[ (-0.1233 * 999999.123) asString = '-123299.8918' ], [ (-0.1233 * 999999.123) asString = '-123299.8918' ],
[ (-0.1233 - -0.123) = -0.0003 ], [ (-0.1233 - -0.123) = -0.0003 ],
[ (-0.1233 - -0.123) asString = '-0.0003' ], [ (-0.1233 - -0.123) asString = '-0.0003' ],
[ (1.234 - 1.234) = 0 ], ## 0.000 [ (1.234 - 1.234) = 0 ], // 0.000
## 75-79 // 75-79
[ (10.12 * 20.345) = 205.891 ], [ (10.12 * 20.345) = 205.891 ],
[ (10.12 mlt: 20.345) = 205.89 ], [ (10.12 mlt: 20.345) = 205.89 ],
[ (-123897128378912738912738917.112323131233 div: 123.1) = -1006475453931053931053931.089458352000 ], [ (-123897128378912738912738917.112323131233 div: 123.1) = -1006475453931053931053931.089458352000 ],
[ (-1006475453931053931053931.089458352000 * 123.1) = -123897128378912738912738917.112323131200 ], [ (-1006475453931053931053931.089458352000 * 123.1) = -123897128378912738912738917.112323131200 ],
[ 10 scale = 0 ], [ 10 scale = 0 ],
## 80-84 // 80-84
[ 10.0 scale = 1 ], [ 10.0 scale = 1 ],
[ 10.00 scale = 2 ], [ 10.00 scale = 2 ],
[ (10 scale: 1) = 10.0 ], [ (10 scale: 1) = 10.0 ],
[ (10 scale: 1) scale = (10.1 scale) ], [ (10 scale: 1) scale = (10.1 scale) ],
[ (10 scale: 2) scale = (10.11 scale) ], [ (10 scale: 2) scale = (10.11 scale) ],
## 85-89 // 85-89
[ ((-10.19 scale: 3) scale) = (10.199 scale) ], [ ((-10.19 scale: 3) scale) = (10.199 scale) ],
[ ((-10.19 scale: 0) scale) = (10 scale) ], [ ((-10.19 scale: 0) scale) = (10 scale) ],
[ (-9p10 scale) = (-10.000000000 scale) ], [ (-9p10 scale) = (-10.000000000 scale) ],
[ (-9p10.123 scale) = (-10.123000000 scale) ], [ (-9p10.123 scale) = (-10.123000000 scale) ],
[ (+3p100.1 + 16rffff + +5p1.22 + -5p1.223) = 65635.09700 ], [ (+3p100.1 + 16rffff + +5p1.22 + -5p1.223) = 65635.09700 ],
## 90-94 // 90-94
[ (30p2123.12 asString) = '2123.120000000000000000000000000000' ], [ (30p2123.12 asString) = '2123.120000000000000000000000000000' ],
[ (+30p2123.12 asString) = '2123.120000000000000000000000000000' ], [ (+30p2123.12 asString) = '2123.120000000000000000000000000000' ],
[ (-30p2123.12 asString) = '-2123.120000000000000000000000000000' ], [ (-30p2123.12 asString) = '-2123.120000000000000000000000000000' ],
@ -296,103 +296,103 @@ extend MyObject
[ (811306333091350399588761 mdiv: 16) = 50706645818209399974297 ], [ (811306333091350399588761 mdiv: 16) = 50706645818209399974297 ],
## 95-99 // 95-99
[ (811306333091350399588761 rem: 16) = 9 ], [ (811306333091350399588761 rem: 16) = 9 ],
[ (811306333091350399588761 mod: 16) = 9 ], [ (811306333091350399588761 mod: 16) = 9 ],
[ (811306333091350399588761 div: 128) = 6338330727276174996787 ], [ (811306333091350399588761 div: 128) = 6338330727276174996787 ],
[ (811306333091350399588761 mdiv: 128) = 6338330727276174996787 ], [ (811306333091350399588761 mdiv: 128) = 6338330727276174996787 ],
[ (811306333091350399588761 rem: 128) = 25 ], [ (811306333091350399588761 rem: 128) = 25 ],
## 100-104 // 100-104
[ (811306333091350399588761 mod: 128) = 25 ], [ (811306333091350399588761 mod: 128) = 25 ],
[ (-811306333091350399588761 div: -16) = 50706645818209399974297 ], [ (-811306333091350399588761 div: -16) = 50706645818209399974297 ],
[ (-811306333091350399588761 mdiv: -16) = 50706645818209399974297 ], [ (-811306333091350399588761 mdiv: -16) = 50706645818209399974297 ],
[ (-811306333091350399588761 rem: -16) = -9 ], [ (-811306333091350399588761 rem: -16) = -9 ],
[ (-811306333091350399588761 mod: -16) = -9 ], [ (-811306333091350399588761 mod: -16) = -9 ],
## 105-109 // 105-109
[ (-811306333091350399588761 div: -128) = 6338330727276174996787 ], [ (-811306333091350399588761 div: -128) = 6338330727276174996787 ],
[ (-811306333091350399588761 mdiv: -128) = 6338330727276174996787 ], [ (-811306333091350399588761 mdiv: -128) = 6338330727276174996787 ],
[ (-811306333091350399588761 rem: -128) = -25 ], [ (-811306333091350399588761 rem: -128) = -25 ],
[ (-811306333091350399588761 mod: -128) = -25 ], [ (-811306333091350399588761 mod: -128) = -25 ],
[ (-8113063330913503995887611892379812731289731289312898971231 div: -1024) = 7922913409095218745983995988652160870400128212219627901 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -1024) = 7922913409095218745983995988652160870400128212219627901 ],
## 110-114 // 110-114
[ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -1024) = 7922913409095218745983995988652160870400128212219627901 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -1024) = 7922913409095218745983995988652160870400128212219627901 ],
[ (-8113063330913503995887611892379812731289731289312898971231 rem: -1024) = -607 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: -1024) = -607 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mod: -1024) = -607 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: -1024) = -607 ],
[ (-8113063330913503995887611892379812731289731289312898971231 div: -65535) = 123797411015693964994088836383303772507663558240831600 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -65535) = 123797411015693964994088836383303772507663558240831600 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65535) = 123797411015693964994088836383303772507663558240831600 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65535) = 123797411015693964994088836383303772507663558240831600 ],
## 115-119 // 115-119
[ (-8113063330913503995887611892379812731289731289312898971231 rem: -65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: -65535) = -65231 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mod: -65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: -65535) = -65231 ],
[ (-8113063330913503995887611892379812731289731289312898971231 div: -65536) = 123795522017112792905999937322690013600002003315931685 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -65536) = 123795522017112792905999937322690013600002003315931685 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65536) = 123795522017112792905999937322690013600002003315931685 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65536) = 123795522017112792905999937322690013600002003315931685 ],
[ (-8113063330913503995887611892379812731289731289312898971231 rem: -65536) = -63071 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: -65536) = -63071 ],
## 120-124 // 120-124
[ (-8113063330913503995887611892379812731289731289312898971231 mod: -65536) = -63071 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: -65536) = -63071 ],
[ (-8113063330913503995887611892379812731289731289312898971231 div: 65535) = -123797411015693964994088836383303772507663558240831600 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 65535) = -123797411015693964994088836383303772507663558240831600 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 65535) = -123797411015693964994088836383303772507663558240831601 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 65535) = -123797411015693964994088836383303772507663558240831601 ],
[ (-8113063330913503995887611892379812731289731289312898971231 rem: 65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: 65535) = -65231 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mod: 65535) = 304 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: 65535) = 304 ],
## 125-129 // 125-129
[ (65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ],
[ (65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = -1 ], [ (65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = -1 ],
[ (65535 rem: -8113063330913503995887611892379812731289731289312898971231) = 65535 ], [ (65535 rem: -8113063330913503995887611892379812731289731289312898971231) = 65535 ],
[ (65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -8113063330913503995887611892379812731289731289312898905696 ], [ (65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -8113063330913503995887611892379812731289731289312898905696 ],
[ (-65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (-65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ],
## 130-134 // 130-134
[ (-65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (-65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = 0 ],
[ (-65535 rem: -8113063330913503995887611892379812731289731289312898971231) = -65535], [ (-65535 rem: -8113063330913503995887611892379812731289731289312898971231) = -65535],
[ (-65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -65535 ], [ (-65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -65535 ],
[ (-65535 div: 8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (-65535 div: 8113063330913503995887611892379812731289731289312898971231) = 0 ],
[ (-65535 mdiv: 8113063330913503995887611892379812731289731289312898971231) = -1 ], [ (-65535 mdiv: 8113063330913503995887611892379812731289731289312898971231) = -1 ],
## 135-139 // 135-139
[ (-65535 rem: 8113063330913503995887611892379812731289731289312898971231) = -65535 ], [ (-65535 rem: 8113063330913503995887611892379812731289731289312898971231) = -65535 ],
[ (-65535 mod: 8113063330913503995887611892379812731289731289312898971231) = 8113063330913503995887611892379812731289731289312898905696 ], [ (-65535 mod: 8113063330913503995887611892379812731289731289312898971231) = 8113063330913503995887611892379812731289731289312898905696 ],
[ (8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = 236121219667649827777862429280643489074710852271 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = 236121219667649827777862429280643489074710852271 ],
[ (-8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = -236121219667649827777862429280643489074710852271 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = -236121219667649827777862429280643489074710852271 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 34359738368) = -236121219667649827777862429280643489074710852272 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 34359738368) = -236121219667649827777862429280643489074710852272 ],
## 140-144 // 140-144
[ (-8113063330913503995887611892379812731289731289312898971231 rem: 34359738368) = -31040337503 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: 34359738368) = -31040337503 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mod: 34359738368) = 3319400865 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: 34359738368) = 3319400865 ],
[ (-8113063330913503995887611892379812731289731289312898971231 div: 18446744073709551615) = -439810044444445199874532569660475732947 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 18446744073709551615) = -439810044444445199874532569660475732947 ],
[ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 18446744073709551615) = -439810044444445199874532569660475732948 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 18446744073709551615) = -439810044444445199874532569660475732948 ],
[ (-8113063330913503995887611892379812731289731289312898971231 rem: 18446744073709551615) = -16637658201046411826 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: 18446744073709551615) = -16637658201046411826 ],
## 145-149 // 145-149
[ (-8113063330913503995887611892379812731289731289312898971231 mod: 18446744073709551615) = 1809085872663139789 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: 18446744073709551615) = 1809085872663139789 ],
[ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971231) = 1 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971231) = 1 ],
[ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971231) = 0 ],
[ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971232) = 0 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971232) = 0 ],
[ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971232) = 8113063330913503995887611892379812731289731289312898971231 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971232) = 8113063330913503995887611892379812731289731289312898971231 ],
## 150-154 // 150-154
[ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971230) = 1 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971230) = 1 ],
[ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971230) = 1 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971230) = 1 ],
[ self testBigintDiv: 100919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 129323482374892374238974238974238947328972389128387312892713891728391278 count: 2000 ], [ self testBigintDiv: 100919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 129323482374892374238974238974238947328972389128387312892713891728391278 count: 2000 ],
[ self testBigintDiv: 234897230919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 12932348237489237423897423897423894732897238912838731289271389172839127 count: 2000 ], [ self testBigintDiv: 234897230919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 12932348237489237423897423897423894732897238912838731289271389172839127 count: 2000 ],
[ self testBigintDiv: 16r1234567812345678123456781234567812345678123456781234567812345678123456781234567812345678 divisor: 16r12345678123456781234567812345678123456781234567812345678 count: 2000 ], [ self testBigintDiv: 16r1234567812345678123456781234567812345678123456781234567812345678123456781234567812345678 divisor: 16r12345678123456781234567812345678123456781234567812345678 count: 2000 ],
## 155-159 // 155-159
[ self testBigintDiv: 16r000089ab0000456700000123 divisor: 1 count: 2000 ], [ self testBigintDiv: 16r000089ab0000456700000123 divisor: 1 count: 2000 ],
[ self testBigintDiv: 16r000000030000000000008000 divisor: 16r000000010000000000002000 count: 2000 ], [ self testBigintDiv: 16r000000030000000000008000 divisor: 16r000000010000000000002000 count: 2000 ],
[ self testBigintDiv: 16rfffffffe0000000080000000 divisor: 16r0000ffff0000000080000000 count: 12345 ], [ self testBigintDiv: 16rfffffffe0000000080000000 divisor: 16r0000ffff0000000080000000 count: 12345 ],
[ self testBigintDiv: 16rfffffffffffffffe divisor: 16rffffffff count: 2000 ], [ self testBigintDiv: 16rfffffffffffffffe divisor: 16rffffffff count: 2000 ],
[ self testBigintDiv: 68651967526299315528548877601614136727014 divisor: 1729382256910270380 count: 1 ], [ self testBigintDiv: 68651967526299315528548877601614136727014 divisor: 1729382256910270380 count: 1 ],
## 160-164 // 160-164
[ self testBigintDiv: 43943618413704592900396132847030223073729048496 divisor: 1135814937804493543741046072006331 count: 1 ], [ self testBigintDiv: 43943618413704592900396132847030223073729048496 divisor: 1135814937804493543741046072006331 count: 1 ],
[ self testBigintDiv: 76733673740671314025981152630586699414203 divisor: 12682136550675277273 count: 1 ], [ self testBigintDiv: 76733673740671314025981152630586699414203 divisor: 12682136550675277273 count: 1 ],
[ self testBigintDiv: 265804060782114895959697138188904455994 divisor: 713053462628379038341886861235 count: 1], [ self testBigintDiv: 265804060782114895959697138188904455994 divisor: 713053462628379038341886861235 count: 1],
## ========================= // =========================
[ [
| k | | k |
k := String new. k := String new.
@ -404,7 +404,7 @@ extend MyObject
[ [
| k | | k |
k := #('str1' 'str2' 'str3' 'str4' 'str5' 'str1' 'str2') asSet. k := #('str1' 'str2' 'str3' 'str4' 'str5' 'str1' 'str2') asSet.
##k do: [:each | each dump]. //k do: [:each | each dump].
if ((k includes: 'str1') and (k includes: 'str3') and ((k includes: 'str9') not)) { true } else { false } if ((k includes: 'str1') and (k includes: 'str3') and ((k includes: 'str9') not)) { true } else { false }
], ],
[ [

View File

@ -1,9 +1,9 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
class MyObject(Object) class MyObject(Object)
{ {
@ -40,7 +40,7 @@ class MyObject(Object)
method(#class) test_on_do_with: dividend with: divisor method(#class) test_on_do_with: dividend with: divisor
{ {
## it returns 0 upon an exception otherwise, division result. // it returns 0 upon an exception otherwise, division result.
^[ dividend div: divisor ] on: Exception do: [:ex | 0 ] ^[ dividend div: divisor ] on: Exception do: [:ex | 0 ]
} }
@ -126,7 +126,7 @@ class MyObject(Object)
sem wait. sem wait.
sem wait. sem wait.
^%( v, p ) ## v must be 2000, p must be 6000 ^%( v, p ) // v must be 2000, p must be 6000
} }
/* /*
@ -155,23 +155,23 @@ class MyObject(Object)
| tc limit | | tc limit |
tc := %( tc := %(
## 0 - 4 // 0 - 4
[ (self test_quicksort: #(7 12 3 20 5 8 2) copy) = #(2 3 5 7 8 12 20)], [ (self test_quicksort: #(7 12 3 20 5 8 2) copy) = #(2 3 5 7 8 12 20)],
[ (self test_quicksort: %(99, 12, 18, 7, 12, 3, 20, 5, 8, 2)) = #(2 3 5 7 8 12 12 18 20 99)], [ (self test_quicksort: %(99, 12, 18, 7, 12, 3, 20, 5, 8, 2)) = #(2 3 5 7 8 12 12 18 20 99)],
[ (self test_on_do_with: 10 with: 2) == 5 ], [ (self test_on_do_with: 10 with: 2) == 5 ],
[ (self test_on_do_with: -10 with: 0) == 0 ], [ (self test_on_do_with: -10 with: 0) == 0 ],
[ self test_ensure_with: -20945. self.ensure_tester_v == -20945 ], [ self test_ensure_with: -20945. self.ensure_tester_v == -20945 ],
## 5-9 // 5-9
[ ((self test_ensure2_with: 8) == 64) and: [self.ensure_tester_v == 8] ], [ ((self test_ensure2_with: 8) == 64) and: [self.ensure_tester_v == 8] ],
[ self proc1 == 100 ], [ self proc1 == 100 ],
[ System sleepForSecs: 2. self proc1 == 200 ], [ System sleepForSecs: 2. self proc1 == 200 ],
[ self test_semaphore_heap == true ], [ self test_semaphore_heap == true ],
[ self test_mutex = #(2000 6000) ], [ self test_mutex = #(2000 6000) ],
## 10-14 // 10-14
####[ self test_sem_sig ], ////[ self test_sem_sig ],
[ System sleepForSecs: 2. self.a == 300 ] ## sleep before checking self.a to prevent different result depending on process switching frequency and speed [ System sleepForSecs: 2. self.a == 300 ] // sleep before checking self.a to prevent different result depending on process switching frequency and speed
). ).
limit := tc size. limit := tc size.
@ -190,7 +190,7 @@ s1 := TcpSocket new.
s1 onEvent: #connected do: [ s1 onEvent: #connected do: [
s1 waitToRead. s1 waitToRead.
##s1 beginWrite: C'GET / HTTP/1.0\n\r'. //s1 beginWrite: C'GET / HTTP/1.0\n\r'.
] ]
s1 onEvent: #written do: [ s1 onEvent: #written do: [
]. ].
@ -202,7 +202,7 @@ s1 onEvent: #readyToRead do: [
s1 beginConnect: '1.2.3.4:45' onConnected: [ :result | xxxx]. s1 beginConnect: '1.2.3.4:45' onConnected: [ :result | xxxx].
#### ////
s1 beginConnect: destination onConnected: s1 beginConnect: destination onConnected:
s1 endConnect --> return what? s1 endConnect --> return what?
s1 endReceive s1 endReceive

View File

@ -1,12 +1,12 @@
## //
## TEST CASES for basic methods // TEST CASES for basic methods
## //
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
class MyObject(Object) class MyObject(Object)
{ {
@ -23,26 +23,26 @@ class MyObject(Object)
} }
method(#class) test1 method(#class) test1
{ {
#### TODO: add this to the test case list. //// TODO: add this to the test case list.
| rec results | | rec results |
##rec := [ :y :z | (108.0000000000000000000000 - (815.000000000000000000 - (1500.0000000000000000 div: z) div: y)) truncate: 18. ]. //rec := [ :y :z | (108.0000000000000000000000 - (815.000000000000000000 - (1500.0000000000000000 div: z) div: y)) truncate: 18. ].
##rec := [ :y :z | (108.0000000000000000000000 - (815.000000000000000000 - (1500.0000000000000000 div: z) div: y)) truncate: 16. ]. //rec := [ :y :z | (108.0000000000000000000000 - (815.000000000000000000 - (1500.0000000000000000 div: z) div: y)) truncate: 16. ].
##rec := [ :y :z | 108.0000000000000000000000 - (815.000000000000000000 - (1500.0000000000000000 div: z) div: y) ]. //rec := [ :y :z | 108.0000000000000000000000 - (815.000000000000000000 - (1500.0000000000000000 div: z) div: y) ].
##rec := [ :y :z | (108.0 scale: 22) - ((815 scale: 18) - ((1500 scale: 16) div: z) div: y) ]. //rec := [ :y :z | (108.0 scale: 22) - ((815 scale: 18) - ((1500 scale: 16) div: z) div: y) ].
##rec := [ :y :z | 108.000000000000000000000000000000 - (815.00000000000000000000000000 - (1500.0000000000000000 div: z) div: y) ]. //rec := [ :y :z | 108.000000000000000000000000000000 - (815.00000000000000000000000000 - (1500.0000000000000000 div: z) div: y) ].
rec := [ :y :z | 22p108 - (18p815 - (16p1500 div: z) div: y) ]. rec := [ :y :z | 22p108 - (18p815 - (16p1500 div: z) div: y) ].
## results := %( 4.0, 425 div: 100.0 ) asOrderedCollection. // results := %( 4.0, 425 div: 100.0 ) asOrderedCollection.
results := OrderedCollection new. results := OrderedCollection new.
results add: 4.0; add: (425.00 div: 100.00). results add: 4.0; add: (425.00 div: 100.00).
3 to: 100 do: [ :i | 3 to: 100 do: [ :i |
##(results at: i - 2) dump. //(results at: i - 2) dump.
##(results at: i - 3) dump. //(results at: i - 3) dump.
##'----------' dump. //'----------' dump.
results add: (rec value: (results at: i - 2) value: (results at: i - 3)). results add: (rec value: (results at: i - 2) value: (results at: i - 3)).
]. ].
@ -57,28 +57,28 @@ class MyObject(Object)
| tc limit | | tc limit |
tc := %( tc := %(
## 0 - 4 // 0 - 4
[(Object isKindOf: Class) == true], [(Object isKindOf: Class) == true],
[(Object isKindOf: Apex) == true], [(Object isKindOf: Apex) == true],
[(Class isKindOf: Class) == true], [(Class isKindOf: Class) == true],
[(Class isKindOf: Apex) == true], [(Class isKindOf: Apex) == true],
[(Class isKindOf: Object) == false], [(Class isKindOf: Object) == false],
## 5-9 // 5-9
[(Apex isKindOf: Class) == true], [(Apex isKindOf: Class) == true],
[(Apex isKindOf: Apex) == true], [(Apex isKindOf: Apex) == true],
[(SmallInteger isKindOf: Integer) == false], [(SmallInteger isKindOf: Integer) == false],
[(SmallInteger isKindOf: SmallInteger) == false], [(SmallInteger isKindOf: SmallInteger) == false],
[(Object isKindOf: SmallInteger) == false], [(Object isKindOf: SmallInteger) == false],
## 10-14 // 10-14
[(10 isKindOf: Integer) == true], [(10 isKindOf: Integer) == true],
[(10 isKindOf: 20) == false], [(10 isKindOf: 20) == false],
[([] isKindOf: BlockContext) == true], [([] isKindOf: BlockContext) == true],
[([] isKindOf: MethodContext) == false], [([] isKindOf: MethodContext) == false],
[([] isKindOf: Context) == true], [([] isKindOf: Context) == true],
## 15-20 // 15-20
[('string' isKindOf: String) == true], [('string' isKindOf: String) == true],
[(#symbol isKindOf: String) == true], [(#symbol isKindOf: String) == true],
[('string' isKindOf: Symbol) == false], [('string' isKindOf: Symbol) == false],
@ -93,7 +93,7 @@ class MyObject(Object)
System log(System.Log.INFO, idx asString, (if (tb value) { ' PASS' } else { ' FAIL' }), "\n"). System log(System.Log.INFO, idx asString, (if (tb value) { ' PASS' } else { ' FAIL' }), "\n").
]. ].
## TODO: // TODO:
String format('%s', " 나 는\\\"") dump. String format('%s', " 나 는\\\"") dump.
#"a b\nc" dump. #"a b\nc" dump.
} }

View File

@ -1,12 +1,12 @@
## //
## TEST CASES for basic methods // TEST CASES for basic methods
## //
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
class MyObject(Object) class MyObject(Object)
{ {
@ -39,7 +39,7 @@ class MyObject(Object)
sg addSemaphore: s3. sg addSemaphore: s3.
s1 signalOnInput: 0. s1 signalOnInput: 0.
s2 signalOnInput: 0. ## this should raise an exception as the same file descriptor is added to a different semaphore s2 signalOnInput: 0. // this should raise an exception as the same file descriptor is added to a different semaphore
s3 signalOnInput: 0. s3 signalOnInput: 0.
[ sg wait. ] fork. [ sg wait. ] fork.
@ -57,7 +57,7 @@ sg removeSemaphore: s1.
| tc limit | | tc limit |
tc := %( tc := %(
## 0 - 4 // 0 - 4
[self test_terminate == 180], [self test_terminate == 180],
[self test_sg == nil] [self test_sg == nil]
). ).

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {
@ -59,7 +59,7 @@ class MyObject(TestObject)
^a + 99. ^a + 99.
##a := Moo.MyCOM.HashTable new. //a := Moo.MyCOM.HashTable new.
} }
method xxx: aBlock method xxx: aBlock
@ -73,46 +73,46 @@ class MyObject(TestObject)
{ {
| a b c sum | | a b c sum |
## ##(10 add: 20) dump. // //(10 add: 20) dump.
## (10 + 20) dump. // (10 + 20) dump.
## //
## a := 10 + 20 + 30. // a := 10 + 20 + 30.
## b := [:x :y | | t z | x := 20. b := 9. x := 10 + 20 ]. // b := [:x :y | | t z | x := 20. b := 9. x := 10 + 20 ].
## //
## (b value: 10 value: 20) dump. // (b value: 10 value: 20) dump.
## //
## thisContext basicSize dump. // thisContext basicSize dump.
## //
## (thisContext basicAt: (8 + 5)) dump. // (thisContext basicAt: (8 + 5)) dump.
## //
## ^self. // ^self.
a := self new. a := self new.
##a yourself. //a yourself.
##b := a getTrue; getFalse. //b := a getTrue; getFalse.
##b := a getTrue; getFalse; getTrue: 20 + 10. //b := a getTrue; getFalse; getTrue: 20 + 10.
##b := a getTrue; getFalse; getTrue: 20 + 10; getTrue: 90 + 20. //b := a getTrue; getFalse; getTrue: 20 + 10; getTrue: 90 + 20.
##b := 3 + 5 getTrue: 20; getTrue: 8 + 1; getTrue: 20; yourself. //b := 3 + 5 getTrue: 20; getTrue: 8 + 1; getTrue: 20; yourself.
b := 3 + 5 inc getTrue: 20 + (30 getTrue: 20; yourself); yourself. b := 3 + 5 inc getTrue: 20 + (30 getTrue: 20; yourself); yourself.
##b := [:q | q ] value: a getTrue. //b := [:q | q ] value: a getTrue.
b dump. b dump.
##^self. //^self.
## ############################################################ // ////////////////////////////////////////////////////////////
## A := 99. // A := 99.
[:x :y | R := y. ] value: 10 value: 6. [:x :y | R := y. ] value: 10 value: 6.
R := R + 1. R := R + 1.
R dump. R dump.
sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1))] ]. sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1))] ].
##sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1)) + (sum value: (n - 2))] ]. //sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1)) + (sum value: (n - 2))] ].
(sum value: R; value: 5) dump. (sum value: R; value: 5) dump.
##sum := [ :n | sum value: 5 ]. //sum := [ :n | sum value: 5 ].
##sum value: 5. //sum value: 5.
#[ 1 2 3] dump. #[ 1 2 3] dump.
#[ 4 5 6] dump. #[ 4 5 6] dump.
@ -135,8 +135,8 @@ class MyObject(TestObject)
C'\n' dump. C'\n' dump.
#abc:def: dump. #abc:def: dump.
##a := (11 < 10) ifTrue: [5] ifFalse: [20]. //a := (11 < 10) ifTrue: [5] ifFalse: [20].
##a dump. //a dump.
} }
method(#class) main55 method(#class) main55
@ -144,8 +144,8 @@ class MyObject(TestObject)
|a b c| |a b c|
self main2. self main2.
## b := 0. // b := 0.
## [ b < 5 ] whileTrue: [ b dump. b := b + 1 ]. // [ b < 5 ] whileTrue: [ b dump. b := b + 1 ].
} }
method(#class) getTen method(#class) getTen
@ -153,10 +153,10 @@ class MyObject(TestObject)
^10 ^10
} }
## --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
## this sample demonstrates what happens when a block context returns to the origin's caller // this sample demonstrates what happens when a block context returns to the origin's caller
## after the caller has already returned. // after the caller has already returned.
method(#class) xxxx method(#class) xxxx
{ {
@ -180,7 +180,7 @@ class MyObject(TestObject)
method(#class) main66 method(#class) main66
{ {
self yyyy. self yyyy.
t2 := t2 value. ## can t2 return? it should return somewhere into the method context of yyy. but it has already terminated t2 := t2 value. // can t2 return? it should return somewhere into the method context of yyy. but it has already terminated
t2 dump. t2 dump.
} }
@ -190,10 +190,10 @@ class MyObject(TestObject)
t1 := 1. t1 := 1.
self xxxx. self xxxx.
t2 := t2 value. ## can t2 return? it should return somewhere into the method context of yyy. but it has already terminated t2 := t2 value. // can t2 return? it should return somewhere into the method context of yyy. but it has already terminated
t2 dump. t2 dump.
} }
## ---------------------------------------------------------------------- // ----------------------------------------------------------------------
method(#class) main22 method(#class) main22
{ {
@ -215,8 +215,8 @@ class MyObject(TestObject)
(#[3 2 1] at: 3) dump. (#[3 2 1] at: 3) dump.
## thisContext value. ## the message value must be unresolvable as thisContext is a method context // thisContext value. // the message value must be unresolvable as thisContext is a method context
## [thisContext value] value. // [thisContext value] value.
'-------------------------' dump. '-------------------------' dump.
b := 0. b := 0.
[ b := b + 1. b dump. thisContext value] value. [ b := b + 1. b dump. thisContext value] value.
@ -254,24 +254,24 @@ class MyObject(TestObject)
| ffi | | ffi |
ffi := FFI new: 'libc.so.6'. ffi := FFI new: 'libc.so.6'.
## ffi call: #printf with: #((str '%d') (int 10) (long 20)). // ffi call: #printf with: #((str '%d') (int 10) (long 20)).
ffi call: #printf signature: '|s|ici)i' arguments: #("hello world %d %c %d\n" 11123 $X 9876543). 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'). //ffi call: #puts signature: 's)i' arguments: #('hello world').
ffi close. ffi close.
} }
method(#class) main method(#class) main
{ {
## --------------------------------------------------------------- // ---------------------------------------------------------------
## getABlock has returned. // getABlock has returned.
## aBlock's home context is getABlock. getABlock has returned // aBlock's home context is getABlock. getABlock has returned
## when 'aBlock value' is executed. so when aBlock is really // when 'aBlock value' is executed. so when aBlock is really
## executed, ^self is a double return attempt. should this be made // executed, ^self is a double return attempt. should this be made
## illegal?? // illegal??
|aBlock| |aBlock|
aBlock := self getABlock. aBlock := self getABlock.
aBlock value. aBlock value.
## --------------------------------------------------------------- // ---------------------------------------------------------------
self test_ffi. self test_ffi.
@ -279,7 +279,7 @@ class MyObject(TestObject)
PROCESS TESTING PROCESS TESTING
| p | | p |
'000000000000000000' dump. '000000000000000000' dump.
## p := [ | 'xxxxxxxxxxx' dump. 'yyyyyyyyyy' dump. ^10. ] newProcess. // p := [ | 'xxxxxxxxxxx' dump. 'yyyyyyyyyy' dump. ^10. ] newProcess.
p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(abc def 10 20). p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(abc def 10 20).
'999999999999999999' dump. '999999999999999999' dump.
p resume. p resume.
@ -295,12 +295,12 @@ PROCESS TESTING
(-2305843009213693952 - 1) dump. (-2305843009213693952 - 1) dump.
(1 + 2) dump. (1 + 2) dump.
##(-2305843009213693952 * 2305843009213693952) dump. //(-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) * ((-2305843009213693952 - 10) * (-2305843009213693952 - 10) *(-2305843009213693952 - 10) * (-2305843009213693952 - 10) * 255)) dump.
##((-2305843009213693952 - 10) * (-2305843009213693952 - 10) *(-2305843009213693952 - 10) * (-2305843009213693952 - 10) * 255) dump. //((-2305843009213693952 - 10) * (-2305843009213693952 - 10) *(-2305843009213693952 - 10) * (-2305843009213693952 - 10) * 255) dump.
##(-16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF * 1) dump. //(-16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF * 1) dump.
##((-2305843009213693952 * -1) - 1 + 2) dump. //((-2305843009213693952 * -1) - 1 + 2) dump.
((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) dump. ((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) dump.
@ -316,46 +316,46 @@ PROCESS TESTING
(7 div: -3) dump. (7 div: -3) dump.
(7 mdiv: -3) dump. (7 mdiv: -3) dump.
##(777777777777777777777777777777777777777777777777777777777777777777777 rem: -8127348917239812731289371289731298) dump. //(777777777777777777777777777777777777777777777777777777777777777777777 rem: -8127348917239812731289371289731298) dump.
##(777777777777777777777777777777777777777777777777777777777777777777777 quo: -8127348917239812731289371289731298) dump. //(777777777777777777777777777777777777777777777777777777777777777777777 div: -8127348917239812731289371289731298) dump.
##(270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) dump. //(270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(270000000000000000000000000000000000000000000000000000000000000000000 quo: 50000000000000000000000000000000000000000000000000000000000000000000) dump. //(270000000000000000000000000000000000000000000000000000000000000000000 div: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(270000000000000000000000000000000000000000000000000000000000000000000 \\ 50000000000000000000000000000000000000000000000000000000000000000000) dump. //(270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(270000000000000000000000000000000000000000000000000000000000000000000 // 50000000000000000000000000000000000000000000000000000000000000000000) dump. //(270000000000000000000000000000000000000000000000000000000000000000000 mod: 50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) dump. //(0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(0 quo: -50000000000000000000000000000000000000000000000000000000000000000000) dump. //(0 div: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(0 \\ -50000000000000000000000000000000000000000000000000000000000000000000) dump. //(0 mdiv: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(0 // -50000000000000000000000000000000000000000000000000000000000000000000) dump. //(0 mod: -50000000000000000000000000000000000000000000000000000000000000000000) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 rem: -1) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 rem: -1) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 quo: -1) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 div: -1) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 \\ -1) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 mdiv: -1) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 // -1) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 mod: -1) dump.
## (-27029038 // 2) asString dump. // (-27029038 mod: 2) asString dump.
## (-270290380000000000000000000000000000000000000000000000000000000000000000000000000000000000000 // 2) asString dump. // (-270290380000000000000000000000000000000000000000000000000000000000000000000000000000000000000 mod: 2) asString dump.
##(-16rAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFF) asString dump. //(-16rAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFF) asString dump.
## (16r2dd01fc06c265c8163ac729b49d890939826ce3dd quo: 16r3b9aca00) dump. // (16r2dd01fc06c265c8163ac729b49d890939826ce3dd div: 16r3b9aca00) dump.
##(0 rem: -50) dump. //(0 rem: -50) dump.
##(0 quo: -50) dump. //(0 div: -50) dump.
##(0 \\ -50) dump. //(0 mdiv: -50) dump.
##(0 // -50) dump. //(0 mod: -50) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 rem: 5) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 rem: 5) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 quo: 5) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 div: 5) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 \\ 5) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 5) dump.
##(-270000000000000000000000000000000000000000000000000000000000000000000 // 5) dump. //(-270000000000000000000000000000000000000000000000000000000000000000000 mod: 5) dump.
##(-270 rem: 5) dump. //(-270 rem: 5) dump.
##(-270 quo: 5) dump. //(-270 div: 5) dump.
##(-270 \\ 5) dump. //(-270 mdiv: 5) dump.
##(-270 // 5) dump. //(-270 mod: 5) dump.
##(16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) dump. //(16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) dump.
(2r1111111111111111111111111111111111111111111111111111111111111111 printStringRadix:2) dump. (2r1111111111111111111111111111111111111111111111111111111111111111 printStringRadix:2) dump.
@ -402,10 +402,10 @@ PROCESS TESTING
(16rFFFFFFFFFF1234567890AAAAAAAAAAAAAAAAAAAAAAAAA22222222222222222F printStringRadix: 32) dump. (16rFFFFFFFFFF1234567890AAAAAAAAAAAAAAAAAAAAAAAAA22222222222222222F printStringRadix: 32) dump.
(32r3VVVVVVVS938LJOI2LALALALALALALALALAL8H248H248H248HF printStringRadix: 16) dump. (32r3VVVVVVVS938LJOI2LALALALALALALALALAL8H248H248H248HF printStringRadix: 16) dump.
## ((-2r110101010101010101010101010101111111111111111111111111111111111111111111111111111111100000000001111111 bitShift: 16r1FFFFFFFFFFFFFFFF) printStringRadix: 2) dump. // ((-2r110101010101010101010101010101111111111111111111111111111111111111111111111111111111100000000001111111 bitShift: 16r1FFFFFFFFFFFFFFFF) printStringRadix: 2) dump.
##((-2r11111111110000000000111110000 bitShift: -31) printStringRadix: 2) dump. //((-2r11111111110000000000111110000 bitShift: -31) printStringRadix: 2) dump.
##((-536870911 bitShift: -536870912) printStringRadix: 2) dump. //((-536870911 bitShift: -536870912) printStringRadix: 2) dump.
((-2r1111 bitShift: -3) printStringRadix: 2) dump. ((-2r1111 bitShift: -3) printStringRadix: 2) dump.
((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -1) printStringRadix: 2) dump. ((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -1) printStringRadix: 2) dump.
((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -2) printStringRadix: 2) dump. ((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -2) printStringRadix: 2) dump.
@ -430,8 +430,8 @@ PROCESS TESTING
(2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitAt: 129) dump. (2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitAt: 129) dump.
(2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitAt: 16rFFFFFFFFFFFFFFFF1) dump. (2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitAt: 16rFFFFFFFFFFFFFFFF1) dump.
##self a: 1 b: 2 c: 3 d: 4 e: 5 f: 6 g: 7. //self a: 1 b: 2 c: 3 d: 4 e: 5 f: 6 g: 7.
##self a: 1 b: 2 c: 3. //self a: 1 b: 2 c: 3.
[1 + [100 + 200] value] value dump. [1 + [100 + 200] value] value dump.
@ -448,8 +448,8 @@ PROCESS TESTING
([ :a :b | /*a := 20.*/ b := [ a + 20 ]. b value.] value: 99 value: 100) dump. ([ :a :b | /*a := 20.*/ b := [ a + 20 ]. b value.] value: 99 value: 100) dump.
'====================' dump. '====================' dump.
[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. ## not sufficient arguments. it must fail [ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. // not sufficient arguments. it must fail
##[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | 'Exception' dump]. //[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | 'Exception' dump].
/* /*
FFI isNil dump. FFI isNil dump.

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {
@ -97,8 +97,8 @@ class MyObject(TestObject)
'START OF MAIN' dump. 'START OF MAIN' dump.
[2 + 3 + 1 + [[[^6] value] value ] value] value dump. [2 + 3 + 1 + [[[^6] value] value ] value] value dump.
## ^(self a: (self new a) b: ([:a :b | a + b] value: 10 value: 20) c: (self new c)) dump. // ^(self a: (self new a) b: ([:a :b | a + b] value: 10 value: 20) c: (self new c)) dump.
##self getBlock value dump. //self getBlock value dump.
'END OF MAIN' dump. 'END OF MAIN' dump.
} }

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {
@ -65,7 +65,7 @@ class MyObject(TestObject)
{ {
| p p2 | | p p2 |
'START OF MAIN' dump. 'START OF MAIN' dump.
##p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(#abc #def 10 20). //p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(#abc #def 10 20).
p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ] newProcessWith: #(#abc #def 10 20). p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ] newProcessWith: #(#abc #def 10 20).
p2 := [ :a :b :c :d | a dump. b dump. a dump. b dump. (c + d) dump. ^10000 ] newProcessWith: #( p2 := [ :a :b :c :d | a dump. b dump. a dump. b dump. (c + d) dump. ^10000 ] newProcessWith: #(
#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA #AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@ -80,7 +80,7 @@ class MyObject(TestObject)
'MIDDLE OF MAIN' dump. 'MIDDLE OF MAIN' dump.
Processor activeProcess terminate. Processor activeProcess terminate.
##p terminate. //p terminate.
'999999999999999999' dump. '999999999999999999' dump.
'999999999999999999' dump. '999999999999999999' dump.
'999999999999999999' dump. '999999999999999999' dump.
@ -88,7 +88,7 @@ class MyObject(TestObject)
'999999999999999999' dump. '999999999999999999' dump.
'999999999999999999' dump. '999999999999999999' dump.
'999999999999999999' dump. '999999999999999999' dump.
## p resume. // p resume.
'999999999999999999' dump. '999999999999999999' dump.
'999999999999999999' dump. '999999999999999999' dump.
'999999999999999999' dump. '999999999999999999' dump.

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {
@ -77,14 +77,14 @@ class MyObject(TestObject)
s2 := Semaphore forMutualExclusion. s2 := Semaphore forMutualExclusion.
t1 := [ t1 := [
##1000 timesRepeat: ['BLOCK #1' dump]. //1000 timesRepeat: ['BLOCK #1' dump].
s2 critical: [ s2 critical: [
10000 timesRepeat: ['BLOCK #1' dump ]. 10000 timesRepeat: ['BLOCK #1' dump ].
Exception signal: 'Raised Exception at process t1'. Exception signal: 'Raised Exception at process t1'.
] ]
] newProcess. ] newProcess.
t2 := [ t2 := [
##1000 timesRepeat: ['BLOCK #2' dump]. //1000 timesRepeat: ['BLOCK #2' dump].
s2 critical: [ s2 critical: [
10000 timesRepeat: ['BLOCK #2' dump. ] 10000 timesRepeat: ['BLOCK #2' dump. ]
]. ].
@ -120,13 +120,13 @@ class MyObject(TestObject)
k := 99. k := 99.
[ [
[ [
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ]. //[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ].
[ ^ 20 ] ensure: [ ('ensure 1 ' & (k asString)) dump. ]. [ ^ 20 ] ensure: [ ('ensure 1 ' & (k asString)) dump. ].
] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 2' dump ].
] ensure: ['ensure 3' dump ]. ] ensure: ['ensure 3' dump ].
] on: Exception do: [:ex | ] on: Exception do: [:ex |
('EXCETION - ' & ex messageText) dump. ('EXCETION - ' & ex messageText) dump.
## Exception signal: 'qqq'. // Exception signal: 'qqq'.
]. ].
^v1 ^v1
} }
@ -134,20 +134,20 @@ class MyObject(TestObject)
{ {
| v1 | | v1 |
'START OF MAIN' dump. 'START OF MAIN' dump.
##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump]. //[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump].
##['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' 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 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ].
##v1 dump. //v1 dump.
##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ]. //[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ].
##[ //[
## [ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ]. // [ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ].
##] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ]. //] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ].
##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']. //[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj'].
/* /*
v1 := [ v1 := [
@ -155,13 +155,13 @@ class MyObject(TestObject)
k := 99. k := 99.
[ [
[ [
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ]. //[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ].
[ ^20 ] ensure: [('ensure 1 ' & (k asString)) dump ]. [ ^20 ] ensure: [('ensure 1 ' & (k asString)) dump ].
] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 2' dump ].
] ensure: ['ensure 3' dump ]. ] ensure: ['ensure 3' dump ].
] on: Exception do: [:ex | ] on: Exception do: [:ex |
('EXCETION - ' & ex messageText) dump. ('EXCETION - ' & ex messageText) dump.
## Exception signal: 'qqq'. // Exception signal: 'qqq'.
]. ].
*/ */
@ -205,7 +205,7 @@ class MyObject(TestObject)
'WAITING ON S3...' dump. 'WAITING ON S3...' dump.
##System unsignal: s3. //System unsignal: s3.
s3 wait. s3 wait.
10 timesRepeat: ['WAITED t1 and t2' dump]. 10 timesRepeat: ['WAITED t1 and t2' dump].

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {
@ -69,13 +69,13 @@ class MyObject(TestObject)
'>>> TEST3 METHOD >>> ' dump. '>>> TEST3 METHOD >>> ' dump.
j dump. j dump.
(j < 25) ifTrue: [ | t | (j < 25) ifTrue: [ | t |
t := Exception signal: 'bad exceptinon'. ## when resumed, t should get Exception, the leftover in the stack... t := Exception signal: 'bad exceptinon'. // when resumed, t should get Exception, the leftover in the stack...
t signal: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. ## so it should be ok to signal again.. t signal: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'. // so it should be ok to signal again..
##t := self raise_exception. ## when resumed, t should get 'self' //t := self raise_exception. // when resumed, t should get 'self'
##g_ex retry. # You should not do these as the following 3 lines make things very complicated. //g_ex retry. # You should not do these as the following 3 lines make things very complicated.
##g_ex signal. //g_ex signal.
##g_ex pass. //g_ex pass.
'RESUMED???' dump. 'RESUMED???' dump.
t dump. t dump.
@ -98,8 +98,8 @@ class MyObject(TestObject)
'>>> TEST4_1 METHOD >>> ' dump. '>>> TEST4_1 METHOD >>> ' dump.
j dump. j dump.
(j < 25) ifTrue: [ | t | (j < 25) ifTrue: [ | t |
##t := Exception signal: 'bad exceptinon'. ## when resume, t should get Exception. //t := Exception signal: 'bad exceptinon'. // when resume, t should get Exception.
t := self raise_exception. ## when resumed, t should get 'self' t := self raise_exception. // when resumed, t should get 'self'
'RESUMED???' dump. 'RESUMED???' dump.
t dump. t dump.
j dump. j dump.
@ -130,8 +130,8 @@ class MyObject(TestObject)
'>>> TEST5 BLOCK >>> ' dump. '>>> TEST5 BLOCK >>> ' dump.
j dump. j dump.
(j < 25) ifTrue: [ | t | (j < 25) ifTrue: [ | t |
##t := Exception signal: 'bad exceptinon'. ## when resume, t should get Exception. //t := Exception signal: 'bad exceptinon'. // when resume, t should get Exception.
t := self raise_exception. ## when resumed, t should get 'self' t := self raise_exception. // when resumed, t should get 'self'
]. ].
'OOOOOOOOOOOOOOOOOOOOOOO' dump. 'OOOOOOOOOOOOOOOOOOOOOOO' dump.
@ -144,15 +144,15 @@ class MyObject(TestObject)
method(#class) test11 method(#class) test11
{ {
## exception is raised in a new process. it can't be captured // exception is raised in a new process. it can't be captured
## by an exception handler of a calling process. // by an exception handler of a calling process.
## exception handling must not cross the process boundary. // exception handling must not cross the process boundary.
'BEGINNING OF test11' dump. 'BEGINNING OF test11' dump.
[ [
|p | |p |
p := [ 'TEST11 IN NEW PROCESS' dump. Exception signal: 'Exception raised in a new process of test11'. ] newProcess. p := [ 'TEST11 IN NEW PROCESS' dump. Exception signal: 'Exception raised in a new process of test11'. ] newProcess.
'JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump. 'JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump.
p resume. ## resume the new process p resume. // resume the new process
] on: Exception do: [:ex | '---- EXCEPTION IN TEST11. THIS MUST NOT BE PRINTED----------' dump. ex messageText dump ]. ] on: Exception do: [:ex | '---- EXCEPTION IN TEST11. THIS MUST NOT BE PRINTED----------' dump. ex messageText dump ].
'END OF test11' dump. 'END OF test11' dump.
} }
@ -182,20 +182,20 @@ class MyObject(TestObject)
[ self main2 ] on: Exception do: [ :ex | [ self main2 ] on: Exception do: [ :ex |
'EXCEPTION CAUGHT IN MAIN....' dump. 'EXCEPTION CAUGHT IN MAIN....' dump.
ex messageText dump. ex messageText dump.
##ex pass. //ex pass.
'Returning back to where the exception has signalled in main2...' dump. 'Returning back to where the exception has signalled in main2...' dump.
##ex resume. //ex resume.
ex resume: 'RESUMED WITH THIS STRING'. ex resume: 'RESUMED WITH THIS STRING'.
]. ].
'##############################' dump. '//////////////////////////////' dump.
## self test3. // self test3.
## self test4. // self test4.
## self test5. // self test5.
self test11. self test11.
## self test12. // self test12.
## 100 timesRepeat: ['>>>>> END OF MAIN' dump]. // 100 timesRepeat: ['>>>>> END OF MAIN' dump].
/* /*
@ -215,12 +215,12 @@ class MyObject(TestObject)
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@' dump. '@@@@@@@@@@@@@@@@@@@@@@@@@@@@' dump.
## the following line(return:to:) must cause primitive failure... // the following line(return:to:) must cause primitive failure...
##[ Processor return: 10 to: 20. ] on: Exception do: [:ex | ex messageText dump]. //[ Processor return: 10 to: 20. ] on: Exception do: [:ex | ex messageText dump].
##[ Processor return: 10 to: 20. ] //[ Processor return: 10 to: 20. ]
## on: PrimitiveFailureException do: [:ex | 'PRIMITIVE FAILURE CAUGHT HERE HERE HERE' dump] // on: PrimitiveFailureException do: [:ex | 'PRIMITIVE FAILURE CAUGHT HERE HERE HERE' dump]
## on: Exception do: [:ex | ex messageText dump]. // on: Exception do: [:ex | ex messageText dump].
'SLEEPING FOR 10 seconds ....' dump. 'SLEEPING FOR 10 seconds ....' dump.
System sleepForSecs: 10. System sleepForSecs: 10.

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {
@ -65,13 +65,13 @@ class MyObject(TestObject)
k := 99. k := 99.
[ [
[ [
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ]. //[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ].
[ ^ 20 ] ensure: [ ('ensure 1 ' & (k asString)) dump. ]. [ ^ 20 ] ensure: [ ('ensure 1 ' & (k asString)) dump. ].
] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 2' dump ].
] ensure: ['ensure 3' dump ]. ] ensure: ['ensure 3' dump ].
] on: Exception do: [:ex | ] on: Exception do: [:ex |
('EXCETION - ' & ex messageText) dump. ('EXCETION - ' & ex messageText) dump.
## Exception signal: 'qqq'. // Exception signal: 'qqq'.
]. ].
^v1 ^v1
} }
@ -79,14 +79,14 @@ class MyObject(TestObject)
{ {
| v1 | | v1 |
'START OF MAIN' dump. 'START OF MAIN' dump.
##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump]. //[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump].
##['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' 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 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ].
##v1 dump. //v1 dump.
##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ]. //[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ].
/*[ /*[
[ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ]. [ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ].
@ -107,7 +107,7 @@ class MyObject(TestObject)
Exception signal: 'qqq'. Exception signal: 'qqq'.
]. ].
##[ ^20 ] ensure: [('ensure 1 ', (k asString)) dump ]. //[ ^20 ] ensure: [('ensure 1 ', (k asString)) dump ].
'KKKKKKKKKKKKKKKKKKKK' dump. 'KKKKKKKKKKKKKKKKKKKK' dump.
] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 2' dump ].
@ -118,9 +118,9 @@ class MyObject(TestObject)
('>>>> EXCETION - ' & ex messageText) dump. ('>>>> EXCETION - ' & ex messageText) dump.
ex pass. ex pass.
##Exception signal: 'XXXXXXXXXXXXx'. //Exception signal: 'XXXXXXXXXXXXx'.
## ex return: 10. // ex return: 10.
## Exception signal: 'qqq'. // Exception signal: 'qqq'.
]. ].
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump. 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump.
] ]
@ -132,7 +132,7 @@ class MyObject(TestObject)
]. ].
## v1 := self aaa_123. // v1 := self aaa_123.
'--------------------------------' dump. '--------------------------------' dump.
v1 dump. v1 dump.
'--------------------------------' dump. '--------------------------------' dump.

View File

@ -1,13 +1,13 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
## TODO: use #define to define a class or use #class to define a class. // TODO: use #define to define a class or use #class to define a class.
## use #extend to extend a class // use #extend to extend a class
## using #class for both feels confusing. // using #class for both feels confusing.
extend Apex extend Apex
{ {
@ -69,7 +69,7 @@ class MyObject(TestObject)
do: [:ex | do: [:ex |
System logNl: ('Exception: ' & ex messageText). System logNl: ('Exception: ' & ex messageText).
ex return: 10. ex return: 10.
##ex retry. //ex retry.
System logNl: '--- THIS MUST NOT BE PRINTED ---'. System logNl: '--- THIS MUST NOT BE PRINTED ---'.
]. ].
@ -80,7 +80,7 @@ class MyObject(TestObject)
v1 := [ v1 := [
[ [
[ [
##1 to: 20000 by: 1 do: [:i | System logNl: i asString. "System sleepForSecs: 1." ] //1 to: 20000 by: 1 do: [:i | System logNl: i asString. "System sleepForSecs: 1." ]
Processor activeProcess terminate. Processor activeProcess terminate.
] ensure: [ System logNl: '<<<PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP>>>' ]. ] ensure: [ System logNl: '<<<PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP>>>' ].
@ -92,9 +92,9 @@ class MyObject(TestObject)
System sleepForSecs: 1. System sleepForSecs: 1.
v1 terminate. v1 terminate.
##[ //[
## [ Processor activeProcess terminate. ] ensure: [System logNl: '<<<PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP>>>' ]. // [ Processor activeProcess terminate. ] ensure: [System logNl: '<<<PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP>>>' ].
##] ensure: [ System logNl: '<<--------------------->>' ]. //] ensure: [ System logNl: '<<--------------------->>' ].
System logNl: S'\0\0\0END OF MAIN\0AB\0\0\0C\0\0\0'. System logNl: S'\0\0\0END OF MAIN\0AB\0\0\0C\0\0\0'.
} }

View File

@ -1,9 +1,9 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
extend Apex extend Apex
{ {
@ -86,7 +86,7 @@ class MyConsole(Console)
class MyObject(TestObject) class MyObject(TestObject)
{ {
##import(#pooldic) ABC, SRX.ABC. //import(#pooldic) ABC, SRX.ABC.
import ABC, SRX.ABC. import ABC, SRX.ABC.
method(#class) main method(#class) main
@ -121,14 +121,14 @@ class MyObject(TestObject)
System logNl: S'\0\0\0END OF MAIN\0AB\0\0\0C\0\0\0'. System logNl: S'\0\0\0END OF MAIN\0AB\0\0\0C\0\0\0'.
##v1 := Stdio2 open: '/tmp/1.txt' for: 'w+'. //v1 := Stdio2 open: '/tmp/1.txt' for: 'w+'.
v1 := Stdio2 new open('/tmp/1.txt', 'w+'). v1 := Stdio2 new open('/tmp/1.txt', 'w+').
(v1 isError) (v1 isError)
ifTrue: [ ifTrue: [
System logNl: ('Error in opening a file....' & v1 asString). System logNl: ('Error in opening a file....' & v1 asString).
] ]
ifFalse: [ ifFalse: [
## v1 puts: 'hello'. // v1 puts: 'hello'.
v1 puts ('hello', 'world', 'good', C'\n', C'\t', 'under my umbrella 123.', C'\n'). v1 puts ('hello', 'world', 'good', C'\n', C'\t', 'under my umbrella 123.', C'\n').
v1 close. v1 close.
@ -169,7 +169,7 @@ class MyObject(TestObject)
0 priorTo: 200 do: [:i | 0 priorTo: 200 do: [:i |
| k | | k |
k := 1 bitShift: i. k := 1 bitShift: i.
## (k printStringRadix: 2) dump. // (k printStringRadix: 2) dump.
((k bitAt: i) = 1) ifFalse: [ ((k bitAt: i) = 1) ifFalse: [
System logNl: 'Test 5 failed'. System logNl: 'Test 5 failed'.
thisProcess terminate. thisProcess terminate.
@ -220,7 +220,7 @@ class MyObject(TestObject)
(thisContext vargAt: k) dump. (thisContext vargAt: k) dump.
]. ].
'varg_test3 end .....' dump. 'varg_test3 end .....' dump.
## ^b * 100 // ^b * 100
^f ^f
} }

View File

@ -1,9 +1,9 @@
#include 'Moo.moo'. #include 'Moo.moo'.
################################################################# ////////////////////////////////////////////////////////////////#
## MAIN // MAIN
################################################################# ////////////////////////////////////////////////////////////////#
class MyObject(Object) class MyObject(Object)
{ {
@ -42,7 +42,7 @@ class MyObject(Object)
ffi := FFI new: 'libc.so.6'. ffi := FFI new: 'libc.so.6'.
now := ffi call: #time signature: 'l)i' arguments: #(0). now := ffi call: #time signature: 'l)i' arguments: #(0).
####ffi call: #srand signature: 'i)' arguments: %(now). ////ffi call: #srand signature: 'i)' arguments: %(now).
ffi call: #srandom signature: 'i)' arguments: %(now). ffi call: #srandom signature: 'i)' arguments: %(now).
[ [
@ -51,24 +51,24 @@ class MyObject(Object)
while (true) while (true)
{ {
##x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20. //x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20.
##divd := (ffi call: #rand signature: ')i' arguments: nil). //divd := (ffi call: #rand signature: ')i' arguments: nil).
x := (ffi call: #random signature: ')l' arguments: nil) rem: 20. x := (ffi call: #random signature: ')l' arguments: nil) rem: 20.
divd := (ffi call: #random signature: ')l' arguments: nil). divd := (ffi call: #random signature: ')l' arguments: nil).
while (x > 0) while (x > 0)
{ {
##divd := (divd bitShift: 7) bitOr: (ffi call: #rand signature: ')i' arguments: nil). //divd := (divd bitShift: 7) bitOr: (ffi call: #rand signature: ')i' arguments: nil).
divd := (divd bitShift: 7) bitOr: (ffi call: #random signature: ')l' arguments: nil). divd := (divd bitShift: 7) bitOr: (ffi call: #random signature: ')l' arguments: nil).
x := x - 1. x := x - 1.
}. }.
##x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20. //x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20.
##divr := (ffi call: #rand signature: ')i' arguments: nil). //divr := (ffi call: #rand signature: ')i' arguments: nil).
x := (ffi call: #random signature: ')l' arguments: nil) rem: 20. x := (ffi call: #random signature: ')l' arguments: nil) rem: 20.
divr := (ffi call: #random signature: ')l' arguments: nil). divr := (ffi call: #random signature: ')l' arguments: nil).
while (x > 0) while (x > 0)
{ {
##divr := (divr bitShift: 7) bitOr: (ffi call: #rand signature: ')i' arguments: nil). //divr := (divr bitShift: 7) bitOr: (ffi call: #rand signature: ')i' arguments: nil).
divr := (divr bitShift: 7) bitOr: (ffi call: #random signature: ')l' arguments: nil). divr := (divr bitShift: 7) bitOr: (ffi call: #random signature: ')l' arguments: nil).
x := x - 1. x := x - 1.
}. }.
@ -77,7 +77,7 @@ class MyObject(Object)
q := divd div: divr. q := divd div: divr.
r := divd rem: divr. r := divd rem: divr.
if (divd ~= (q * divr + r)) { i dump. divd dump. divr dump. q dump. r dump. (q * divr + r) dump. ^false. }. if (divd ~= (q * divr + r)) { i dump. divd dump. divr dump. q dump. r dump. (q * divr + r) dump. ^false. }.
####((q asString) & ' ' & (r asString)) dump ////((q asString) & ' ' & (r asString)) dump
}. }.
] ensure: [ ffi close. ]. ] ensure: [ ffi close. ].
^true ^true

View File

@ -1119,8 +1119,28 @@ static int skip_comment (moo_t* moo)
/* handle block comment encoded in /x x/ where x is * */ /* handle block comment encoded in /x x/ where x is * */
lc = moo->c->lxc; lc = moo->c->lxc;
GET_CHAR_TO (moo, c); GET_CHAR_TO (moo, c);
if (c != '*') goto not_comment; if (c == '/')
{
do
{
GET_CHAR_TO (moo, c);
if (c == MOO_OOCI_EOF)
{
/* EOF on the comment line is ok for a single-line comment */
break;
}
else if (c == '\r' || c == '\n')
{
GET_CHAR (moo); /* keep the first meaningful character in lxc */
break;
}
}
while (1);
return 1; /* single line comment led by // */
}
else if (c == '*')
{
do do
{ {
GET_CHAR_TO (moo, c); GET_CHAR_TO (moo, c);
@ -1144,6 +1164,9 @@ static int skip_comment (moo_t* moo)
return 1; /* multi-line comment enclosed in /x and x/ where x is * */ return 1; /* multi-line comment enclosed in /x and x/ where x is * */
} }
goto not_comment;
}
else if (c == '#') else if (c == '#')
{ {
/* handle #! or ## */ /* handle #! or ## */
@ -1153,7 +1176,7 @@ static int skip_comment (moo_t* moo)
/* read a new character */ /* read a new character */
GET_CHAR_TO (moo, c); GET_CHAR_TO (moo, c);
if (c != '!' && c != '#') goto not_comment; if (c != '!') goto not_comment;
do do
{ {
GET_CHAR_TO (moo, c); GET_CHAR_TO (moo, c);
@ -1170,7 +1193,7 @@ static int skip_comment (moo_t* moo)
} }
while (1); while (1);
return 1; /* single line comment led by ## or #! */ return 1; /* single line comment led by #! */
} }
else else
{ {