From fcb987891e65fdeb5cb58b658dad047ab061d96e Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Thu, 27 Jun 2019 06:29:09 +0000 Subject: [PATCH] no more ## comment. // as a signle-line comment starter. --- moo/README.md | 42 ++++++++- moo/kernel/Apex.moo | 84 ++++++++--------- moo/kernel/Class.moo | 12 +-- moo/kernel/Collect.moo | 178 ++++++++++++++++++------------------ moo/kernel/Console.moo | 18 ++-- moo/kernel/Context.moo | 26 +++--- moo/kernel/Except.moo | 116 ++++++++++++------------ moo/kernel/FFI.moo | 2 +- moo/kernel/Fcgi.moo | 76 ++++++++-------- moo/kernel/Http.moo | 22 ++--- moo/kernel/Magnitu.moo | 34 +++---- moo/kernel/Mill.moo | 66 +++++++------- moo/kernel/Moo.moo | 2 +- moo/kernel/Process.moo | 102 ++++++++++----------- moo/kernel/Socket.moo | 150 +++++++++++++++---------------- moo/kernel/Stdio.moo | 4 +- moo/kernel/Stream.moo | 50 +++++------ moo/kernel/System.moo | 94 +++++++++---------- moo/kernel/X11.moo | 68 +++++++------- moo/kernel/test-001.moo | 88 +++++++++--------- moo/kernel/test-002.moo | 24 ++--- moo/kernel/test-003.moo | 42 ++++----- moo/kernel/test-004.moo | 16 ++-- moo/kernel/test-005.moo | 194 ++++++++++++++++++++-------------------- moo/kernel/test-006.moo | 16 ++-- moo/kernel/test-007.moo | 18 ++-- moo/kernel/test-008.moo | 12 +-- moo/kernel/test-009.moo | 12 +-- moo/kernel/test-010.moo | 44 ++++----- moo/kernel/test-011.moo | 66 +++++++------- moo/kernel/test-012.moo | 36 ++++---- moo/kernel/test-013.moo | 22 ++--- moo/kernel/test-014.moo | 16 ++-- moo/kernel/test-bi.moo | 22 ++--- moo/lib/comp.c | 59 ++++++++---- 35 files changed, 946 insertions(+), 887 deletions(-) diff --git a/moo/README.md b/moo/README.md index 2863c2a..b6da548 100644 --- a/moo/README.md +++ b/moo/README.md @@ -1,12 +1,19 @@ -## Top-level elemtns +### Top-level elements * #include * #pragma * class * interface * pooldic +### Comments -## Literal notations +~~~ +#! comment text +// comment text +/* comment text */ +~~~ + +### Literal notations * 200 decimal integer * 2r1100 binary integer * 16rFF00 hexadecimal integer @@ -48,4 +55,33 @@ The following are not literals. ** S%{A B C '\n'} * S%{} String with dynamic expression -* S%{ 65 asCharacter, 64 asCharacter } \ No newline at end of file +* 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 | ... ]. +~~~ + diff --git a/moo/kernel/Apex.moo b/moo/kernel/Apex.moo index 601b088..4f54352 100644 --- a/moo/kernel/Apex.moo +++ b/moo/kernel/Apex.moo @@ -19,7 +19,7 @@ class(#limited) Error(Apex) ERANGE := #\E20. ELIMIT := #\E9999. - ## add more items... + // add more items... } } @@ -39,7 +39,7 @@ pooldic Error.Code ERANGE := #\E20. ELIMIT := #\E9999. -## add more items... +// add more items... } */ /*pooldic Error.Code2 @@ -54,20 +54,20 @@ pooldic Error.Code extend Apex { - ## ------------------------------------------------------- - ## ------------------------------------------------------- + // ------------------------------------------------------- + // ------------------------------------------------------- method(#dual) dump { } - ## ------------------------------------------------------- - ## ------------------------------------------------------- + // ------------------------------------------------------- + // ------------------------------------------------------- method(#dual) yourself { ^self } - ## ------------------------------------------------------- - ## INSTANTIATION & INITIALIZATION - ## ------------------------------------------------------- + // ------------------------------------------------------- + // INSTANTIATION & INITIALIZATION + // ------------------------------------------------------- method(#class,#primitive,#lenient) _basicNew. method(#class,#primitive,#lenient) _basicNew: size. @@ -90,7 +90,7 @@ extend Apex { | x | 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. } @@ -98,7 +98,7 @@ extend Apex { | x | 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. } @@ -108,15 +108,15 @@ extend Apex ^self. } - ## ------------------------------------------------------- - ## ------------------------------------------------------- + // ------------------------------------------------------- + // ------------------------------------------------------- method(#dual,#primitive,#lenient) _shallowCopy. method(#dual,#primitive) shallowCopy. - method(#dual,#primitive,#lenient) _copy. ## alias to _shallowCopy - method(#dual,#primitive) copy. ## alias to shallowCopy + method(#dual,#primitive,#lenient) _copy. // alias to _shallowCopy + method(#dual,#primitive) copy. // alias to shallowCopy - ## ------------------------------------------------------- - ## ------------------------------------------------------- + // ------------------------------------------------------- + // ------------------------------------------------------- method(#dual,#primitive,#lenient) _basicSize. method(#dual,#primitive) basicSize. @@ -148,8 +148,8 @@ extend Apex * IDENTITY TEST * ------------------------------------------------------------------ */ - ## check if the receiver is identical to anObject. - ## this doesn't compare the contents + // check if the receiver is identical to anObject. + // this doesn't compare the contents method(#dual, #primitive) == anObject. method(#dual) ~~ anObject @@ -182,14 +182,14 @@ extend Apex method(#dual) isNil { - ## ^self == nil. + // ^self == nil. ^false } method(#dual) notNil { - ## ^(self == nil) not - ## ^self ~= nil. + // ^(self == nil) not + // ^self ~= nil. ^true. } @@ -203,8 +203,8 @@ extend Apex ^true } - ## ------------------------------------------------------- - ## ------------------------------------------------------- + // ------------------------------------------------------- + // ------------------------------------------------------- method(#class) inheritsFrom: aClass { @@ -242,13 +242,13 @@ extend Apex ^(self isMemberOf: aClass) or: [self class inheritsFrom: aClass]. } - ## ------------------------------------------------------- - ## ------------------------------------------------------- + // ------------------------------------------------------- + // ------------------------------------------------------- method(#dual,#primitive) respondsTo: selector. - ## ------------------------------------------------------- - ## ------------------------------------------------------- + // ------------------------------------------------------- + // ------------------------------------------------------- method(#dual,#variadic,#primitive) perform(selector). @@ -306,10 +306,10 @@ class UndefinedObject(Apex) method handleException: exception { - ('### EXCEPTION NOT HANDLED #### ' & exception class name & ' - ' & exception messageText) dump. - ## TODO: debug the current process???? " -## TODO: ensure to execute ensure blocks as well.... - ####Processor activeProcess terminate. + ('//# EXCEPTION NOT HANDLED //// ' & exception class name & ' - ' & exception messageText) dump. + // TODO: debug the current process???? " +// TODO: ensure to execute ensure blocks as well.... + ////Processor activeProcess terminate. } } @@ -362,28 +362,28 @@ extend Error exctx := (exctx sender) findExceptionContext. }. - ## ----------------------------------------------------------------- - ## FATAL ERROR - no exception handler. - ## ----------------------------------------------------------------- - ##thisContext unwindTo: nil return: nil. - ##thisContext unwindTo: (Processor activeProcess initialContext) return: nil. + // ----------------------------------------------------------------- + // FATAL ERROR - no exception handler. + // ----------------------------------------------------------------- + //thisContext unwindTo: nil return: nil. + //thisContext unwindTo: (Processor activeProcess initialContext) return: nil. -## TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... +// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... System logNl: '== BACKTRACE =='. ctx := thisContext. while (ctx notNil) { if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }. - ## TODO: include blockcontext??? + // TODO: include blockcontext??? ctx := ctx sender. }. System logNl: '== END OF BACKTRACE =='. thisContext unwindTo: (thisProcess initialContext) return: nil. - ('### ERROR NOT HANDLED #### ' & self class name & ' - ' & self asString) dump. - ## TODO: debug the current process???? " + ('//# ERROR NOT HANDLED //// ' & self class name & ' - ' & self asString) dump. + // TODO: debug the current process???? " - ##Processor activeProcess terminate. + //Processor activeProcess terminate. thisProcess terminate. } } diff --git a/moo/kernel/Class.moo b/moo/kernel/Class.moo index 0168db1..3f16bbc 100644 --- a/moo/kernel/Class.moo +++ b/moo/kernel/Class.moo @@ -4,10 +4,10 @@ interface ClassInterface method superclass. } -## -## the Class object should be a variable-pointer object because -## it needs to accomodate class instance variables. -## +// +// the Class object should be a variable-pointer object because +// it needs to accomodate class instance variables. +// class(#pointer,#limited) Class(Apex) [ClassInterface] { var spec, selfspec, superclass, subclasses, name, modname. @@ -24,8 +24,8 @@ class(#pointer,#limited) Class(Apex) [ClassInterface] method specNumInstVars { - ## shift right by 8 bits. - ## see MOO_CLASS_SPEC_NAMED_INSTVARS in moo-prv.h for details. + // shift right by 8 bits. + // see MOO_CLASS_SPEC_NAMED_INSTVARS in moo-prv.h for details. ^self.spec bitShift: -8 } diff --git a/moo/kernel/Collect.moo b/moo/kernel/Collect.moo index bf872fb..bf21ba7 100644 --- a/moo/kernel/Collect.moo +++ b/moo/kernel/Collect.moo @@ -26,9 +26,9 @@ class Collection(Object) self subclassResponsibility: #add:. } - ## =================================================================== - ## ENUMERATING - ## =================================================================== + // =================================================================== + // ENUMERATING + // =================================================================== method do: block { @@ -38,7 +38,7 @@ class Collection(Object) method collect: block { | coll | - ##coll := self class new: self basicSize. + //coll := self class new: self basicSize. coll := self class new. self do: [ :el | coll add: (block value: el) ]. ^coll @@ -51,7 +51,7 @@ class Collection(Object) 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 } ]. ^exception_block value. } @@ -59,7 +59,7 @@ class Collection(Object) method select: condition_block { | coll | - ##coll := self class new: self basicSize. + //coll := self class new: self basicSize. coll := self class new. self do: [ :el | if (condition_block value: el) { coll add: el } ]. ^coll @@ -68,7 +68,7 @@ class Collection(Object) method reject: condition_block { | coll | - ##coll := self class new: self basicSize. + //coll := self class new: self basicSize. coll := self class new. self do: [ :el | ifnot (condition_block value: el) { coll add: el } ]. ^coll @@ -80,7 +80,7 @@ class Collection(Object) } } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- class SequenceableCollection(Collection) { method do: aBlock @@ -113,7 +113,7 @@ class SequenceableCollection(Collection) 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 := self at: anIndex. @@ -123,7 +123,7 @@ class SequenceableCollection(Collection) } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- class(#pointer) Array(SequenceableCollection) { method size @@ -158,8 +158,8 @@ class(#pointer) Array(SequenceableCollection) method copy: anArray from: start to: end { - ## copy elements from an array 'anArray' starting from - ## the index 'start' to the index 'end'. + // copy elements from an array 'anArray' starting from + // the index 'start' to the index 'end'. | s i ss | @@ -192,8 +192,8 @@ class(#pointer) Array(SequenceableCollection) method copyFrom: start to: end { - ## returns a copy of the receiver starting from the element - ## at index 'start' to the element at index 'end'. + // returns a copy of the receiver starting from the element + // at index 'start' to the element at index 'end'. | newsz | newsz := end - start + 1. ^(self class new: newsz) copy: self from: start to: end @@ -255,7 +255,7 @@ class(#pointer) Array(SequenceableCollection) } } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- class(#character) String(Array) { @@ -299,7 +299,7 @@ class(#character) String(Array) method(#primitive,#variadic,#class) format(fmt). } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- class(#character,#final,#limited,#immutable) Symbol(String) { @@ -312,7 +312,7 @@ class(#character,#final,#limited,#immutable) Symbol(String) size := self basicSize. 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. while (i < size) { @@ -337,24 +337,24 @@ class(#character,#final,#limited,#immutable) Symbol(String) } } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- 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 { - ## TODO: support other encodings. it only supports utf8 as of now. + // TODO: support other encodings. it only supports utf8 as of now. self primitiveFailed(thisContext method). /* - ### TODO: implement this in moo also.. + //# TODO: implement this in moo also.. | firstByte | firstByte := self at: 0. if ((firstByte bitAnd:2r10000000) == 0) { 1 } @@ -371,13 +371,13 @@ class(#byte) ByteString(Array) { } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- class OrderedCollection(SequenceableCollection) { var buffer. 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 { @@ -416,7 +416,7 @@ class OrderedCollection(SequenceableCollection) 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 := index + self.firstIndex. if ((i >= self.firstIndex) and (i < self.lastIndex)) { ^self.buffer at: i put: obj }. @@ -554,19 +554,19 @@ class OrderedCollection(SequenceableCollection) method removeAtIndex: index { - ## remove the element at the given position. + // remove the element at the given position. | 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). ^obj } method remove: obj ifAbsent: error_block { - ## remove the first element equivalent to the given object. - ## and returns the removed element. - ## if no matching element is found, it evaluates error_block - ## and return the evaluation result. + // remove the first element equivalent to the given object. + // and returns the removed element. + // if no matching element is found, it evaluates error_block + // and return the evaluation result. | i cand | i := self.firstIndex. while (i < self.lastIndex) @@ -578,9 +578,9 @@ class OrderedCollection(SequenceableCollection) ^error_block value. } - ## ------------------------------------------------ - ## ENUMERATING - ## ------------------------------------------------ + // ------------------------------------------------ + // ENUMERATING + // ------------------------------------------------ method collect: aBlock { | coll | @@ -591,7 +591,7 @@ class OrderedCollection(SequenceableCollection) 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 := self.firstIndex. @@ -624,9 +624,9 @@ class OrderedCollection(SequenceableCollection) }. } - ## ------------------------------------------------ - ## PRIVATE METHODS - ## ------------------------------------------------ + // ------------------------------------------------ + // PRIVATE METHODS + // ------------------------------------------------ method __grow_and_shift(grow_size, shift_count) { | newcon | @@ -652,10 +652,10 @@ class OrderedCollection(SequenceableCollection) method __ensure_tail_room(size) { | tmp | - tmp := (self.buffer size) - self.lastIndex. ## remaining capacity + tmp := (self.buffer size) - self.lastIndex. // remaining capacity 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). } } @@ -666,8 +666,8 @@ class OrderedCollection(SequenceableCollection) if (index <= 0) { - ## treat a negative index as the indicator to - ## grow space in the front side. + // treat a negative index as the indicator to + // grow space in the front side. reqsize := index * -1 + 1. if (reqsize >= self.firstIndex) { self __ensure_head_room(reqsize) }. self.firstIndex := self.firstIndex + index - 1. @@ -705,10 +705,10 @@ class OrderedCollection(SequenceableCollection) method __remove_index(index) { - ## remove an element at the given index from the internal buffer's - ## 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 - ## grater than self.firstIndex and less than self.lastIndex. + // remove an element at the given index from the internal buffer's + // 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 + // grater than self.firstIndex and less than self.lastIndex. self.buffer replaceFrom: index to: self.lastIndex - 2 @@ -735,18 +735,18 @@ class OrderedCollection(SequenceableCollection) } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- class Set(Collection) { - ## The set class stores unordered elemenents and disallows duplicates. - ## It is implemented as an open-addressed hash table currently. + // The set class stores unordered elemenents and disallows duplicates. + // It is implemented as an open-addressed hash table currently. var tally, bucket. method(#class) new { - ^self new: 16. ### TODO: default size. + ^self new: 16. //# TODO: default size. } method(#class) new: capacity @@ -781,7 +781,7 @@ class Set(Collection) | newbuc newsz ass index i | /* 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. i := 0. while (i < bs) @@ -812,7 +812,7 @@ class Set(Collection) 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 @@ -872,9 +872,9 @@ class Set(Collection) { | index absent bs | - ## you cannot add nil to a set. however, the add: method doesn't - ## raise an exception for this. the includes: for nil returns - ## false naturally for the way it's implemented. + // you cannot add nil to a set. however, the add: method doesn't + // raise an exception for this. the includes: for nil returns + // false naturally for the way it's implemented. if (anObject isNil) { ^anObject }. index := self __find_index_for_add: anObject. @@ -934,12 +934,12 @@ class Set(Collection) method collect: aBlock { - ## override the default implementation to avoid frequent growth - ## of the new collection being constructed. the block tends to - ## include expression that will produce a unique value for each - ## element. so sizing the returning collection to the same size - ## as the receiver is likely to help. however, this assumption - ## isn't always true. + // override the default implementation to avoid frequent growth + // of the new collection being constructed. the block tends to + // include expression that will produce a unique value for each + // element. so sizing the returning collection to the same size + // as the receiver is likely to help. however, this assumption + // isn't always true. | coll | coll := self class new: self capacity. @@ -948,10 +948,10 @@ class Set(Collection) } } -## TODO: implement IdentitySet -##class IdentitySet(Set) -##{ -##} +// TODO: implement IdentitySet +//class IdentitySet(Set) +//{ +//} class AssociativeCollection(Collection) { @@ -1078,7 +1078,7 @@ class AssociativeCollection(Collection) method at: key put: value { - ## returns the affected/inserted association + // returns the affected/inserted association ^self __find: key or_upsert: true with: value. } @@ -1152,7 +1152,7 @@ class AssociativeCollection(Collection) self.bucket at: x put: nil. self.tally := self.tally - 1. - ## return the affected association + // return the affected association ^v } @@ -1204,9 +1204,9 @@ class AssociativeCollection(Collection) ^self __find: (anAssociation key) or_upsert: true with: (anAssociation value) } - ## =================================================================== - ## ENUMERATING - ## =================================================================== + // =================================================================== + // ENUMERATING + // =================================================================== method collect: aBlock { @@ -1220,9 +1220,9 @@ class AssociativeCollection(Collection) { | coll | coll := self class new. - ## TODO: using at:put: here isn't really right. implement add: to be able to insert the assocication without - ## creating another new association. - ##self associationsDo: [ :ass | if (aBlock value: ass value) { coll add: ass } ]. + // TODO: using at:put: here isn't really right. implement add: to be able to insert the assocication without + // creating another new association. + //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) } ]. ^coll } @@ -1287,9 +1287,9 @@ class Dictionary(AssociativeCollection) * for the dictionary expression notation - %{ } */ - ## TODO: implement Dictionary as a Hashed List/Table or Red-Black Tree - ## Do not inherit Set upon reimplementation - ## + // TODO: implement Dictionary as a Hashed List/Table or Red-Black Tree + // Do not inherit Set upon reimplementation + // method(#class) new: capacity { ^super new: (capacity + 10). @@ -1322,7 +1322,7 @@ class Dictionary(AssociativeCollection) { /* found */ 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. }. @@ -1354,14 +1354,14 @@ class(#limited) Namespace(AssociativeCollection) var name, nsup. 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 * 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 * namespace */ method nsup { ^self.nsup } - ## method nsup: nsup { self.nsup := nsup } + // method nsup: nsup { self.nsup := nsup } method at: key { @@ -1386,10 +1386,10 @@ class MethodDictionary(AssociativeCollection) extend Apex { - ## ------------------------------------------------------- - ## Association has been defined now. let's add association - ## creating methods - ## ------------------------------------------------------- + // ------------------------------------------------------- + // Association has been defined now. let's add association + // creating methods + // ------------------------------------------------------- method(#class) -> object { @@ -1402,7 +1402,7 @@ extend Apex } } -## ------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------- class Link(Object) { @@ -1567,9 +1567,9 @@ class LinkedList(Collection) extend Collection { - ## =================================================================== - ## CONVERSION - ## =================================================================== + // =================================================================== + // CONVERSION + // =================================================================== method asOrderedCollection { | coll | diff --git a/moo/kernel/Console.moo b/moo/kernel/Console.moo index 0498a56..cd936ad 100644 --- a/moo/kernel/Console.moo +++ b/moo/kernel/Console.moo @@ -1,4 +1,4 @@ -## TODO: move Pointe to a separate file +// TODO: move Pointe to a separate file class Point(Object) { var x, y. @@ -65,23 +65,23 @@ class Console(Object) from 'con' */ -## method(#class) input -## { -## ^self new _open: filename mode: mode -## } +// method(#class) input +// { +// ^self new _open: filename mode: mode +// } method(#class) output { | c | 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 } -## method(#class) error -## { -## } +// method(#class) error +// { +// } method close { diff --git a/moo/kernel/Context.moo b/moo/kernel/Context.moo index 586d946..d149b66 100644 --- a/moo/kernel/Context.moo +++ b/moo/kernel/Context.moo @@ -61,8 +61,8 @@ class(#pointer,#final,#limited) MethodContext(Context) self.ip := anInteger. } - ## it is similar to the pc: method but it doesn't - ## push the return value to the stack. + // it is similar to the pc: method but it doesn't + // push the return value to the stack. method(#primitive) goto: pc. method sp @@ -111,18 +111,18 @@ class(#pointer,#final,#limited) BlockContext(Context) ^self.home vargAt: index } -## TODO: how can i pass variadic arguments to newProcess -## method(#variadic) fork() -> how to pass them to newProcess??? +// TODO: how can i pass variadic arguments to newProcess +// method(#variadic) fork() -> how to pass them to newProcess??? method fork { - ## crate a new process in the runnable state + // crate a new process in the runnable state ^self newProcess resume. } - ## create a new process in the suspended state + // create a new process in the suspended state method(#variadic,#primitive) newProcess(). - ## evaluate the block + // evaluate the block method(#variadic,#primitive) value(). method value: a @@ -154,19 +154,19 @@ class(#pointer,#final,#limited) BlockContext(Context) method ifTrue: aBlock { - ##^(self value) ifTrue: aBlock. + //^(self value) ifTrue: aBlock. ^if (self value) { aBlock value }. } method ifFalse: aBlock { - ##^(self value) ifFalse: aBlock. + //^(self value) ifFalse: aBlock. ^if (self value) { /* nothing */ } else { aBlock value }. } 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 }. } @@ -254,7 +254,7 @@ class(#pointer,#final,#limited) BlockContext(Context) * -------------------------------------------------- | pc | pc := thisContext pcplus1. - (self value) ifTrue: [ ^nil ]. ## ^self + (self value) ifTrue: [ ^nil ]. // ^self aBlock value. thisContext goto: pc. * -------------------------------------------------- */ @@ -279,7 +279,7 @@ class(#pointer,#final,#limited) BlockContext(Context) * -------------------------------------------------- | pc | pc := thisContext pcplus1. - (self value) ifTrue: [ ^nil ]. ## ^self + (self value) ifTrue: [ ^nil ]. // ^self thisContext goto: pc. * -------------------------------------------------- */ while ((self value) == false) { }. @@ -314,7 +314,7 @@ class(#pointer,#final,#limited) BlockContext(Context) 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. method preamble diff --git a/moo/kernel/Except.moo b/moo/kernel/Except.moo index d3663f8..b425907 100644 --- a/moo/kernel/Except.moo +++ b/moo/kernel/Except.moo @@ -1,9 +1,9 @@ -## -## TODO: is it better to inherit from Object??? -## or treat Exception specially like UndefinedObject or Class??? -## +// +// TODO: is it better to inherit from Object??? +// or treat Exception specially like UndefinedObject or Class??? +// class Exception(Apex) { var signalContext, handlerContext. @@ -47,11 +47,11 @@ TODO: can i convert 'thisProcess primError' to a relevant exception? self.signalContext := thisContext. exctx := (thisContext sender) findExceptionContext. - ##[exctx notNil] whileTrue: [ + //[exctx notNil] whileTrue: [ while (exctx notNil) { 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))) { self.handlerContext := exctx. @@ -63,28 +63,28 @@ TODO: can i convert 'thisProcess primError' to a relevant exception? exctx := (exctx sender) findExceptionContext. }. - ## ----------------------------------------------------------------- - ## FATAL ERROR - no exception handler. - ## ----------------------------------------------------------------- - ##thisContext unwindTo: nil return: nil. - ##thisContext unwindTo: (Processor activeProcess initialContext) return: nil. + // ----------------------------------------------------------------- + // FATAL ERROR - no exception handler. + // ----------------------------------------------------------------- + //thisContext unwindTo: nil return: nil. + //thisContext unwindTo: (Processor activeProcess initialContext) return: nil. -## TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... +// TOOD: IMPROVE THIS EXPERIMENTAL BACKTRACE... System logNl: '== BACKTRACE =='. ctx := thisContext. while (ctx notNil) { if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }. - ## TODO: include blockcontext??? + // TODO: include blockcontext??? ctx := ctx sender. }. System logNl: '== END OF BACKTRACE =='. thisContext unwindTo: (thisProcess initialContext) return: nil. - ('### EXCEPTION NOT HANDLED(Exception) #### ' & self class name & ' - ' & self messageText) dump. - ## TODO: debug the current process???? " + ('//# EXCEPTION NOT HANDLED(Exception) //// ' & self class name & ' - ' & self messageText) dump. + // TODO: debug the current process???? " - ##Processor activeProcess terminate. + //Processor activeProcess terminate. thisProcess terminate. } @@ -96,7 +96,7 @@ System logNl: '== END OF BACKTRACE =='. method pass { - ## pass the exception to the outer context + // pass the exception to the outer context ((self.handlerContext sender) findExceptionContext) handleException: self. } @@ -107,7 +107,7 @@ System logNl: '== END OF BACKTRACE =='. method retry { -## TODO: verify if return:to: causes unnecessary stack growth. +// TODO: verify if return:to: causes unnecessary stack growth. if (self.handlerContext notNil) { self.handlerContext pc: 0. @@ -117,8 +117,8 @@ System logNl: '== END OF BACKTRACE =='. method resume: value { -## TODO: verify if return:to: causes unnecessary stack growth. -## is this correct??? +// TODO: verify if return:to: causes unnecessary stack growth. +// is this correct??? | ctx | if ((self.signalContext notNil) and (self.handlerContext notNil)) { @@ -135,7 +135,7 @@ System logNl: '== END OF BACKTRACE =='. } } -##============================================================================ +//============================================================================ extend Context { method isExceptionContext @@ -167,11 +167,11 @@ extend Context method unwindTo: context return: retval { - ## ------------------------------------------------------------------- - ## <> - ## private: called by VM upon unwinding as well as by - ## Exception<> + // private: called by VM upon unwinding as well as by + // Exception<>' & (method name) }. - ### 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) } - ### elsif (ec == Error.Code.EPERM) { self messageProhibited: method name } - ### elsif (ec == Error.Code.ENOIMPL) { self subclassResponsibility: method name }. + //# 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) } + //# elsif (ec == Error.Code.EPERM) { self messageProhibited: method name } + //# elsif (ec == Error.Code.ENOIMPL) { self subclassResponsibility: method name }. (PrimitiveFailureException /* in: method */ withErrorCode: ec) signal: msg. } method(#dual) doesNotUnderstand: message_name { - ## TODO: implement this properly + // TODO: implement this properly | class_name ctx | 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 =='. ctx := thisContext. while (ctx notNil) { if (ctx class == MethodContext) { System logNl: (' ' & ctx method owner name & '>>' & ctx method name) }. - ## TODO: include blockcontext??? + // TODO: include blockcontext??? ctx := ctx sender. }. System logNl: '== END OF BACKTRACE =='. diff --git a/moo/kernel/FFI.moo b/moo/kernel/FFI.moo index e04c0f1..335afd6 100644 --- a/moo/kernel/FFI.moo +++ b/moo/kernel/FFI.moo @@ -52,7 +52,7 @@ class FFI(Object) f := self.ffi getsym(name). if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }. 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 ]. diff --git a/moo/kernel/Fcgi.moo b/moo/kernel/Fcgi.moo index 327195a..5046a0c 100644 --- a/moo/kernel/Fcgi.moo +++ b/moo/kernel/Fcgi.moo @@ -1,4 +1,4 @@ -###include 'Moo.moo'. +//#include 'Moo.moo'. #include 'Socket.moo'. /* ------------------------------------------- @@ -219,7 +219,7 @@ class Fcgi.ParamRecord(Fcgi.Record) if (aString notNil) { -### TODO: implement this... +//# TODO: implement this... /* (aString subStrings: %(char)) do: [:each | equal := each indexOf: $=. @@ -288,7 +288,7 @@ class FcgiConnReg(Object) method initialize { | i size | - self.connections := Array new: 32. ## TODO: make it dynamic + self.connections := Array new: 32. // TODO: make it dynamic i := self.connections size. if (i <= 0) @@ -336,9 +336,9 @@ class FcgiConnReg(Object) method do: block { | index size conn | - ## 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 - ## impelemented. so no worry on this. + // 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 + // impelemented. so no worry on this. size := self.connections size. index := 0. while (index < size) @@ -406,39 +406,39 @@ class FcgiSocket(SyncSocket) 'IM RUNNING SERVICE...............' dump. - ## typedef struct { - ## unsigned char version; - ## unsigned char type; - ## unsigned char requestIdB1; - ## unsigned char requestIdB0; - ## unsigned char contentLengthB1; - ## unsigned char contentLengthB0; - ## unsigned char paddingLength; - ## unsigned char reserved; - ## } FCGI_Header; + // typedef struct { + // unsigned char version; + // unsigned char type; + // unsigned char requestIdB1; + // unsigned char requestIdB0; + // unsigned char contentLengthB1; + // unsigned char contentLengthB0; + // unsigned char paddingLength; + // unsigned char reserved; + // } FCGI_Header; /* ver := 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). plen := self.bs next. - self.bs next. ## eat up the reserved byte. + self.bs next. // eat up the reserved byte. */ - ## typedef struct { - ## unsigned char roleB1; - ## unsigned char roleB0; - ## unsigned char flags; - ## unsigned char reserved[5]; - ## } FCGI_BeginRequestBody; - ## typedef struct { - ## unsigned char appStatusB3; - ## unsigned char appStatusB2; - ## unsigned char appStatusB1; - ## unsigned char appStatusB0; - ## unsigned char protocolStatus; - ## unsigned char reserved[3]; - ## } FCGI_EndRequestBody; + // typedef struct { + // unsigned char roleB1; + // unsigned char roleB0; + // unsigned char flags; + // unsigned char reserved[5]; + // } FCGI_BeginRequestBody; + // typedef struct { + // unsigned char appStatusB3; + // unsigned char appStatusB2; + // unsigned char appStatusB1; + // unsigned char appStatusB0; + // unsigned char protocolStatus; + // unsigned char reserved[3]; + // } FCGI_EndRequestBody; /* if (type == Fcgi.Type.BEGIN_REQUEST) @@ -516,7 +516,7 @@ cliaddr dump. method acceptedSocketClass { - ##^if (self currentAddress port == 80) { FcgiSocket } else { FcgiSocket }. + //^if (self currentAddress port == 80) { FcgiSocket } else { FcgiSocket }. ^FcgiSocket. } @@ -569,7 +569,7 @@ class FcgiServer(Object) listener listen: 128. ] on: Exception do: [:ex | listener close. - ## ex pass. + // ex pass. Exception signal: ('unable to add new listener - ' & ex messageText). ]. } @@ -598,7 +598,7 @@ class FcgiServer(Object) { | listener | 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 ]. } @@ -647,7 +647,7 @@ class MyObject(Object) }. ]. clisck onEvent: #data_out do: [ :csck | - ##csck writeBytesFrom: #[ $a, $b, C'\n' ]. + //csck writeBytesFrom: #[ $a, $b, C'\n' ]. ]. clisck onEvent: #closed do: [ :csck | 'Socket CLOSED....' dump. @@ -713,7 +713,7 @@ class MyObject(Object) { ss := thisProcess handleAsyncEvent. if (ss isError) { break }. - ###if (ss == st) { thisProcess removeAsyncSemaphore: st }. + //#if (ss == st) { thisProcess removeAsyncSemaphore: st }. }. ] ensure: @@ -767,7 +767,7 @@ thisProcess terminate. /* [ 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 timeout: 5. fcgi connect: addr. diff --git a/moo/kernel/Http.moo b/moo/kernel/Http.moo index 6850873..1999f69 100644 --- a/moo/kernel/Http.moo +++ b/moo/kernel/Http.moo @@ -1,4 +1,4 @@ -###include 'Moo.moo'. +//#include 'Moo.moo'. #include 'Socket.moo'. class HttpConnReg(Object) @@ -10,7 +10,7 @@ class HttpConnReg(Object) method initialize { | i size | - self.connections := Array new: 32. ## TODO: make it dynamic + self.connections := Array new: 32. // TODO: make it dynamic i := self.connections size. if (i <= 0) @@ -58,9 +58,9 @@ class HttpConnReg(Object) method do: block { | index size conn | - ## 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 - ## impelemented. so no worry on this. + // 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 + // impelemented. so no worry on this. size := self.connections size. index := 0. while (index < size) @@ -199,7 +199,7 @@ cliaddr dump. method acceptedSocketClass { - ##^if (self currentAddress port == 80) { HttpSocket } else { HttpSocket }. + //^if (self currentAddress port == 80) { HttpSocket } else { HttpSocket }. ^HttpSocket. } @@ -252,7 +252,7 @@ class HttpServer(Object) listener listen: 128. ] on: Exception do: [:ex | listener close. - ## ex pass. + // ex pass. Exception signal: ('unable to add new listener - ' & ex messageText). ]. } @@ -281,7 +281,7 @@ class HttpServer(Object) { | listener | 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 ]. } @@ -330,7 +330,7 @@ class MyObject(Object) }. ]. clisck onEvent: #data_out do: [ :csck | - ##csck writeBytesFrom: #[ $a, $b, C'\n' ]. + //csck writeBytesFrom: #[ $a, $b, C'\n' ]. ]. clisck onEvent: #closed do: [ :csck | 'Socket CLOSED....' dump. @@ -396,7 +396,7 @@ class MyObject(Object) { ss := thisProcess handleAsyncEvent. if (ss isError) { break }. - ###if (ss == st) { thisProcess removeAsyncSemaphore: st }. + //#if (ss == st) { thisProcess removeAsyncSemaphore: st }. }. ] ensure: @@ -446,7 +446,7 @@ class MyObject(Object) /* [ 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 timeout: 5. httpd connect: addr. diff --git a/moo/kernel/Magnitu.moo b/moo/kernel/Magnitu.moo index 3eab22c..bf6b57b 100644 --- a/moo/kernel/Magnitu.moo +++ b/moo/kernel/Magnitu.moo @@ -12,13 +12,13 @@ class Magnitude(Object) method min: aMagnitude { - ##^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude] + //^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude] ^if (self < aMagnitude) { self } else { aMagnitude }. } method max: aMagnitude { - ##^self > aMagnitude ifTrue: [self] ifFalse: [aMagnitude] + //^self > aMagnitude ifTrue: [self] ifFalse: [aMagnitude] ^if (self > aMagnitude) { self } else { aMagnitude }. } @@ -67,8 +67,8 @@ class Association(Magnitude) class(#limited) Character(Magnitude) { -## method(#primitive,#class) codePoint: code. -## method(#primitive) codePoint. +// method(#primitive,#class) codePoint: code. +// method(#primitive) codePoint. method asCharacter { ^self } method(#primitive) asError. @@ -86,7 +86,7 @@ class(#limited) Character(Magnitude) method digitValue { - ## + // if ((self >= $0) and (self <= $9)) { @@ -101,7 +101,7 @@ class(#limited) Character(Magnitude) ^self asInteger - $a asInteger + 10 }. - ##Exception signal: 'not a digit character'. + //Exception signal: 'not a digit character'. ^-1 } } @@ -140,36 +140,36 @@ class(#limited) Number(Magnitude) method div: aNumber { - ## integer division rounded toward zero + // integer division rounded toward zero self primitiveFailed. } method rem: aNumber { - ## integer remainder rounded toward zero + // integer remainder rounded toward zero self primitiveFailed. } method mdiv: aNumber { - ## integer division quotient + // integer division quotient self primitiveFailed. } method mod: aNumber { - ## integer division remainder + // integer division remainder self primitiveFailed. } - ##method / aNumber - ##{ - ## ## fraction? fixed-point decimal? floating-point? - ##} + //method / aNumber + //{ + // // fraction? fixed-point decimal? floating-point? + //} method = aNumber { @@ -367,7 +367,7 @@ class(#limited) Integer(Number) { method timesRepeat: aBlock { - ## 1 to: self by: 1 do: [ :count | aBlock value ]. + // 1 to: self by: 1 do: [ :count | aBlock value ]. | count | count := 0. while (count < self) { aBlock value. count := count + 1 } @@ -375,10 +375,10 @@ class(#limited) Integer(Number) method asInteger { ^self } - ## integer has the scale of 0. + // integer has the scale of 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. } diff --git a/moo/kernel/Mill.moo b/moo/kernel/Mill.moo index bcdce8a..a468ff6 100644 --- a/moo/kernel/Mill.moo +++ b/moo/kernel/Mill.moo @@ -46,7 +46,7 @@ class MyObject(Object) /*k := Mill new. k register: #abc call: [ Dictionary new ]. a := k make: #abc. - ##a dump.*/ + //a dump.*/ d := Dictionary new. d at: #abc put: 20. @@ -61,9 +61,9 @@ class MyObject(Object) 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. - ##(System at: #MyObject) dump. + //(System at: #MyObject) dump. (d removeKey: #moo) dump. d removeKey: #abc ifAbsent: [System logNl: '#moo not found']. d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ]. @@ -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]. @@ -148,7 +148,7 @@ class MyObject(Object) ] value) dump. 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: [ [ @@ -169,16 +169,16 @@ class MyObject(Object) 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 := 5. a := while (true) { a := a + 1. - ##if (a > 20) { break if (true) { break. }. }. + //if (a > 20) { break if (true) { break. }. }. 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. }. @@ -188,13 +188,13 @@ class MyObject(Object) do { a := do { ('in loop.....' & a asString) dump. - ##if (a > 5) { break }. + //if (a > 5) { break }. a := a + 1. } while(a < 10). } while (false). a dump. - ## these should be elimited by the compiler. + // these should be elimited by the compiler. nil. 1. 0. @@ -203,14 +203,14 @@ class MyObject(Object) thisContext. 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) { - ##[: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. }. }. @@ -240,14 +240,14 @@ class MyObject(Object) a do: [ :v | v dump]. /* - ## how to handle return inside 'if' like the following??? - ## what happens to the stack? + // how to handle return inside 'if' like the following??? + // what happens to the stack? a := if ((k := 20) == 10) {99} else { 100}. k dump. a dump. */ '---------- END ------------' dump. - ##System sleepForSecs: 20. + //System sleepForSecs: 20. } @@ -256,21 +256,21 @@ class MyObject(Object) { |a i| -###self main_xx. +//#self main_xx. a := 100. - ## PROBLEM: the following double loop will exhaust the stack + // PROBLEM: the following double loop will exhaust the stack /* while (true) { - ##111 dump. + //111 dump. 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. - ##break. - ##[:j :q | (j + q) dump] value: 10 value: 20. - ##if (false) {} else { break }. + //break. + //[:j :q | (j + q) dump] value: 10 value: 20. + //if (false) {} else { break }. }. }.*/ @@ -281,14 +281,14 @@ class MyObject(Object) 'bbb' -> 30, #bbb -> 40, Association key: 12343 value: 129908123, - ##5 -> 99, + //5 -> 99, 'ccc' -> 890 }. /*a removeKey: '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 | k 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 */ - ## (System nsdic) keysAndValuesDo: [:k :v | - ## k dump. - ## v dump. - ## '------------' dump. - ## ]. + // (System nsdic) keysAndValuesDo: [:k :v | + // k dump. + // v dump. + // '------------' dump. + // ]. (System at: #Processor) dump. @@ -337,8 +337,8 @@ while (i > 0) a getUint32(0) dump. a getUint32(1) dump. -##a dump. -##System free(a). +//a dump. +//System free(a). a free. System sleepForSecs: 2. @@ -365,6 +365,6 @@ a free. /* pooldic XXD { #abc := #(1 2 3). - #def := %( 1, 3, 4 ). ## syntax error - literal expected where %( is + #def := %( 1, 3, 4 ). // syntax error - literal expected where %( is } */ diff --git a/moo/kernel/Moo.moo b/moo/kernel/Moo.moo index ec89090..a2fc329 100644 --- a/moo/kernel/Moo.moo +++ b/moo/kernel/Moo.moo @@ -12,4 +12,4 @@ /* -------------------------------------------------------------------------- */ #include 'FFI.moo'. #include 'Stdio.moo'. -## #include 'Console.moo'. +// #include 'Console.moo'. diff --git a/moo/kernel/Process.moo b/moo/kernel/Process.moo index 85efced..c7b7fe2 100644 --- a/moo/kernel/Process.moo +++ b/moo/kernel/Process.moo @@ -20,30 +20,30 @@ class(#pointer,#final,#limited) Process(Object) method terminate { - ## 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, - ## the ensureblock is not executed in the context of the - ## process being terminated, but in the context of terminatig process. - ## - ## 1) process termianted by another process - ## p := [ - ## [ 1 to: 10000 by: 1 do: [:ex | System logNl: i asString] ] ensure: [System logNl: 'ensured....'] - ## ] newProcess. - ## p resume. - ## p terminate. - ## - ## 2) process terminated by itself - ## p := [ - ## [ thisProcess terminate. ] ensure: [System logNl: 'ensured....'] - ## ] newProcess. - ## p resume. - ## p terminate. - ## ---------------------------------------------------------------------------------------------------------- - ## the process must be frozen first. while unwinding is performed, - ## the process must not be scheduled. - ## ---------------------------------------------------------------------------------------------------------- + // 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, + // the ensureblock is not executed in the context of the + // process being terminated, but in the context of terminatig process. + // + // 1) process termianted by another process + // p := [ + // [ 1 to: 10000 by: 1 do: [:ex | System logNl: i asString] ] ensure: [System logNl: 'ensured....'] + // ] newProcess. + // p resume. + // p terminate. + // + // 2) process terminated by itself + // p := [ + // [ thisProcess terminate. ] ensure: [System logNl: 'ensured....'] + // ] newProcess. + // p resume. + // p terminate. + // ---------------------------------------------------------------------------------------------------------- + // the process must be frozen first. while unwinding is performed, + // the process must not be scheduled. + // ---------------------------------------------------------------------------------------------------------- - ##if (Processor activeProcess ~~ self) { self suspend }. + //if (Processor activeProcess ~~ self) { self suspend }. if (thisProcess ~~ self) { self suspend }. self.currentContext unwindTo: self.initialContext return: nil. ^self _terminate @@ -75,13 +75,13 @@ class Semaphore(Object) var waiting_head := 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 - fireTimeSec := nil, ## overlaps as ioHandle - fireTimeNsec := nil. ## overlaps as ioType + var heapIndex := nil, // overlaps as ioIndex + fireTimeSec := nil, // overlaps as ioHandle + fireTimeNsec := nil. // overlaps as ioType var(#get,#set) signalAction := nil. @@ -89,7 +89,7 @@ class Semaphore(Object) _grm_next := nil, _grm_prev := nil. - ## ================================================================== + // ================================================================== method(#primitive) signal. method(#primitive) _wait. @@ -102,7 +102,7 @@ class Semaphore(Object) ^k } - ## ================================================================== + // ================================================================== method(#primitive) signalAfterSecs: secs. method(#primitive) signalAfterSecs: secs nanosecs: nanosecs. @@ -111,7 +111,7 @@ class Semaphore(Object) method(#primitive) signalOnGCFin. method(#primitive) unsignal. - ## ================================================================== + // ================================================================== method heapIndex: index { @@ -122,9 +122,9 @@ class Semaphore(Object) ^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 { ^self.fireTimeSec @@ -175,7 +175,7 @@ TODO: how to prohibit wait and signal??? 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, waiting_tail := nil. @@ -207,7 +207,7 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit x := self _wait. 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 }. }. ^x @@ -217,26 +217,26 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit { | s r | - ## create an internal semaphore for timeout notification. + // create an internal semaphore for timeout notification. s := Semaphore new. self addSemaphore: s. [ - ## arrange the processor to notify upon timeout. + // arrange the processor to notify upon timeout. s signalAfterSecs: seconds. - ## wait on the semaphore group. + // wait on the semaphore group. r := self wait. - ## if the internal semaphore has been signaled, - ## arrange to return nil to indicate timeout. - if (r == s) { r := nil } ## timed out - elsif (r signalAction notNil) { r signalAction value: r }. ## run the signal action block + // if the internal semaphore has been signaled, + // arrange to return nil to indicate timeout. + if (r == s) { r := nil } // timed out + elsif (r signalAction notNil) { r signalAction value: r }. // run the signal action block ] ensure: [ - ## System< extend to support fixed 4 bytes by throwing an error in basicNew:. -### -> #byte(4,fixed)? -### -> #byte -> byte variable/flexible -### -> #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. -### -> #byte(4,4) -> it can emulated fixed byte size. -> do i have space in spec to store the upper bound? +//# TODO: extend the compiler +//# #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:. +//# -> #byte(4,fixed)? +//# -> #byte -> byte variable/flexible +//# -> #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. +//# -> #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) { @@ -70,7 +70,7 @@ class(#byte(4)) IP4Address(IPAddress) else { ^Error.Code.EINVAL - ### goto @label@. + //# goto @label@. }. } while (true). @@ -98,10 +98,10 @@ class(#byte(16)) IP6Address(IP4Address) ^self basicNew: 16. }*/ - ##method(#class) fromString: str - ##{ - ## ^self new fromString: str. - ##} + //method(#class) fromString: str + //{ + // ^self new fromString: str. + //} method __fromString: str { @@ -111,7 +111,7 @@ class(#byte(16)) IP6Address(IP4Address) size := str size. mysize := self basicSize. - ## handle leading :: specially + // handle leading :: specially if ((size > 0) and ((str at: pos) == $:)) { pos := pos + 1. @@ -143,17 +143,17 @@ class(#byte(16)) IP6Address(IP4Address) curseg := pos. if (saw_xdigit not) { - ## no multiple double colons are allowed + // no multiple double colons are allowed if (colonpos >= 0) { ^Error.Code.EINVAL }. - ## capture the target position when the double colons - ## are encountered. + // capture the target position when the double colons + // are encountered. colonpos := tgpos. continue. } elsif (pos >= size) { - ## a colon can't be the last character + // a colon can't be the last character ^Error.Code.EINVAL }. @@ -169,14 +169,14 @@ class(#byte(16)) IP6Address(IP4Address) 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 }. tgpos := tgpos + 4. saw_xdigit := false. break. }. - ## invalid character in the address + // invalid character in the address ^Error.Code.EINVAL. }. @@ -190,9 +190,9 @@ class(#byte(16)) IP6Address(IP4Address) if (colonpos >= 0) { - ## double colon position + // double colon position self basicShiftFrom: colonpos to: (colonpos + (mysize - tgpos)) count: (tgpos - colonpos). - ##tgpos := tgpos + (mysize - tgpos). + //tgpos := tgpos + (mysize - tgpos). } elsif (tgpos ~~ mysize) { @@ -208,9 +208,9 @@ class(#byte(16)) IP6Address(IP4Address) } } - ##method toString - ##{ - ##} + //method toString + //{ + //} } class(#byte) SocketAddress(Object) from 'sck.addr' @@ -226,11 +226,11 @@ class(#byte) SocketAddress(Object) from 'sck.addr' class Socket(Object) from 'sck' { - ## the handle must be the first field in this object to match - ## the internal representation used by various modules. (e.g. sck) + // the handle must be the first field in this object to match + // the internal representation used by various modules. (e.g. sck) 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 { INET := 2. @@ -244,8 +244,8 @@ class Socket(Object) from 'sck' } method(#primitive) open(family, type, proto). - ## 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. + // 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. method(#primitive) __open(handle). method(#primitive) _close. @@ -265,16 +265,16 @@ class Socket(Object) from 'sck' method(#class) __with_handle: handle { - ###self addToBeFinalized. + //#self addToBeFinalized. ^(super new) __open(handle) } method(#class) family: family type: type { - ###self addToBeFinalized. + //#self addToBeFinalized. - ## new is prohibited. so use _basicNew with initialize. - ##^(self new) open(family, type, 0) + // new is prohibited. so use _basicNew with initialize. + //^(self new) open(family, type, 0) ^(super new) open(family, type, 0) } @@ -292,7 +292,7 @@ class Socket(Object) from 'sck' method onSocketClosed { - ## do nothing. + // do nothing. } } @@ -307,16 +307,16 @@ class SyncSocket(Socket) /* method(#class) __with_handle: handle { - ###self addToBeFinalized. + //#self addToBeFinalized. ^(super new) __open(handle) } method(#class) family: family type: type { - ###self addToBeFinalized. + //#self addToBeFinalized. - ## new is prohibited. so use _basicNew with initialize. - ##^(self new) open(family, type, 0) + // new is prohibited. so use _basicNew with initialize. + //^(self new) open(family, type, 0) ^(super new) open(family, type, 0) } */ @@ -335,7 +335,7 @@ class SyncSocket(Socket) method beWatched { - ## do nothing. i don't want to be watched. + // do nothing. i don't want to be watched. } method timeout: secs @@ -370,10 +370,10 @@ class SyncSocket(Socket) { | soerr | - ## an exception is thrown upon exception failure. + // an exception is thrown upon exception failure. if ((super _connect: addr) <= -1) { - ## connection in progress + // connection in progress while (true) { self __wait_for_output. @@ -549,9 +549,9 @@ class AsyncSocket(Socket) Exception signal: 'Not allowed to write again'. }. - ## n >= 0: written - ## n <= -1: tolerable error (e.g. EAGAIN) - ## exception: fatal error + // n >= 0: written + // n <= -1: tolerable error (e.g. EAGAIN) + // exception: fatal error pos := offset. rem := length. @@ -583,9 +583,9 @@ class AsyncSocket(Socket) ^self writeBytesFrom: bytes offset: 0 length: (bytes size) } - ##method onSocketClosed - ##{ - ##} + //method onSocketClosed + //{ + //} method onSocketDataIn { @@ -612,7 +612,7 @@ class AsyncClientSocket(AsyncSocket) soerr := self _socketError. if (soerr >= 0) { - ## finalize connection if not in progress + // finalize connection if not in progress sem unsignal. thisProcess removeAsyncSemaphore: sem. @@ -644,7 +644,7 @@ class AsyncClientSocket(AsyncSocket) } else { - ## connected immediately + // connected immediately 'IMMEDIATELY CONNECTED.....' dump. self onSocketConnected: true. @@ -656,7 +656,7 @@ class AsyncClientSocket(AsyncSocket) 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. fd := self _accept: cliaddr. - ##if (fd >= 0) + //if (fd >= 0) if (fd notNil) { clisck := (self acceptedSocketClass) __with_handle: fd. @@ -699,13 +699,13 @@ class AsyncServerSocket(AsyncSocket) { | n | - ## If listen is called before the socket handle is - ## added to the multiplexer, a spurious hangup event might - ## be generated. At least, such behavior was observed - ## in linux with epoll in the level trigger mode. - ## self.inreadysem signalOnInput: self.handle. - ## thisProcess addAsyncSemaphore: self.inreadysem. - ## self _listen: backlog. + // If listen is called before the socket handle is + // added to the multiplexer, a spurious hangup event might + // be generated. At least, such behavior was observed + // in linux with epoll in the level trigger mode. + // self.inreadysem signalOnInput: self.handle. + // thisProcess addAsyncSemaphore: self.inreadysem. + // self _listen: backlog. n := self _listen: backlog. self.inreadysem signalOnInput: self.handle. @@ -715,8 +715,8 @@ class AsyncServerSocket(AsyncSocket) method onSocketAccepted: clisck from: cliaddr { - ## close the accepted client socket immediately. - ## a subclass must override this to avoid it. + // close the accepted client socket immediately. + // a subclass must override this to avoid it. clisck close. } @@ -741,7 +741,7 @@ class ListenerSocket(Socket) cliaddr := SocketAddress new. fd := self _accept: cliaddr. - ##if (fd >= 0) + //if (fd >= 0) if (fd notNil) { clisck := (self acceptedSocketClass) __with_handle: fd. @@ -773,13 +773,13 @@ class ListenerSocket(Socket) { | n | - ## If listen is called before the socket handle is - ## added to the multiplexer, a spurious hangup event might - ## be generated. At least, such behavior was observed - ## in linux with epoll in the level trigger mode. - ## self.inreadysem signalOnInput: self.handle. - ## thisProcess addAsyncSemaphore: self.inreadysem. - ## self _listen: backlog. + // If listen is called before the socket handle is + // added to the multiplexer, a spurious hangup event might + // be generated. At least, such behavior was observed + // in linux with epoll in the level trigger mode. + // self.inreadysem signalOnInput: self.handle. + // thisProcess addAsyncSemaphore: self.inreadysem. + // self _listen: backlog. n := self _listen: backlog. @@ -795,8 +795,8 @@ class ListenerSocket(Socket) method onSocketAccepted: clisck from: cliaddr { - ## close the accepted client socket immediately. - ## a subclass must override this to avoid it. + // close the accepted client socket immediately. + // a subclass must override this to avoid it. clisck close. } diff --git a/moo/kernel/Stdio.moo b/moo/kernel/Stdio.moo index 31c4906..3fb8774 100644 --- a/moo/kernel/Stdio.moo +++ b/moo/kernel/Stdio.moo @@ -66,8 +66,8 @@ class Stdio2(Stdio) { method(#class) new { - ##self prohibited - ##raise exception. prohibited... + //self prohibited + //raise exception. prohibited... ^(super new). } } diff --git a/moo/kernel/Stream.moo b/moo/kernel/Stream.moo index 8c0cff1..8983fa8 100644 --- a/moo/kernel/Stream.moo +++ b/moo/kernel/Stream.moo @@ -2,7 +2,7 @@ class Stream(Object) { method(#class) new { - ## you must use dedicated class methods for instantiation + // you must use dedicated class methods for instantiation self messageProhibited: #new. } @@ -18,13 +18,13 @@ class Stream(Object) method next { - ## return the next object in the receiver + // return the next object in the receiver ^self subclassResponsibility: #next. } 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. } @@ -100,7 +100,7 @@ class PositionableStream(Stream) method position: pos { - ##if (pos >= 0 and + //if (pos >= 0 and } method reset @@ -126,7 +126,7 @@ class ExternalStream(ReadWriteStream) } /* -## mimic java's interface... +// mimic java's interface... interface ByteStreamable { 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? @@ -188,7 +188,7 @@ extension String: StringConvertible { Let me think about it.. */ -class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] +class ByteStreamAdapter(Object) //# [ByteStreamable, ByteXXX] { var bsobj. var inbuf. @@ -239,12 +239,12 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] { | v | v := self.bsobj readBytesInto: self.inbuf. - ## if the streamable object is not blocking, it may return an - ## error object when data is not ready. + // if the streamable object is not blocking, it may return an + // error object when data is not ready. if (v isError) { ^v }. if (v == 0) { - ## end of input + // end of input self.indown := true. ^v }. @@ -262,9 +262,9 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] if (self.inpos >= self.inlen) { 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 (self.inpos >= self.inlen) { ^nil }. + ////if (self.inpos >= self.inlen) { ^nil }. }. v := self.inbuf at: self.inpos. @@ -274,15 +274,15 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] method next: count into: byte_array startingAt: pos { - ## return the count bytes + // return the count bytes | taken avail needed v incapa | if (self.indown) { ^0 }. - ## i assume the given byte array is large enough - ## to store as many as count bytes starting at the pos position. - ## if the parameters cannot meet this assumption, you will get - ## into various system exceptions. + // i assume the given byte array is large enough + // to store as many as count bytes starting at the pos position. + // if the parameters cannot meet this assumption, you will get + // into various system exceptions. needed := count. incapa := self.inbuf size. @@ -293,11 +293,11 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] { if (needed >= incapa) { - ## don't rely on the internal buffer if the number of bytes - ## needed are equal to or greater than the capacity of the - ## buffer. + // don't rely on the internal buffer if the number of bytes + // needed are equal to or greater than the capacity of the + // buffer. 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. needed := needed - v. continue. @@ -305,7 +305,7 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] else { 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. if (free <= 0) { - self flush. ## TODO: error handling... + self flush. // TODO: error handling... }. if (self.outlen <= 0 and rem >= outcapa) { 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 { @@ -363,7 +363,7 @@ class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX] while (pos < self.outlen) { 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. }. diff --git a/moo/kernel/System.moo b/moo/kernel/System.moo index 43f4c8d..bbe59d6 100644 --- a/moo/kernel/System.moo +++ b/moo/kernel/System.moo @@ -1,12 +1,12 @@ -## TODO: consider if System can replace Apex itself. -## System, being the top class, seems to give very natural way of -## offering global system-level functions and interfaces. -## -## class System(nil) { ... } -## class Object(System) { .... } -## System at: # -## System logNl: 'xxxxx'. -## System getUint8(ptr,offset) +// TODO: consider if System can replace Apex itself. +// System, being the top class, seems to give very natural way of +// offering global system-level functions and interfaces. +// +// class System(nil) { ... } +// class Object(System) { .... } +// System at: # +// System logNl: 'xxxxx'. +// System getUint8(ptr,offset) class System(Apex) { @@ -14,10 +14,10 @@ class System(Apex) pooldic Log { - ## ----------------------------------------------------------- - ## defines log levels - ## these items must follow defintions in moo.h - ## ----------------------------------------------------------- + // ----------------------------------------------------------- + // defines log levels + // these items must follow defintions in moo.h + // ----------------------------------------------------------- DEBUG := 1. INFO := 2. @@ -47,19 +47,19 @@ class System(Apex) 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) { self error: ('Cannot find the class - ' & class_name). }. - ## start the gc finalizer process + // start the gc finalizer process [ 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. - #### System logNl: '======= END of startup ==============='. + //// System logNl: '======= END of startup ==============='. ^ret. } @@ -77,14 +77,14 @@ class System(Apex) { 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 (Processor total_count == 1) + //if (Processor total_count == 1) 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) { System logNl: 'Exiting the GC finalization process ' & (thisProcess id) asString. @@ -100,10 +100,10 @@ class System(Apex) gc := false. }. - ##System logNl: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^gc_waiting....'. - ##System sleepForSecs: 1. ## TODO: wait on semaphore instead.. + //System logNl: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^gc_waiting....'. + //System sleepForSecs: 1. // TODO: wait on semaphore instead.. gcfin_sem wait. - ##System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX gc_waitED....'. + //System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX gc_waitED....'. } ] ensure: [ gcfin_sem unsignal. @@ -116,12 +116,12 @@ class System(Apex) method(#class,#primitive) gc. method(#class,#primitive) return: object to: context. - ## ======================================================================================= + // ======================================================================================= method(#class) sleepForSecs: secs { - ## ----------------------------------------------------- - ## put the calling process to sleep for given seconds. - ## ----------------------------------------------------- + // ----------------------------------------------------- + // put the calling process to sleep for given seconds. + // ----------------------------------------------------- | s | s := Semaphore new. s signalAfterSecs: secs. @@ -130,20 +130,20 @@ class System(Apex) 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 := Semaphore new. s signalAfterSecs: secs nanosecs: nanosecs. s wait. } - ## the following methods may not look suitable to be placed - ## inside a system dictionary. but they are here for quick and dirty - ## output production from the moo code. - ## System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'. - ## + // the following methods may not look suitable to be placed + // inside a system dictionary. but they are here for quick and dirty + // output production from the moo code. + // System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'. + // 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 { - ## do nothing upon logging failure + // do nothing upon logging failure } method(#class) atLevel: level log: message and: message2 { - ## do nothing upon logging failure + // do nothing upon logging failure } method(#class) atLevel: level log: message and: message2 and: message3 { - ## do nothing upon logging failure + // do nothing upon logging failure } method(#class) atLevel: level logNl: message { - ## the #_log primitive accepts an array. - ## so the following lines should work also. - ## | x | - ## x := Array new: 2. - ## x at: 0 put: message. - ## x at: 1 put: S'\n'. - ## ^self atLevel: level log: x. + // the #_log primitive accepts an array. + // so the following lines should work also. + // | x | + // x := Array new: 2. + // x at: 0 put: message. + // x at: 1 put: S'\n'. + // ^self atLevel: level log: x. ^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. /* raw memory access */ - method(#class,#primitive) getInt8 (rawptr, offset). ## + method(#class,#primitive) getInt8 (rawptr, offset). // method(#class,#primitive) getInt16 (rawptr, offset). method(#class,#primitive) getInt32 (rawptr, offset). method(#class,#primitive) getInt64 (rawptr, offset). - method(#class,#primitive) getUint8 (rawptr, offset). ## + method(#class,#primitive) getUint8 (rawptr, offset). // method(#class,#primitive) getUint16 (rawptr, offset). method(#class,#primitive) getUint32 (rawptr, offset). method(#class,#primitive) getUint64 (rawptr, offset). diff --git a/moo/kernel/X11.moo b/moo/kernel/X11.moo index 1a3ffff..f3832de 100644 --- a/moo/kernel/X11.moo +++ b/moo/kernel/X11.moo @@ -29,15 +29,15 @@ method(#dual,#liberal) def(x, z) { ^nil } class X11(Object) [X11able,selfns.X11able3] from 'x11' { - ## ===================================================================== - ## this part of the class must match the internal - ## definition struct x11_t defined in _x11.h - ## --------------------------------------------------------------------- + // ===================================================================== + // this part of the class must match the internal + // definition struct x11_t defined in _x11.h + // --------------------------------------------------------------------- var display_base := 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 llevent_blocks. @@ -45,7 +45,7 @@ class X11(Object) [X11able,selfns.X11able3] from 'x11' method(#dual) abc { ^nil } method(#dual,#liberal) def(x, z) { ^nil } -###method(#dual) abc3 { ^nil } +//#method(#dual) abc3 { ^nil } interface X11able3 { @@ -108,8 +108,8 @@ TODO: TODO: compiler enhancement method(#primitive) _destroy_window(window_handle). method(#primitive) _create_gc (window_handle). - 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) _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) _draw_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) { | w | -###('DESTROY ' & window_handle asString) dump. +//#('DESTROY ' & window_handle asString) dump. w := self _destroy_window(window_handle). if (w notError) { self.window_registrar removeKey: window_handle } } } -## --------------------------------------------------------------------------- -## Event -## --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// Event +// --------------------------------------------------------------------------- pooldic X11.LLEventType { KEY_PRESS := 2. @@ -179,7 +179,7 @@ class X11.MouseEvent(X11.Event) var(#get,#set) x := 0, y := 0, - button := 0. ## X11.MouseButton + button := 0. // X11.MouseButton } class X11.MouseWheelEvent(X11.Event) @@ -201,9 +201,9 @@ class X11.ExposeEvent(X11.Event) -## --------------------------------------------------------------------------- -## X11 Context -## --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// X11 Context +// --------------------------------------------------------------------------- pooldic X11.GCLineStyle { SOLID := 0. @@ -221,7 +221,7 @@ pooldic X11.GCFillStyle 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. @@ -293,9 +293,9 @@ widget windowHandle dump. } } -## --------------------------------------------------------------------------- -## X11 Widgets -## --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// X11 Widgets +// --------------------------------------------------------------------------- class X11.Widget(Object) { @@ -505,7 +505,7 @@ class X11.Composite(X11.Widget) { super onPaintEvent: event. self.children do: [:child | - ## TODO: adjust event relative to each child... + // TODO: adjust event relative to each child... child onPaintEvent: event. ] } @@ -521,16 +521,16 @@ class X11.Shell(X11.Composite) self.title := title. } -#### TODO: -#### redefine x:, y:, width:, height: to return actual geometry values... -#### +//// TODO: +//// redefine x:, y:, width:, height: to return actual geometry values... +//// method title: title { self.title := title. 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 { method(#class) new @@ -667,7 +667,7 @@ extend X11 { 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. break. } @@ -681,7 +681,7 @@ extend X11 'CLOSING X11 EVENT LOOP' dump. 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_proc := nil. @@ -694,7 +694,7 @@ extend X11 { 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 := 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: '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.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.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. comp1 := Fx new. diff --git a/moo/kernel/test-001.moo b/moo/kernel/test-001.moo index e8746fb..68865dd 100644 --- a/moo/kernel/test-001.moo +++ b/moo/kernel/test-001.moo @@ -1,6 +1,6 @@ -## -## TEST CASES for namespacing -## +// +// TEST CASES for namespacing +// #include 'Moo.moo'. @@ -56,7 +56,7 @@ class MyObject.System.Horse (Donkey) method(#class) myns2 { [^selfns] value } 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) horse1 { ^Horse } @@ -98,13 +98,13 @@ class MyObject.System.Stallion (selfns.Donkey) method(#class) party { ^Party } - 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) system1 { ^System } // Single word. can be looked up in the current workspace. + method(#class) system2 { ^System.System } // Dotted. The search begins at the top. } extend MyObject { -## TODO: support import in extend?? +// TODO: support import in extend?? method(#class) makeBlock(a,b) { @@ -116,7 +116,7 @@ extend MyObject |a b | a := self makeBlock (12, 22). 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 @@ -162,133 +162,133 @@ extend MyObject | tc limit | tc := %( - ## 0 - 4 + // 0 - 4 [MyObject.Donkey v == 901982], [selfns.MyObject.Donkey v == 901982], [MyObject.System.Donkey v == 89123], [MyObject.System.Horse v == 89123], [selfns.MyObject.System.Donkey v == 89123], - ## 5 - 9 + // 5 - 9 [MyObject.System.Horse donkey1 == MyObject.System.Donkey], [MyObject.System.Horse donkey2 == MyObject.System.Donkey], [MyObject.System.Horse donkey2 v == 89123], [MyObject.System.Horse donkey3 v == 901982], [MyObject.System.Horse horse1 == MyObject.System.Horse], - ## 10 - 14 + // 10 - 14 [MyObject.System.Horse horse2 == MyObject.System.Horse], [MyObject.System.Horse superclass == MyObject.System.Donkey], [MyObject.System.Donkey superclass == MyObject], [selfns == System nsdic], [MyObject.System.Horse myns1 == MyObject.System], - ## 15 - 19 + // 15 - 19 [MyObject.System.Horse myns2 == MyObject.System], [MyObject.System == self.System], [MyObject.System.Donkey == self.System.Donkey], [MyObject.System.Stallion superclass == self.System.Donkey], [MyObject.Donkey.Party party1 == 5555], - ## 20 - 24 + // 20 - 24 [MyObject.Donkey.Party party2 == MyObject.Donkey.Party], [MyObject.Donkey.Party party3 == 5555], [MyObject.Donkey.Party party4 == MyObject.Donkey.Party.Party], [MyObject.Donkey.Party cat1 == MyObject], [MyObject.Code.FASTER2X == 40], - ## 25 - 29 + // 25 - 29 [MyObject.Code.FASTER2X == MyObject.Code.FASTER], [((MyObject.Code.FASTER3X at: 3) at: 1) == MyObject.Donkey], [MyObject.System.Stallion new x == MyObject.Code.FASTER3X], [MyObject.System.Stallion party == MyObject.Donkey.Party], [MyObject.System.Stallion system1 == MyObject.System.System], - ## 30 - 34 + // 30 - 34 [MyObject.System.Stallion system2 == System.System], [MyObject.System.System.System.System f == XX.FFFF], [MyObject.System.System a == XX.AAAA], [MyObject.System.System.System.System a == nil] , [MyObject.System.System.System.System new kk == #KK], - ## 35 - 39 + // 35 - 39 [MyObject.System.System.System KING == #KING], [self testMakeBlock == 49036], [ ((-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' ], - ## 40 - 44 + // 40 - 44 [ "%#x" strfmt((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) = '16r20000000000000000000000000000000000000000000000000000000000000000000000000001' ], [ (7 div: -3) = -2 ], [ (7 rem: -3) = 1 ], [ (7 mdiv: -3) = -3 ], [ (7 mod: -3) = -2 ], - ## 45-49 + // 45-49 [ ([ (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 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' ], [ (270000000000000000000000000000000000000000000000000000000000000000000 div: 50000000000000000000000000000000000000000000000000000000000000000000) = 5 ], - ## 50-54 + // 50-54 [ (270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ], [ (270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 50000000000000000000000000000000000000000000000000000000000000000000) = 5], [ (270000000000000000000000000000000000000000000000000000000000000000000 mod: 50000000000000000000000000000000000000000000000000000000000000000000) = 20000000000000000000000000000000000000000000000000000000000000000000 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], - ## 55-59 + // 55-59 [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) = 0 ], [ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd div: 16r3b9aca00) = 4184734490355220618401938634485367707982 ], [ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd rem: 16r3b9aca00) = 394876893 ], [ (16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) = 16r1111111111111111111111111111111111111111 ], - ## 60-64 + // 60-64 [(100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0], [(100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = 100213123891273912837891273189237], [(-100213123891273912837891273189237 div: 1238971238971894573289472398477891263781263781263) = 0], [(-100213123891273912837891273189237 rem: 1238971238971894573289472398477891263781263781263) = -100213123891273912837891273189237], [(-100213123891273912837891273189237 mdiv: 1238971238971894573289472398477891263781263781263) = -1], - ## 65-69 + // 65-69 [(-100213123891273912837891273189237 mod: 1238971238971894573289472398477891263781263781263) = 1238971238971894473076348507203978425889990592026], [(-123897123897189421321312312321312312132 div: -123897123897189421321312312321312312132) = 1], [(-123897123897189421321312312321312312132 rem: -123897123897189421321312312321312312132) = 0], [(-123897123897189421321312312321312312132 mdiv: -123897123897189421321312312321312312132) = 1], [(-123897123897189421321312312321312312132 mod: -123897123897189421321312312321312312132) = 0], - ## 70-74 + // 70-74 [ (-0.1233 * 999999.123) = -123299.8918 ], [ (-0.1233 * 999999.123) asString = '-123299.8918' ], [ (-0.1233 - -0.123) = -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 mlt: 20.345) = 205.89 ], [ (-123897128378912738912738917.112323131233 div: 123.1) = -1006475453931053931053931.089458352000 ], [ (-1006475453931053931053931.089458352000 * 123.1) = -123897128378912738912738917.112323131200 ], [ 10 scale = 0 ], - ## 80-84 + // 80-84 [ 10.0 scale = 1 ], [ 10.00 scale = 2 ], [ (10 scale: 1) = 10.0 ], [ (10 scale: 1) scale = (10.1 scale) ], [ (10 scale: 2) scale = (10.11 scale) ], - ## 85-89 + // 85-89 [ ((-10.19 scale: 3) scale) = (10.199 scale) ], [ ((-10.19 scale: 0) scale) = (10 scale) ], [ (-9p10 scale) = (-10.000000000 scale) ], [ (-9p10.123 scale) = (-10.123000000 scale) ], [ (+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' ], @@ -296,103 +296,103 @@ extend MyObject [ (811306333091350399588761 mdiv: 16) = 50706645818209399974297 ], - ## 95-99 + // 95-99 [ (811306333091350399588761 rem: 16) = 9 ], [ (811306333091350399588761 mod: 16) = 9 ], [ (811306333091350399588761 div: 128) = 6338330727276174996787 ], [ (811306333091350399588761 mdiv: 128) = 6338330727276174996787 ], [ (811306333091350399588761 rem: 128) = 25 ], - ## 100-104 + // 100-104 [ (811306333091350399588761 mod: 128) = 25 ], [ (-811306333091350399588761 div: -16) = 50706645818209399974297 ], [ (-811306333091350399588761 mdiv: -16) = 50706645818209399974297 ], [ (-811306333091350399588761 rem: -16) = -9 ], [ (-811306333091350399588761 mod: -16) = -9 ], - ## 105-109 + // 105-109 [ (-811306333091350399588761 div: -128) = 6338330727276174996787 ], [ (-811306333091350399588761 mdiv: -128) = 6338330727276174996787 ], [ (-811306333091350399588761 rem: -128) = -25 ], [ (-811306333091350399588761 mod: -128) = -25 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -1024) = 7922913409095218745983995988652160870400128212219627901 ], - ## 110-114 + // 110-114 [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -1024) = 7922913409095218745983995988652160870400128212219627901 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: -1024) = -607 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: -1024) = -607 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -65535) = 123797411015693964994088836383303772507663558240831600 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65535) = 123797411015693964994088836383303772507663558240831600 ], - ## 115-119 + // 115-119 [ (-8113063330913503995887611892379812731289731289312898971231 rem: -65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: -65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: -65536) = 123795522017112792905999937322690013600002003315931685 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: -65536) = 123795522017112792905999937322690013600002003315931685 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: -65536) = -63071 ], - ## 120-124 + // 120-124 [ (-8113063330913503995887611892379812731289731289312898971231 mod: -65536) = -63071 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 65535) = -123797411015693964994088836383303772507663558240831600 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 65535) = -123797411015693964994088836383303772507663558240831601 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: 65535) = -65231 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: 65535) = 304 ], - ## 125-129 + // 125-129 [ (65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = -1 ], [ (65535 rem: -8113063330913503995887611892379812731289731289312898971231) = 65535 ], [ (65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -8113063330913503995887611892379812731289731289312898905696 ], [ (-65535 div: -8113063330913503995887611892379812731289731289312898971231) = 0 ], - ## 130-134 + // 130-134 [ (-65535 mdiv: -8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (-65535 rem: -8113063330913503995887611892379812731289731289312898971231) = -65535], [ (-65535 mod: -8113063330913503995887611892379812731289731289312898971231) = -65535 ], [ (-65535 div: 8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (-65535 mdiv: 8113063330913503995887611892379812731289731289312898971231) = -1 ], - ## 135-139 + // 135-139 [ (-65535 rem: 8113063330913503995887611892379812731289731289312898971231) = -65535 ], [ (-65535 mod: 8113063330913503995887611892379812731289731289312898971231) = 8113063330913503995887611892379812731289731289312898905696 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = 236121219667649827777862429280643489074710852271 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 34359738368) = -236121219667649827777862429280643489074710852271 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 34359738368) = -236121219667649827777862429280643489074710852272 ], - ## 140-144 + // 140-144 [ (-8113063330913503995887611892379812731289731289312898971231 rem: 34359738368) = -31040337503 ], [ (-8113063330913503995887611892379812731289731289312898971231 mod: 34359738368) = 3319400865 ], [ (-8113063330913503995887611892379812731289731289312898971231 div: 18446744073709551615) = -439810044444445199874532569660475732947 ], [ (-8113063330913503995887611892379812731289731289312898971231 mdiv: 18446744073709551615) = -439810044444445199874532569660475732948 ], [ (-8113063330913503995887611892379812731289731289312898971231 rem: 18446744073709551615) = -16637658201046411826 ], - ## 145-149 + // 145-149 [ (-8113063330913503995887611892379812731289731289312898971231 mod: 18446744073709551615) = 1809085872663139789 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971231) = 1 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971231) = 0 ], [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971232) = 0 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971232) = 8113063330913503995887611892379812731289731289312898971231 ], - ## 150-154 + // 150-154 [ (8113063330913503995887611892379812731289731289312898971231 div: 8113063330913503995887611892379812731289731289312898971230) = 1 ], [ (8113063330913503995887611892379812731289731289312898971231 rem: 8113063330913503995887611892379812731289731289312898971230) = 1 ], [ self testBigintDiv: 100919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 129323482374892374238974238974238947328972389128387312892713891728391278 count: 2000 ], [ self testBigintDiv: 234897230919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 12932348237489237423897423897423894732897238912838731289271389172839127 count: 2000 ], [ self testBigintDiv: 16r1234567812345678123456781234567812345678123456781234567812345678123456781234567812345678 divisor: 16r12345678123456781234567812345678123456781234567812345678 count: 2000 ], - ## 155-159 + // 155-159 [ self testBigintDiv: 16r000089ab0000456700000123 divisor: 1 count: 2000 ], [ self testBigintDiv: 16r000000030000000000008000 divisor: 16r000000010000000000002000 count: 2000 ], [ self testBigintDiv: 16rfffffffe0000000080000000 divisor: 16r0000ffff0000000080000000 count: 12345 ], [ self testBigintDiv: 16rfffffffffffffffe divisor: 16rffffffff count: 2000 ], [ self testBigintDiv: 68651967526299315528548877601614136727014 divisor: 1729382256910270380 count: 1 ], - ## 160-164 + // 160-164 [ self testBigintDiv: 43943618413704592900396132847030223073729048496 divisor: 1135814937804493543741046072006331 count: 1 ], [ self testBigintDiv: 76733673740671314025981152630586699414203 divisor: 12682136550675277273 count: 1 ], [ self testBigintDiv: 265804060782114895959697138188904455994 divisor: 713053462628379038341886861235 count: 1], - ## ========================= + // ========================= [ | k | k := String new. @@ -404,7 +404,7 @@ extend MyObject [ | k | 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 } ], [ diff --git a/moo/kernel/test-002.moo b/moo/kernel/test-002.moo index 00f80a3..e3dea80 100644 --- a/moo/kernel/test-002.moo +++ b/moo/kernel/test-002.moo @@ -1,9 +1,9 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# class MyObject(Object) { @@ -40,7 +40,7 @@ class MyObject(Object) 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 ] } @@ -126,7 +126,7 @@ class MyObject(Object) 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 := %( - ## 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: %(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: 0) == 0 ], [ 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 proc1 == 100 ], [ System sleepForSecs: 2. self proc1 == 200 ], [ self test_semaphore_heap == true ], [ self test_mutex = #(2000 6000) ], - ## 10-14 - ####[ 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 + // 10-14 + ////[ 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 ). limit := tc size. @@ -190,7 +190,7 @@ s1 := TcpSocket new. s1 onEvent: #connected do: [ s1 waitToRead. - ##s1 beginWrite: C'GET / HTTP/1.0\n\r'. + //s1 beginWrite: C'GET / HTTP/1.0\n\r'. ] s1 onEvent: #written do: [ ]. @@ -202,7 +202,7 @@ s1 onEvent: #readyToRead do: [ s1 beginConnect: '1.2.3.4:45' onConnected: [ :result | xxxx]. -#### +//// s1 beginConnect: destination onConnected: s1 endConnect --> return what? s1 endReceive diff --git a/moo/kernel/test-003.moo b/moo/kernel/test-003.moo index 8c51d6c..82a7528 100644 --- a/moo/kernel/test-003.moo +++ b/moo/kernel/test-003.moo @@ -1,12 +1,12 @@ -## -## TEST CASES for basic methods -## +// +// TEST CASES for basic methods +// #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# class MyObject(Object) { @@ -23,26 +23,26 @@ class MyObject(Object) } method(#class) test1 { - #### TODO: add this to the test case list. + //// TODO: add this to the test case list. | 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: 16. ]. - ##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.000000000000000000000000000000 - (815.00000000000000000000000000 - (1500.0000000000000000 div: z) div: y) ]. + //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) ]. + //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 | 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 add: 4.0; add: (425.00 div: 100.00). 3 to: 100 do: [ :i | -##(results at: i - 2) dump. -##(results at: i - 3) dump. -##'----------' dump. +//(results at: i - 2) dump. +//(results at: i - 3) dump. +//'----------' dump. results add: (rec value: (results at: i - 2) value: (results at: i - 3)). ]. @@ -57,28 +57,28 @@ class MyObject(Object) | tc limit | tc := %( - ## 0 - 4 + // 0 - 4 [(Object isKindOf: Class) == true], [(Object isKindOf: Apex) == true], [(Class isKindOf: Class) == true], [(Class isKindOf: Apex) == true], [(Class isKindOf: Object) == false], - ## 5-9 + // 5-9 [(Apex isKindOf: Class) == true], [(Apex isKindOf: Apex) == true], [(SmallInteger isKindOf: Integer) == false], [(SmallInteger isKindOf: SmallInteger) == false], [(Object isKindOf: SmallInteger) == false], - ## 10-14 + // 10-14 [(10 isKindOf: Integer) == true], [(10 isKindOf: 20) == false], [([] isKindOf: BlockContext) == true], [([] isKindOf: MethodContext) == false], [([] isKindOf: Context) == true], - ## 15-20 + // 15-20 [('string' isKindOf: String) == true], [(#symbol isKindOf: String) == true], [('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"). ]. - ## TODO: + // TODO: String format('%s', " 나 는\\\"") dump. #"a b\nc" dump. } diff --git a/moo/kernel/test-004.moo b/moo/kernel/test-004.moo index 4d1be0f..f6bda45 100644 --- a/moo/kernel/test-004.moo +++ b/moo/kernel/test-004.moo @@ -1,12 +1,12 @@ -## -## TEST CASES for basic methods -## +// +// TEST CASES for basic methods +// #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# class MyObject(Object) { @@ -39,7 +39,7 @@ class MyObject(Object) sg addSemaphore: s3. 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. [ sg wait. ] fork. @@ -57,7 +57,7 @@ sg removeSemaphore: s1. | tc limit | tc := %( - ## 0 - 4 + // 0 - 4 [self test_terminate == 180], [self test_sg == nil] ). diff --git a/moo/kernel/test-005.moo b/moo/kernel/test-005.moo index f16c773..550dabd 100644 --- a/moo/kernel/test-005.moo +++ b/moo/kernel/test-005.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { @@ -59,7 +59,7 @@ class MyObject(TestObject) ^a + 99. - ##a := Moo.MyCOM.HashTable new. + //a := Moo.MyCOM.HashTable new. } method xxx: aBlock @@ -73,46 +73,46 @@ class MyObject(TestObject) { | a b c sum | -## ##(10 add: 20) dump. -## (10 + 20) dump. -## -## a := 10 + 20 + 30. -## b := [:x :y | | t z | x := 20. b := 9. x := 10 + 20 ]. -## -## (b value: 10 value: 20) dump. -## -## thisContext basicSize dump. -## -## (thisContext basicAt: (8 + 5)) dump. -## -## ^self. +// //(10 add: 20) dump. +// (10 + 20) dump. +// +// a := 10 + 20 + 30. +// b := [:x :y | | t z | x := 20. b := 9. x := 10 + 20 ]. +// +// (b value: 10 value: 20) dump. +// +// thisContext basicSize dump. +// +// (thisContext basicAt: (8 + 5)) dump. +// +// ^self. a := self new. - ##a yourself. - ##b := a getTrue; getFalse. - ##b := a getTrue; getFalse; getTrue: 20 + 10. - ##b := a getTrue; getFalse; getTrue: 20 + 10; getTrue: 90 + 20. - ##b := 3 + 5 getTrue: 20; getTrue: 8 + 1; getTrue: 20; yourself. + //a yourself. + //b := a getTrue; getFalse. + //b := a getTrue; getFalse; getTrue: 20 + 10. + //b := a getTrue; getFalse; getTrue: 20 + 10; getTrue: 90 + 20. + //b := 3 + 5 getTrue: 20; getTrue: 8 + 1; getTrue: 20; yourself. 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. - ##^self. + //^self. -## ############################################################ -## A := 99. +// //////////////////////////////////////////////////////////// +// A := 99. [:x :y | R := y. ] value: 10 value: 6. R := R + 1. R dump. sum := [ :n | (n < 2) ifTrue: [1] ifFalse: [ n + (sum value: (n - 1))] ]. - ##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 := [ :n | sum value: 5 ]. -##sum value: 5. +//sum := [ :n | sum value: 5 ]. +//sum value: 5. #[ 1 2 3] dump. #[ 4 5 6] dump. @@ -135,8 +135,8 @@ class MyObject(TestObject) C'\n' dump. #abc:def: dump. - ##a := (11 < 10) ifTrue: [5] ifFalse: [20]. - ##a dump. + //a := (11 < 10) ifTrue: [5] ifFalse: [20]. + //a dump. } method(#class) main55 @@ -144,8 +144,8 @@ class MyObject(TestObject) |a b c| self main2. -## b := 0. -## [ b < 5 ] whileTrue: [ b dump. b := b + 1 ]. +// b := 0. +// [ b < 5 ] whileTrue: [ b dump. b := b + 1 ]. } method(#class) getTen @@ -153,10 +153,10 @@ class MyObject(TestObject) ^10 } -## --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- -## this sample demonstrates what happens when a block context returns to the origin's caller -## after the caller has already returned. +// this sample demonstrates what happens when a block context returns to the origin's caller +// after the caller has already returned. method(#class) xxxx { @@ -180,7 +180,7 @@ class MyObject(TestObject) method(#class) main66 { 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. } @@ -190,10 +190,10 @@ class MyObject(TestObject) t1 := 1. 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. } -## ---------------------------------------------------------------------- +// ---------------------------------------------------------------------- method(#class) main22 { @@ -215,8 +215,8 @@ class MyObject(TestObject) (#[3 2 1] at: 3) dump. - ## thisContext value. ## the message value must be unresolvable as thisContext is a method context - ## [thisContext value] value. + // thisContext value. // the message value must be unresolvable as thisContext is a method context + // [thisContext value] value. '-------------------------' dump. b := 0. [ b := b + 1. b dump. thisContext value] value. @@ -254,24 +254,24 @@ class MyObject(TestObject) | ffi | 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: #puts signature: 's)i' arguments: #('hello world'). + //ffi call: #puts signature: 's)i' arguments: #('hello world'). ffi close. } method(#class) main { - ## --------------------------------------------------------------- - ## getABlock has returned. - ## aBlock's home context is getABlock. getABlock has returned - ## when 'aBlock value' is executed. so when aBlock is really - ## executed, ^self is a double return attempt. should this be made - ## illegal?? + // --------------------------------------------------------------- + // getABlock has returned. + // aBlock's home context is getABlock. getABlock has returned + // when 'aBlock value' is executed. so when aBlock is really + // executed, ^self is a double return attempt. should this be made + // illegal?? |aBlock| aBlock := self getABlock. aBlock value. - ## --------------------------------------------------------------- + // --------------------------------------------------------------- self test_ffi. @@ -279,7 +279,7 @@ class MyObject(TestObject) PROCESS TESTING | p | '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). '999999999999999999' dump. p resume. @@ -295,12 +295,12 @@ PROCESS TESTING (-2305843009213693952 - 1) dump. (1 + 2) 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) 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) dump. - ##(-16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF * 1) dump. - ##((-2305843009213693952 * -1) - 1 + 2) dump. + //(-16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF * 1) dump. + //((-2305843009213693952 * -1) - 1 + 2) dump. ((-2305843009213693952 * -2305843009213693952 * 2305843009213693952 * 2305843009213693952 * 2305843009213693952) - 1 + 2) dump. @@ -316,46 +316,46 @@ PROCESS TESTING (7 div: -3) dump. (7 mdiv: -3) dump. -##(777777777777777777777777777777777777777777777777777777777777777777777 rem: -8127348917239812731289371289731298) dump. -##(777777777777777777777777777777777777777777777777777777777777777777777 quo: -8127348917239812731289371289731298) dump. +//(777777777777777777777777777777777777777777777777777777777777777777777 rem: -8127348917239812731289371289731298) dump. +//(777777777777777777777777777777777777777777777777777777777777777777777 div: -8127348917239812731289371289731298) dump. -##(270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(270000000000000000000000000000000000000000000000000000000000000000000 quo: 50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(270000000000000000000000000000000000000000000000000000000000000000000 \\ 50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(270000000000000000000000000000000000000000000000000000000000000000000 // 50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(270000000000000000000000000000000000000000000000000000000000000000000 rem: 50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(270000000000000000000000000000000000000000000000000000000000000000000 div: 50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(270000000000000000000000000000000000000000000000000000000000000000000 mod: 50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(0 quo: -50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(0 \\ -50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(0 // -50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(0 rem: -50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(0 div: -50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(0 mdiv: -50000000000000000000000000000000000000000000000000000000000000000000) dump. +//(0 mod: -50000000000000000000000000000000000000000000000000000000000000000000) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 rem: -1) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 quo: -1) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 \\ -1) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 // -1) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 rem: -1) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 div: -1) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 mdiv: -1) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 mod: -1) dump. -## (-27029038 // 2) asString dump. -## (-270290380000000000000000000000000000000000000000000000000000000000000000000000000000000000000 // 2) asString dump. -##(-16rAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFF) asString dump. -## (16r2dd01fc06c265c8163ac729b49d890939826ce3dd quo: 16r3b9aca00) dump. +// (-27029038 mod: 2) asString dump. +// (-270290380000000000000000000000000000000000000000000000000000000000000000000000000000000000000 mod: 2) asString dump. +//(-16rAAAAAAAABBBBBBBBCCCCCCCCDDDDDDDDEEEEEEEEFFFFFFFF) asString dump. +// (16r2dd01fc06c265c8163ac729b49d890939826ce3dd div: 16r3b9aca00) dump. -##(0 rem: -50) dump. -##(0 quo: -50) dump. -##(0 \\ -50) dump. -##(0 // -50) dump. +//(0 rem: -50) dump. +//(0 div: -50) dump. +//(0 mdiv: -50) dump. +//(0 mod: -50) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 rem: 5) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 quo: 5) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 \\ 5) dump. -##(-270000000000000000000000000000000000000000000000000000000000000000000 // 5) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 rem: 5) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 div: 5) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 mdiv: 5) dump. +//(-270000000000000000000000000000000000000000000000000000000000000000000 mod: 5) dump. -##(-270 rem: 5) dump. -##(-270 quo: 5) dump. -##(-270 \\ 5) dump. -##(-270 // 5) dump. +//(-270 rem: 5) dump. +//(-270 div: 5) dump. +//(-270 mdiv: 5) dump. +//(-270 mod: 5) dump. -##(16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) dump. +//(16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) dump. (2r1111111111111111111111111111111111111111111111111111111111111111 printStringRadix:2) dump. @@ -402,10 +402,10 @@ PROCESS TESTING (16rFFFFFFFFFF1234567890AAAAAAAAAAAAAAAAAAAAAAAAA22222222222222222F printStringRadix: 32) dump. (32r3VVVVVVVS938LJOI2LALALALALALALALALAL8H248H248H248HF printStringRadix: 16) dump. -## ((-2r110101010101010101010101010101111111111111111111111111111111111111111111111111111111100000000001111111 bitShift: 16r1FFFFFFFFFFFFFFFF) printStringRadix: 2) dump. +// ((-2r110101010101010101010101010101111111111111111111111111111111111111111111111111111111100000000001111111 bitShift: 16r1FFFFFFFFFFFFFFFF) printStringRadix: 2) dump. -##((-2r11111111110000000000111110000 bitShift: -31) printStringRadix: 2) dump. -##((-536870911 bitShift: -536870912) printStringRadix: 2) dump. +//((-2r11111111110000000000111110000 bitShift: -31) printStringRadix: 2) dump. +//((-536870911 bitShift: -536870912) printStringRadix: 2) dump. ((-2r1111 bitShift: -3) printStringRadix: 2) dump. ((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -1) printStringRadix: 2) dump. ((-2r11111111111111111111111111111111111111111111111111111111111111111111110001 bitShift: -2) printStringRadix: 2) dump. @@ -430,8 +430,8 @@ PROCESS TESTING (2r1000000000000000000000000000100000000000000000000000000000000000000000000000 bitAt: 129) 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. + //self a: 1 b: 2 c: 3 d: 4 e: 5 f: 6 g: 7. + //self a: 1 b: 2 c: 3. [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. '====================' 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.] on: Exception do: [:ex | 'Exception' 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.] on: Exception do: [:ex | 'Exception' dump]. /* FFI isNil dump. diff --git a/moo/kernel/test-006.moo b/moo/kernel/test-006.moo index fd1e67c..f33280c 100644 --- a/moo/kernel/test-006.moo +++ b/moo/kernel/test-006.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { @@ -97,8 +97,8 @@ class MyObject(TestObject) 'START OF MAIN' 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 getBlock value dump. + // ^(self a: (self new a) b: ([:a :b | a + b] value: 10 value: 20) c: (self new c)) dump. + //self getBlock value dump. 'END OF MAIN' dump. } diff --git a/moo/kernel/test-007.moo b/moo/kernel/test-007.moo index 89bf8ae..32f9e61 100644 --- a/moo/kernel/test-007.moo +++ b/moo/kernel/test-007.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { @@ -65,7 +65,7 @@ class MyObject(TestObject) { | p p2 | '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). p2 := [ :a :b :c :d | a dump. b dump. a dump. b dump. (c + d) dump. ^10000 ] newProcessWith: #( #AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA @@ -80,7 +80,7 @@ class MyObject(TestObject) 'MIDDLE OF MAIN' dump. Processor activeProcess terminate. - ##p terminate. + //p terminate. '999999999999999999' dump. '999999999999999999' dump. '999999999999999999' dump. @@ -88,7 +88,7 @@ class MyObject(TestObject) '999999999999999999' dump. '999999999999999999' dump. '999999999999999999' dump. -## p resume. +// p resume. '999999999999999999' dump. '999999999999999999' dump. '999999999999999999' dump. diff --git a/moo/kernel/test-008.moo b/moo/kernel/test-008.moo index ab3e9f8..5d175a9 100644 --- a/moo/kernel/test-008.moo +++ b/moo/kernel/test-008.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { diff --git a/moo/kernel/test-009.moo b/moo/kernel/test-009.moo index 03d1e73..12c617d 100644 --- a/moo/kernel/test-009.moo +++ b/moo/kernel/test-009.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { diff --git a/moo/kernel/test-010.moo b/moo/kernel/test-010.moo index 3c88b08..70a9136 100644 --- a/moo/kernel/test-010.moo +++ b/moo/kernel/test-010.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { @@ -77,14 +77,14 @@ class MyObject(TestObject) s2 := Semaphore forMutualExclusion. t1 := [ - ##1000 timesRepeat: ['BLOCK #1' dump]. + //1000 timesRepeat: ['BLOCK #1' dump]. s2 critical: [ 10000 timesRepeat: ['BLOCK #1' dump ]. Exception signal: 'Raised Exception at process t1'. ] ] newProcess. t2 := [ - ##1000 timesRepeat: ['BLOCK #2' dump]. + //1000 timesRepeat: ['BLOCK #2' dump]. s2 critical: [ 10000 timesRepeat: ['BLOCK #2' dump. ] ]. @@ -120,13 +120,13 @@ class MyObject(TestObject) 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. ]. ] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 3' dump ]. ] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. - ## Exception signal: 'qqq'. + // Exception signal: 'qqq'. ]. ^v1 } @@ -134,20 +134,20 @@ class MyObject(TestObject) { | v1 | 'START OF MAIN' dump. - ##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump]. - ##['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump]. + //[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump]. + //['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump]. - ##v1 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ]. - ##v1 dump. + //v1 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ]. + //v1 dump. - ##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ]. + //[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ]. - ##[ - ## [ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ]. - ##] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ]. + //[ + // [ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ]. + //] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ]. - ##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']. + //[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']. /* v1 := [ @@ -155,13 +155,13 @@ class MyObject(TestObject) 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 ]. ] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 3' dump ]. ] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. - ## Exception signal: 'qqq'. + // Exception signal: 'qqq'. ]. */ @@ -205,7 +205,7 @@ class MyObject(TestObject) 'WAITING ON S3...' dump. - ##System unsignal: s3. + //System unsignal: s3. s3 wait. 10 timesRepeat: ['WAITED t1 and t2' dump]. diff --git a/moo/kernel/test-011.moo b/moo/kernel/test-011.moo index 8005137..0f10019 100644 --- a/moo/kernel/test-011.moo +++ b/moo/kernel/test-011.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { @@ -69,13 +69,13 @@ class MyObject(TestObject) '>>> TEST3 METHOD >>> ' dump. j dump. (j < 25) ifTrue: [ | t | - 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 := self raise_exception. ## when resumed, t should get 'self' + 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 := 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 signal. - ##g_ex pass. + //g_ex retry. # You should not do these as the following 3 lines make things very complicated. + //g_ex signal. + //g_ex pass. 'RESUMED???' dump. t dump. @@ -98,8 +98,8 @@ class MyObject(TestObject) '>>> TEST4_1 METHOD >>> ' dump. j dump. (j < 25) ifTrue: [ | t | - ##t := Exception signal: 'bad exceptinon'. ## when resume, t should get Exception. - t := self raise_exception. ## when resumed, t should get 'self' + //t := Exception signal: 'bad exceptinon'. // when resume, t should get Exception. + t := self raise_exception. // when resumed, t should get 'self' 'RESUMED???' dump. t dump. j dump. @@ -130,8 +130,8 @@ class MyObject(TestObject) '>>> TEST5 BLOCK >>> ' dump. j dump. (j < 25) ifTrue: [ | t | - ##t := Exception signal: 'bad exceptinon'. ## when resume, t should get Exception. - t := self raise_exception. ## when resumed, t should get 'self' + //t := Exception signal: 'bad exceptinon'. // when resume, t should get Exception. + t := self raise_exception. // when resumed, t should get 'self' ]. 'OOOOOOOOOOOOOOOOOOOOOOO' dump. @@ -144,15 +144,15 @@ class MyObject(TestObject) method(#class) test11 { - ## exception is raised in a new process. it can't be captured - ## by an exception handler of a calling process. - ## exception handling must not cross the process boundary. + // exception is raised in a new process. it can't be captured + // by an exception handler of a calling process. + // exception handling must not cross the process boundary. 'BEGINNING OF test11' dump. [ |p | p := [ 'TEST11 IN NEW PROCESS' dump. Exception signal: 'Exception raised in a new process of test11'. ] newProcess. '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 ]. 'END OF test11' dump. } @@ -182,20 +182,20 @@ class MyObject(TestObject) [ self main2 ] on: Exception do: [ :ex | 'EXCEPTION CAUGHT IN MAIN....' dump. ex messageText dump. - ##ex pass. + //ex pass. 'Returning back to where the exception has signalled in main2...' dump. - ##ex resume. + //ex resume. ex resume: 'RESUMED WITH THIS STRING'. ]. - '##############################' dump. - ## self test3. - ## self test4. + '//////////////////////////////' dump. + // self test3. + // self test4. - ## self test5. + // self test5. self test11. - ## self test12. - ## 100 timesRepeat: ['>>>>> END OF MAIN' dump]. + // self test12. + // 100 timesRepeat: ['>>>>> END OF MAIN' dump]. /* @@ -215,12 +215,12 @@ class MyObject(TestObject) '@@@@@@@@@@@@@@@@@@@@@@@@@@@@' dump. - ## the following line(return:to:) must cause primitive failure... - ##[ Processor return: 10 to: 20. ] on: Exception do: [:ex | ex messageText dump]. + // 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: PrimitiveFailureException do: [:ex | 'PRIMITIVE FAILURE CAUGHT HERE HERE HERE' dump] - ## on: Exception do: [:ex | ex messageText dump]. + //[ Processor return: 10 to: 20. ] + // on: PrimitiveFailureException do: [:ex | 'PRIMITIVE FAILURE CAUGHT HERE HERE HERE' dump] + // on: Exception do: [:ex | ex messageText dump]. 'SLEEPING FOR 10 seconds ....' dump. System sleepForSecs: 10. diff --git a/moo/kernel/test-012.moo b/moo/kernel/test-012.moo index 4256bbb..a0625c1 100644 --- a/moo/kernel/test-012.moo +++ b/moo/kernel/test-012.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { @@ -65,13 +65,13 @@ class MyObject(TestObject) 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. ]. ] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 3' dump ]. ] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. - ## Exception signal: 'qqq'. + // Exception signal: 'qqq'. ]. ^v1 } @@ -79,14 +79,14 @@ class MyObject(TestObject) { | v1 | 'START OF MAIN' dump. - ##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump]. - ##['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump]. + //[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump]. + //['ENSURE TEST' dump] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump]. - ##v1 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ]. - ##v1 dump. + //v1 := [ ['kkk' dump.] ensure: ['XXXXXXXXX ENSURE XXXXXXXXXXXXXx' dump. 30] ] on: Exception do: [:ex | 'EXCEPTION OUTSIDE ENSURE...' dump. ]. + //v1 dump. - ##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ]. + //[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ]. /*[ [ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ]. @@ -107,7 +107,7 @@ class MyObject(TestObject) Exception signal: 'qqq'. ]. - ##[ ^20 ] ensure: [('ensure 1 ', (k asString)) dump ]. + //[ ^20 ] ensure: [('ensure 1 ', (k asString)) dump ]. 'KKKKKKKKKKKKKKKKKKKK' dump. ] ensure: ['ensure 2' dump ]. @@ -118,9 +118,9 @@ class MyObject(TestObject) ('>>>> EXCETION - ' & ex messageText) dump. ex pass. - ##Exception signal: 'XXXXXXXXXXXXx'. - ## ex return: 10. - ## Exception signal: 'qqq'. + //Exception signal: 'XXXXXXXXXXXXx'. + // ex return: 10. + // Exception signal: 'qqq'. ]. 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump. ] @@ -132,7 +132,7 @@ class MyObject(TestObject) ]. -## v1 := self aaa_123. +// v1 := self aaa_123. '--------------------------------' dump. v1 dump. '--------------------------------' dump. diff --git a/moo/kernel/test-013.moo b/moo/kernel/test-013.moo index 2b91984..2a3b9c2 100644 --- a/moo/kernel/test-013.moo +++ b/moo/kernel/test-013.moo @@ -1,13 +1,13 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# -## TODO: use #define to define a class or use #class to define a class. -## use #extend to extend a class -## using #class for both feels confusing. +// TODO: use #define to define a class or use #class to define a class. +// use #extend to extend a class +// using #class for both feels confusing. extend Apex { @@ -69,7 +69,7 @@ class MyObject(TestObject) do: [:ex | System logNl: ('Exception: ' & ex messageText). ex return: 10. - ##ex retry. + //ex retry. System logNl: '--- THIS MUST NOT BE PRINTED ---'. ]. @@ -80,7 +80,7 @@ class MyObject(TestObject) 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. ] ensure: [ System logNl: '<<>>' ]. @@ -92,9 +92,9 @@ class MyObject(TestObject) System sleepForSecs: 1. v1 terminate. - ##[ - ## [ Processor activeProcess terminate. ] ensure: [System logNl: '<<>>' ]. - ##] ensure: [ System logNl: '<<--------------------->>' ]. + //[ + // [ Processor activeProcess terminate. ] ensure: [System logNl: '<<>>' ]. + //] ensure: [ System logNl: '<<--------------------->>' ]. System logNl: S'\0\0\0END OF MAIN\0AB\0\0\0C\0\0\0'. } diff --git a/moo/kernel/test-014.moo b/moo/kernel/test-014.moo index 2c6923f..33847f8 100644 --- a/moo/kernel/test-014.moo +++ b/moo/kernel/test-014.moo @@ -1,9 +1,9 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# extend Apex { @@ -86,7 +86,7 @@ class MyConsole(Console) class MyObject(TestObject) { - ##import(#pooldic) ABC, SRX.ABC. + //import(#pooldic) ABC, SRX.ABC. import ABC, SRX.ABC. 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'. - ##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 isError) ifTrue: [ System logNl: ('Error in opening a file....' & v1 asString). ] ifFalse: [ - ## v1 puts: 'hello'. + // v1 puts: 'hello'. v1 puts ('hello', 'world', 'good', C'\n', C'\t', 'under my umbrella 123.', C'\n'). v1 close. @@ -169,7 +169,7 @@ class MyObject(TestObject) 0 priorTo: 200 do: [:i | | k | k := 1 bitShift: i. - ## (k printStringRadix: 2) dump. + // (k printStringRadix: 2) dump. ((k bitAt: i) = 1) ifFalse: [ System logNl: 'Test 5 failed'. thisProcess terminate. @@ -220,7 +220,7 @@ class MyObject(TestObject) (thisContext vargAt: k) dump. ]. 'varg_test3 end .....' dump. - ## ^b * 100 + // ^b * 100 ^f } diff --git a/moo/kernel/test-bi.moo b/moo/kernel/test-bi.moo index e223b82..0a89a9a 100644 --- a/moo/kernel/test-bi.moo +++ b/moo/kernel/test-bi.moo @@ -1,9 +1,9 @@ #include 'Moo.moo'. -################################################################# -## MAIN -################################################################# +////////////////////////////////////////////////////////////////# +// MAIN +////////////////////////////////////////////////////////////////# class MyObject(Object) { @@ -42,7 +42,7 @@ class MyObject(Object) ffi := FFI new: 'libc.so.6'. 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). [ @@ -51,24 +51,24 @@ class MyObject(Object) while (true) { - ##x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20. - ##divd := (ffi call: #rand signature: ')i' arguments: nil). + //x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20. + //divd := (ffi call: #rand signature: ')i' arguments: nil). x := (ffi call: #random signature: ')l' arguments: nil) rem: 20. divd := (ffi call: #random signature: ')l' arguments: nil). 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). x := x - 1. }. - ##x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20. - ##divr := (ffi call: #rand signature: ')i' arguments: nil). + //x := (ffi call: #rand signature: ')i' arguments: nil) rem: 20. + //divr := (ffi call: #rand signature: ')i' arguments: nil). x := (ffi call: #random signature: ')l' arguments: nil) rem: 20. divr := (ffi call: #random signature: ')l' arguments: nil). 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). x := x - 1. }. @@ -77,7 +77,7 @@ class MyObject(Object) q := divd div: 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. }. - ####((q asString) & ' ' & (r asString)) dump + ////((q asString) & ' ' & (r asString)) dump }. ] ensure: [ ffi close. ]. ^true diff --git a/moo/lib/comp.c b/moo/lib/comp.c index e195411..aa991b0 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -1119,30 +1119,53 @@ static int skip_comment (moo_t* moo) /* handle block comment encoded in /x x/ where x is * */ lc = moo->c->lxc; GET_CHAR_TO (moo, c); - if (c != '*') goto not_comment; - - do + if (c == '/') { - GET_CHAR_TO (moo, c); - if (c == MOO_OOCI_EOF) goto unterminated; - - if (c == '*') + do { - check_rparen: GET_CHAR_TO (moo, c); - if (c == MOO_OOCI_EOF) goto unterminated; - - if (c == '*') goto check_rparen; /* got another * after * */ - if (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); + } + while (1); - return 1; /* multi-line comment enclosed in /x and x/ where x is * */ + return 1; /* single line comment led by // */ + } + else if (c == '*') + { + do + { + GET_CHAR_TO (moo, c); + if (c == MOO_OOCI_EOF) goto unterminated; + + if (c == '*') + { + check_rparen: + GET_CHAR_TO (moo, c); + if (c == MOO_OOCI_EOF) goto unterminated; + + if (c == '*') goto check_rparen; /* got another * after * */ + if (c == '/') + { + GET_CHAR (moo); /* keep the first meaningful character in lxc */ + break; + } + } + } + while (1); + + return 1; /* multi-line comment enclosed in /x and x/ where x is * */ + } + + goto not_comment; } else if (c == '#') { @@ -1153,7 +1176,7 @@ static int skip_comment (moo_t* moo) /* read a new character */ GET_CHAR_TO (moo, c); - if (c != '!' && c != '#') goto not_comment; + if (c != '!') goto not_comment; do { GET_CHAR_TO (moo, c); @@ -1170,7 +1193,7 @@ static int skip_comment (moo_t* moo) } while (1); - return 1; /* single line comment led by ## or #! */ + return 1; /* single line comment led by #! */ } else {