changed the block comment style the same as C
This commit is contained in:
parent
6b2cb6f9df
commit
102de55322
@ -23,7 +23,7 @@ class(#limited) Error(Apex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
pooldic Error.Code
|
pooldic Error.Code
|
||||||
{
|
{
|
||||||
ENOERR := #\E0.
|
ENOERR := #\E0.
|
||||||
@ -40,9 +40,9 @@ pooldic Error.Code
|
|||||||
|
|
||||||
ELIMIT := #\E9999.
|
ELIMIT := #\E9999.
|
||||||
## add more items...
|
## add more items...
|
||||||
} *)
|
} */
|
||||||
|
|
||||||
(*pooldic Error.Code2
|
/*pooldic Error.Code2
|
||||||
{
|
{
|
||||||
>> CAN I SUPPORT this kind of redefnition? as of now, it's not accepted because
|
>> CAN I SUPPORT this kind of redefnition? as of now, it's not accepted because
|
||||||
>> Error.Code2.EGENERIC is not a literal. Should i treate pooldic members as a constant
|
>> Error.Code2.EGENERIC is not a literal. Should i treate pooldic members as a constant
|
||||||
@ -50,7 +50,7 @@ pooldic Error.Code
|
|||||||
>> the definition here won't see the change... what is the best way to tackle this issue?
|
>> the definition here won't see the change... what is the best way to tackle this issue?
|
||||||
|
|
||||||
EGENERIC := Error.Code2.EGENERIC.
|
EGENERIC := Error.Code2.EGENERIC.
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
extend Apex
|
extend Apex
|
||||||
{
|
{
|
||||||
@ -73,7 +73,7 @@ extend Apex
|
|||||||
|
|
||||||
method(#class,#primitive) basicNew.
|
method(#class,#primitive) basicNew.
|
||||||
method(#class,#primitive) basicNew: size.
|
method(#class,#primitive) basicNew: size.
|
||||||
(* the following definition is almost equivalent to the simpler definition
|
/* the following definition is almost equivalent to the simpler definition
|
||||||
* method(#class,#primitive) basicNew: size.
|
* method(#class,#primitive) basicNew: size.
|
||||||
* found above.
|
* found above.
|
||||||
* in the following defintion, the primitiveFailed method is executed
|
* in the following defintion, the primitiveFailed method is executed
|
||||||
@ -84,7 +84,7 @@ extend Apex
|
|||||||
{
|
{
|
||||||
<primitive: #Apex__basicNew:>
|
<primitive: #Apex__basicNew:>
|
||||||
self primitiveFailed(thisContext method)
|
self primitiveFailed(thisContext method)
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
method(#class) new
|
method(#class) new
|
||||||
{
|
{
|
||||||
@ -104,7 +104,7 @@ extend Apex
|
|||||||
|
|
||||||
method initialize
|
method initialize
|
||||||
{
|
{
|
||||||
(* a subclass may override this method *)
|
/* a subclass may override this method */
|
||||||
^self.
|
^self.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,27 +126,27 @@ extend Apex
|
|||||||
method(#dual,#primitive) basicFillFrom: sindex with: value count: count.
|
method(#dual,#primitive) basicFillFrom: sindex with: value count: count.
|
||||||
method(#dual,#primitive) basicShiftFrom: sindex to: dindex count: count.
|
method(#dual,#primitive) basicShiftFrom: sindex to: dindex count: count.
|
||||||
|
|
||||||
(* ------------------------------------------------------------------
|
/* ------------------------------------------------------------------
|
||||||
* FINALIZATION SUPPORT
|
* FINALIZATION SUPPORT
|
||||||
* ------------------------------------------------------------------ *)
|
* ------------------------------------------------------------------ */
|
||||||
method(#dual,#primitive) addToBeFinalized.
|
method(#dual,#primitive) addToBeFinalized.
|
||||||
method(#dual,#primitive) removeToBeFinalized.
|
method(#dual,#primitive) removeToBeFinalized.
|
||||||
|
|
||||||
(* ------------------------------------------------------------------
|
/* ------------------------------------------------------------------
|
||||||
* HASHING
|
* HASHING
|
||||||
* ------------------------------------------------------------------ *)
|
* ------------------------------------------------------------------ */
|
||||||
method(#dual,#primitive) hash.
|
method(#dual,#primitive) hash.
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method(#dual) hash
|
method(#dual) hash
|
||||||
{
|
{
|
||||||
<primitive: #Apex_hash>
|
<primitive: #Apex_hash>
|
||||||
self subclassResponsibility: #hash
|
self subclassResponsibility: #hash
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
(* ------------------------------------------------------------------
|
/* ------------------------------------------------------------------
|
||||||
* IDENTITY TEST
|
* IDENTITY TEST
|
||||||
* ------------------------------------------------------------------ *)
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
## check if the receiver is identical to anObject.
|
## check if the receiver is identical to anObject.
|
||||||
## this doesn't compare the contents
|
## this doesn't compare the contents
|
||||||
@ -158,9 +158,9 @@ extend Apex
|
|||||||
^(self == anObject) not.
|
^(self == anObject) not.
|
||||||
}
|
}
|
||||||
|
|
||||||
(* ------------------------------------------------------------------
|
/* ------------------------------------------------------------------
|
||||||
* EQUALITY TEST
|
* EQUALITY TEST
|
||||||
* ------------------------------------------------------------------ *)
|
* ------------------------------------------------------------------ */
|
||||||
method(#dual) = anObject
|
method(#dual) = anObject
|
||||||
{
|
{
|
||||||
<primitive: #'Apex_='>
|
<primitive: #'Apex_='>
|
||||||
@ -174,9 +174,9 @@ extend Apex
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
(* ------------------------------------------------------------------
|
/* ------------------------------------------------------------------
|
||||||
* COMMON QUERIES
|
* COMMON QUERIES
|
||||||
* ------------------------------------------------------------------ *)
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
method(#dual,#primitive) class.
|
method(#dual,#primitive) class.
|
||||||
|
|
||||||
@ -210,10 +210,10 @@ extend Apex
|
|||||||
{
|
{
|
||||||
| c |
|
| c |
|
||||||
c := self superclass.
|
c := self superclass.
|
||||||
(* [c notNil] whileTrue: [
|
/* [c notNil] whileTrue: [
|
||||||
[ c == aClass ] ifTrue: [^true].
|
[ c == aClass ] ifTrue: [^true].
|
||||||
c := c superclass.
|
c := c superclass.
|
||||||
]. *)
|
]. */
|
||||||
while (c notNil)
|
while (c notNil)
|
||||||
{
|
{
|
||||||
if (c == aClass) { ^true }.
|
if (c == aClass) { ^true }.
|
||||||
@ -224,10 +224,10 @@ extend Apex
|
|||||||
|
|
||||||
method(#class) isMemberOf: aClass
|
method(#class) isMemberOf: aClass
|
||||||
{
|
{
|
||||||
(* a class object is an instance of Class
|
/* a class object is an instance of Class
|
||||||
* but Class inherits from Apex. On the other hand,
|
* but Class inherits from Apex. On the other hand,
|
||||||
* most of ordinary classes are under Object again under Apex.
|
* most of ordinary classes are under Object again under Apex.
|
||||||
* special consideration is required here. *)
|
* special consideration is required here. */
|
||||||
^aClass == Class
|
^aClass == Class
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,13 +276,13 @@ extend Apex
|
|||||||
self primitiveFailed
|
self primitiveFailed
|
||||||
}
|
}
|
||||||
|
|
||||||
(* ------------------------------------------------------------------
|
/* ------------------------------------------------------------------
|
||||||
* COMMON ERROR/EXCEPTION HANDLERS
|
* COMMON ERROR/EXCEPTION HANDLERS
|
||||||
* ------------------------------------------------------------------ *)
|
* ------------------------------------------------------------------ */
|
||||||
method(#dual) error: msgText
|
method(#dual) error: msgText
|
||||||
{
|
{
|
||||||
(* TODO: implement this
|
/* TODO: implement this
|
||||||
Error signal: msgText. *)
|
Error signal: msgText. */
|
||||||
msgText dump.
|
msgText dump.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ class UndefinedObject(Apex)
|
|||||||
|
|
||||||
extend Error
|
extend Error
|
||||||
{
|
{
|
||||||
(* ----------------------------
|
/* ----------------------------
|
||||||
TODO: support nested pooldic/constant declaration...
|
TODO: support nested pooldic/constant declaration...
|
||||||
|
|
||||||
pooldic/const
|
pooldic/const
|
||||||
@ -325,7 +325,7 @@ extend Error
|
|||||||
NONE := #\e0.
|
NONE := #\e0.
|
||||||
GENERIC := #\e1.
|
GENERIC := #\e1.
|
||||||
}
|
}
|
||||||
-------------------------------- *)
|
-------------------------------- */
|
||||||
|
|
||||||
method isError
|
method isError
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class Boolean(Object)
|
class Boolean(Object)
|
||||||
{
|
{
|
||||||
(* TODO: do i need to really define methods defined in True and False here?
|
/* TODO: do i need to really define methods defined in True and False here?
|
||||||
and call subclassResponsibiltiy?" *)
|
and call subclassResponsibiltiy?" */
|
||||||
}
|
}
|
||||||
|
|
||||||
class True(Boolean)
|
class True(Boolean)
|
||||||
|
@ -17,8 +17,8 @@ class(#pointer,#limited) Class(Apex) [ClassInterface]
|
|||||||
|
|
||||||
method(#class) initialize { ^self }
|
method(#class) initialize { ^self }
|
||||||
|
|
||||||
(* most of the following methods can actually become class methods of Apex.
|
/* most of the following methods can actually become class methods of Apex.
|
||||||
* if the instance varibles can be made accessible from the Apex class. *)
|
* if the instance varibles can be made accessible from the Apex class. */
|
||||||
method name { ^self.name }
|
method name { ^self.name }
|
||||||
method superclass { ^self.superclass }
|
method superclass { ^self.superclass }
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class(#pointer,#limited) Class(Apex) [ClassInterface]
|
|||||||
^self.spec bitShift: -8
|
^self.spec bitShift: -8
|
||||||
}
|
}
|
||||||
|
|
||||||
(*method inheritsFrom: aSuperclass
|
/*method inheritsFrom: aSuperclass
|
||||||
{
|
{
|
||||||
| c |
|
| c |
|
||||||
c := self superclass.
|
c := self superclass.
|
||||||
@ -38,7 +38,7 @@ class(#pointer,#limited) Class(Apex) [ClassInterface]
|
|||||||
c := c superclass.
|
c := c superclass.
|
||||||
].
|
].
|
||||||
^false
|
^false
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
method nsup { ^self.nsup }
|
method nsup { ^self.nsup }
|
||||||
method nsdic { ^self.nsdic }
|
method nsdic { ^self.nsdic }
|
||||||
|
@ -13,8 +13,8 @@ class Collection(Object)
|
|||||||
|
|
||||||
method size
|
method size
|
||||||
{
|
{
|
||||||
(* Each subclass must override this method because
|
/* Each subclass must override this method because
|
||||||
* it interates over the all elements for counting *)
|
* it interates over the all elements for counting */
|
||||||
| count |
|
| count |
|
||||||
count := 0.
|
count := 0.
|
||||||
self do: [ :el | count := count + 1 ].
|
self do: [ :el | count := count + 1 ].
|
||||||
@ -163,7 +163,7 @@ class(#pointer) Array(SequenceableCollection)
|
|||||||
|
|
||||||
| s i ss |
|
| s i ss |
|
||||||
|
|
||||||
(*
|
/*
|
||||||
s := anArray size.
|
s := anArray size.
|
||||||
|
|
||||||
if (start < 0) { start := 0 }
|
if (start < 0) { start := 0 }
|
||||||
@ -171,7 +171,7 @@ class(#pointer) Array(SequenceableCollection)
|
|||||||
|
|
||||||
if (end < 0) { end := 0 }
|
if (end < 0) { end := 0 }
|
||||||
elsif (end >= s) { end := s - 1 }.
|
elsif (end >= s) { end := s - 1 }.
|
||||||
*)
|
*/
|
||||||
i := 0.
|
i := 0.
|
||||||
ss := self size.
|
ss := self size.
|
||||||
while (start <= end)
|
while (start <= end)
|
||||||
@ -261,15 +261,15 @@ class(#character) String(Array)
|
|||||||
{
|
{
|
||||||
method & string
|
method & string
|
||||||
{
|
{
|
||||||
(* TOOD: make this a primitive for performance. *)
|
/* TOOD: make this a primitive for performance. */
|
||||||
|
|
||||||
(* concatenate two strings. *)
|
/* concatenate two strings. */
|
||||||
| newsize newstr cursize appsize |
|
| newsize newstr cursize appsize |
|
||||||
|
|
||||||
cursize := self basicSize.
|
cursize := self basicSize.
|
||||||
appsize := string basicSize.
|
appsize := string basicSize.
|
||||||
newsize := cursize + appsize.
|
newsize := cursize + appsize.
|
||||||
(*newstr := self class basicNew: newsize.*)
|
/*newstr := self class basicNew: newsize.*/
|
||||||
newstr := String basicNew: newsize.
|
newstr := String basicNew: newsize.
|
||||||
|
|
||||||
0 priorTo: cursize do: [:i | newstr at: i put: (self at: i) ].
|
0 priorTo: cursize do: [:i | newstr at: i put: (self at: i) ].
|
||||||
@ -283,15 +283,15 @@ class(#character) String(Array)
|
|||||||
^self
|
^self
|
||||||
}
|
}
|
||||||
|
|
||||||
(* TODO: Symbol is a #final class. Symbol new is not allowed. To create a symbol programatically, you should
|
/* TODO: Symbol is a #final class. Symbol new is not allowed. To create a symbol programatically, you should
|
||||||
* build a string and send asSymbol to the string............
|
* build a string and send asSymbol to the string............
|
||||||
method asSymbol
|
method asSymbol
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
(* The strlen method returns the number of characters before a terminating null.
|
/* The strlen method returns the number of characters before a terminating null.
|
||||||
* if no terminating null character exists, it returns the same value as the size method *)
|
* if no terminating null character exists, it returns the same value as the size method */
|
||||||
method(#primitive,#lenient) _strlen.
|
method(#primitive,#lenient) _strlen.
|
||||||
method(#primitive) strlen.
|
method(#primitive) strlen.
|
||||||
|
|
||||||
@ -305,9 +305,9 @@ class(#character,#final,#limited,#immutable) Symbol(String)
|
|||||||
{
|
{
|
||||||
method asString
|
method asString
|
||||||
{
|
{
|
||||||
(* TODO: make this a primitive for performance *)
|
/* TODO: make this a primitive for performance */
|
||||||
|
|
||||||
(* convert a symbol to a string *)
|
/* convert a symbol to a string */
|
||||||
| size str i |
|
| size str i |
|
||||||
size := self basicSize.
|
size := self basicSize.
|
||||||
str := String basicNew: size.
|
str := String basicNew: size.
|
||||||
@ -324,14 +324,14 @@ class(#character,#final,#limited,#immutable) Symbol(String)
|
|||||||
|
|
||||||
method = anObject
|
method = anObject
|
||||||
{
|
{
|
||||||
(* for a symbol, equality check is the same as the identity check *)
|
/* for a symbol, equality check is the same as the identity check */
|
||||||
<primitive: #'Apex_=='>
|
<primitive: #'Apex_=='>
|
||||||
self primitiveFailed.
|
self primitiveFailed.
|
||||||
}
|
}
|
||||||
|
|
||||||
method ~= anObject
|
method ~= anObject
|
||||||
{
|
{
|
||||||
(* for a symbol, equality check is the same as the identity check *)
|
/* for a symbol, equality check is the same as the identity check */
|
||||||
<primitive: #'Apex_~~'>
|
<primitive: #'Apex_~~'>
|
||||||
^(self == anObject) not.
|
^(self == anObject) not.
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ class(#byte) ByteArray(Array)
|
|||||||
<primitive: #_utf8_to_uc>
|
<primitive: #_utf8_to_uc>
|
||||||
self primitiveFailed(thisContext method).
|
self primitiveFailed(thisContext method).
|
||||||
|
|
||||||
(*
|
/*
|
||||||
### TODO: implement this in moo also..
|
### TODO: implement this in moo also..
|
||||||
| firstByte |
|
| firstByte |
|
||||||
firstByte := self at: 0.
|
firstByte := self at: 0.
|
||||||
@ -363,7 +363,7 @@ class(#byte) ByteArray(Array)
|
|||||||
elsif (firstByte bitAnd:2r11110000) == 2r11100000) { 4 }
|
elsif (firstByte bitAnd:2r11110000) == 2r11100000) { 4 }
|
||||||
elsif (firstByte bitAnd:2r11111000) == 2r11110000) { 5 }
|
elsif (firstByte bitAnd:2r11111000) == 2r11110000) { 5 }
|
||||||
elsif (firstByte bitAnd:2r11111100) == 2r11111000) { 6 }.
|
elsif (firstByte bitAnd:2r11111100) == 2r11111000) { 6 }.
|
||||||
*)
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -718,7 +718,7 @@ class OrderedCollection(SequenceableCollection)
|
|||||||
self.buffer at: self.lastIndex put: nil.
|
self.buffer at: self.lastIndex put: nil.
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method findIndex: obj
|
method findIndex: obj
|
||||||
{
|
{
|
||||||
| i |
|
| i |
|
||||||
@ -731,7 +731,7 @@ class OrderedCollection(SequenceableCollection)
|
|||||||
}.
|
}.
|
||||||
|
|
||||||
^Error.Code.ENOENT.
|
^Error.Code.ENOENT.
|
||||||
} *)
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ class Set(Collection)
|
|||||||
{
|
{
|
||||||
| newbuc newsz ass index i |
|
| newbuc newsz ass index i |
|
||||||
|
|
||||||
(* expand the bucket *)
|
/* expand the bucket */
|
||||||
newsz := bs + 16. ## TODO: make this sizing operation configurable.
|
newsz := bs + 16. ## TODO: make this sizing operation configurable.
|
||||||
newbuc := Array new: newsz.
|
newbuc := Array new: newsz.
|
||||||
i := 0.
|
i := 0.
|
||||||
@ -846,12 +846,12 @@ class Set(Collection)
|
|||||||
y := (y + 1) rem: bs.
|
y := (y + 1) rem: bs.
|
||||||
|
|
||||||
ass := self.bucket at: y.
|
ass := self.bucket at: y.
|
||||||
if (ass isNil) { (* done. the slot at the current index is nil *) break }.
|
if (ass isNil) { /* done. the slot at the current index is nil */ break }.
|
||||||
|
|
||||||
(* get the natural hash index *)
|
/* get the natural hash index */
|
||||||
z := (ass key hash) rem: bs.
|
z := (ass key hash) rem: bs.
|
||||||
|
|
||||||
(* move an element if necessary *)
|
/* move an element if necessary */
|
||||||
if (((y > x) and ((z <= x) or (z > y))) or ((y < x) and ((z <= x) and (z > y))))
|
if (((y > x) and ((z <= x) or (z > y))) or ((y < x) and ((z <= x) and (z > y))))
|
||||||
{
|
{
|
||||||
self.bucket at: x put: (self.bucket at: y).
|
self.bucket at: x put: (self.bucket at: y).
|
||||||
@ -864,7 +864,7 @@ class Set(Collection)
|
|||||||
self.bucket at: x put: nil.
|
self.bucket at: x put: nil.
|
||||||
self.tally := self.tally - 1.
|
self.tally := self.tally - 1.
|
||||||
|
|
||||||
(* return the affected association *)
|
/* return the affected association */
|
||||||
^v
|
^v
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,8 +988,8 @@ class AssociativeCollection(Collection)
|
|||||||
{
|
{
|
||||||
| newbuc newsz ass index i |
|
| newbuc newsz ass index i |
|
||||||
|
|
||||||
(* expand the bucket *)
|
/* expand the bucket */
|
||||||
newsz := bs + 128. (* TODO: keep this growth policy in sync with VM(dic.c) *)
|
newsz := bs + 128. /* TODO: keep this growth policy in sync with VM(dic.c) */
|
||||||
newbuc := Array new: newsz.
|
newbuc := Array new: newsz.
|
||||||
i := 0.
|
i := 0.
|
||||||
while (i < bs)
|
while (i < bs)
|
||||||
@ -1019,7 +1019,7 @@ class AssociativeCollection(Collection)
|
|||||||
{
|
{
|
||||||
if (key = ass key)
|
if (key = ass key)
|
||||||
{
|
{
|
||||||
(* found *)
|
/* found */
|
||||||
if (upsert) { ass value: value }.
|
if (upsert) { ass value: value }.
|
||||||
^ass
|
^ass
|
||||||
}.
|
}.
|
||||||
@ -1134,12 +1134,12 @@ class AssociativeCollection(Collection)
|
|||||||
y := (y + 1) rem: bs.
|
y := (y + 1) rem: bs.
|
||||||
|
|
||||||
ass := self.bucket at: y.
|
ass := self.bucket at: y.
|
||||||
if (ass isNil) { (* done. the slot at the current index is nil *) break }.
|
if (ass isNil) { /* done. the slot at the current index is nil */ break }.
|
||||||
|
|
||||||
(* get the natural hash index *)
|
/* get the natural hash index */
|
||||||
z := (ass key hash) rem: bs.
|
z := (ass key hash) rem: bs.
|
||||||
|
|
||||||
(* move an element if necessary *)
|
/* move an element if necessary */
|
||||||
if (((y > x) and ((z <= x) or (z > y))) or ((y < x) and ((z <= x) and (z > y))))
|
if (((y > x) and ((z <= x) or (z > y))) or ((y < x) and ((z <= x) and (z > y))))
|
||||||
{
|
{
|
||||||
self.bucket at: x put: (self.bucket at: y).
|
self.bucket at: x put: (self.bucket at: y).
|
||||||
@ -1174,19 +1174,19 @@ class AssociativeCollection(Collection)
|
|||||||
|
|
||||||
method removeAllKeys
|
method removeAllKeys
|
||||||
{
|
{
|
||||||
(* remove all items from a dictionary *)
|
/* remove all items from a dictionary */
|
||||||
| bs |
|
| bs |
|
||||||
bs := self.bucket size.
|
bs := self.bucket size.
|
||||||
0 priorTo: bs do: [:i | self.bucket at: i put: nil ].
|
0 priorTo: bs do: [:i | self.bucket at: i put: nil ].
|
||||||
self.tally := 0
|
self.tally := 0
|
||||||
}
|
}
|
||||||
|
|
||||||
(* TODO: ... keys is an array of keys.
|
/* TODO: ... keys is an array of keys.
|
||||||
method removeAllKeys: keys
|
method removeAllKeys: keys
|
||||||
{
|
{
|
||||||
self notImplemented: #removeAllKeys:
|
self notImplemented: #removeAllKeys:
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method remove: assoc
|
method remove: assoc
|
||||||
{
|
{
|
||||||
@ -1282,10 +1282,10 @@ class SymbolTable(AssociativeCollection)
|
|||||||
|
|
||||||
class Dictionary(AssociativeCollection)
|
class Dictionary(AssociativeCollection)
|
||||||
{
|
{
|
||||||
(* [NOTE]
|
/* [NOTE]
|
||||||
* VM require Dictionary to implement new: and __put_assoc
|
* VM require Dictionary to implement new: and __put_assoc
|
||||||
* for the dictionary expression notation - %{ }
|
* for the dictionary expression notation - %{ }
|
||||||
*)
|
*/
|
||||||
|
|
||||||
## TODO: implement Dictionary as a Hashed List/Table or Red-Black Tree
|
## TODO: implement Dictionary as a Hashed List/Table or Red-Black Tree
|
||||||
## Do not inherit Set upon reimplementation
|
## Do not inherit Set upon reimplementation
|
||||||
@ -1295,14 +1295,14 @@ class Dictionary(AssociativeCollection)
|
|||||||
^super new: (capacity + 10).
|
^super new: (capacity + 10).
|
||||||
}
|
}
|
||||||
|
|
||||||
(* put_assoc: is called internally by VM to add an association
|
/* put_assoc: is called internally by VM to add an association
|
||||||
* to a dictionary with the dictionary/association expression notation
|
* to a dictionary with the dictionary/association expression notation
|
||||||
* like this:
|
* like this:
|
||||||
*
|
*
|
||||||
* %{ 1 -> 20, #moo -> 999 }
|
* %{ 1 -> 20, #moo -> 999 }
|
||||||
*
|
*
|
||||||
* it must return self for the way VM works.
|
* it must return self for the way VM works.
|
||||||
*)
|
*/
|
||||||
method __put_assoc: assoc
|
method __put_assoc: assoc
|
||||||
{
|
{
|
||||||
| hv ass bs index ntally key |
|
| hv ass bs index ntally key |
|
||||||
@ -1312,22 +1312,22 @@ class Dictionary(AssociativeCollection)
|
|||||||
hv := key hash.
|
hv := key hash.
|
||||||
index := hv rem: bs.
|
index := hv rem: bs.
|
||||||
|
|
||||||
(* as long as 'assoc' supports the message 'key' and 'value'
|
/* as long as 'assoc' supports the message 'key' and 'value'
|
||||||
* this dictionary should work. there is no explicit check
|
* this dictionary should work. there is no explicit check
|
||||||
* on this protocol of key and value. *)
|
* on this protocol of key and value. */
|
||||||
|
|
||||||
while ((ass := self.bucket at: index) notNil)
|
while ((ass := self.bucket at: index) notNil)
|
||||||
{
|
{
|
||||||
if (key = ass key)
|
if (key = ass key)
|
||||||
{
|
{
|
||||||
(* found *)
|
/* found */
|
||||||
self.bucket at: index put: assoc.
|
self.bucket at: index put: assoc.
|
||||||
^self. ## it must return self for the instructions generated by the compiler.
|
^self. ## it must return self for the instructions generated by the compiler.
|
||||||
}.
|
}.
|
||||||
index := (index + 1) rem: bs.
|
index := (index + 1) rem: bs.
|
||||||
}.
|
}.
|
||||||
|
|
||||||
(* not found *)
|
/* not found */
|
||||||
ntally := self.tally + 1.
|
ntally := self.tally + 1.
|
||||||
if (ntally >= bs)
|
if (ntally >= bs)
|
||||||
{
|
{
|
||||||
@ -1340,15 +1340,15 @@ class Dictionary(AssociativeCollection)
|
|||||||
self.tally := ntally.
|
self.tally := ntally.
|
||||||
self.bucket at: index put: assoc.
|
self.bucket at: index put: assoc.
|
||||||
|
|
||||||
(* it must return self for the instructions generated by the compiler.
|
/* it must return self for the instructions generated by the compiler.
|
||||||
* otherwise, VM will break. *)
|
* otherwise, VM will break. */
|
||||||
^self.
|
^self.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(* Namespace is marked with #limited. If a compiler is writeen in moo itself, it must
|
/* Namespace is marked with #limited. If a compiler is writeen in moo itself, it must
|
||||||
* call a primitive to instantiate a new namespace rather than sending the new message
|
* call a primitive to instantiate a new namespace rather than sending the new message
|
||||||
* to Namespace *)
|
* to Namespace */
|
||||||
class(#limited) Namespace(AssociativeCollection)
|
class(#limited) Namespace(AssociativeCollection)
|
||||||
{
|
{
|
||||||
var name, nsup.
|
var name, nsup.
|
||||||
@ -1356,10 +1356,10 @@ class(#limited) Namespace(AssociativeCollection)
|
|||||||
method name { ^self.name }
|
method name { ^self.name }
|
||||||
## method name: name { self.name := name }
|
## method name: name { self.name := name }
|
||||||
|
|
||||||
(* nsup points to either the class associated with this namespace or directly
|
/* nsup points to either the class associated with this namespace or directly
|
||||||
* the upper namespace placed above this namespace. when it points to a class,
|
* the upper namespace placed above this namespace. when it points to a class,
|
||||||
* you should inspect the nsup field of the class to reach the actual upper
|
* you should inspect the nsup field of the class to reach the actual upper
|
||||||
* namespace *)
|
* namespace */
|
||||||
method nsup { ^self.nsup }
|
method nsup { ^self.nsup }
|
||||||
## method nsup: nsup { self.nsup := nsup }
|
## method nsup: nsup { self.nsup := nsup }
|
||||||
|
|
||||||
@ -1452,7 +1452,7 @@ class LinkedList(Collection)
|
|||||||
{
|
{
|
||||||
if (pos isNil)
|
if (pos isNil)
|
||||||
{
|
{
|
||||||
(* add link at the back *)
|
/* add link at the back */
|
||||||
if (self.tally == 0)
|
if (self.tally == 0)
|
||||||
{
|
{
|
||||||
self.first := link.
|
self.first := link.
|
||||||
@ -1469,7 +1469,7 @@ class LinkedList(Collection)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(* insert the link before pos *)
|
/* insert the link before pos */
|
||||||
link next: pos.
|
link next: pos.
|
||||||
link prev: pos prev.
|
link prev: pos prev.
|
||||||
if (pos prev notNil) { pos prev next: link }
|
if (pos prev notNil) { pos prev next: link }
|
||||||
|
@ -55,14 +55,14 @@ class Console(Object) from 'con'
|
|||||||
method(#primitive) _setcursor(x, y).
|
method(#primitive) _setcursor(x, y).
|
||||||
method(#primitive) _write(msg).
|
method(#primitive) _write(msg).
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method finalize
|
method finalize
|
||||||
{
|
{
|
||||||
if (still open) {
|
if (still open) {
|
||||||
self _close.
|
self _close.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
|
|
||||||
## method(#class) input
|
## method(#class) input
|
||||||
|
@ -17,7 +17,7 @@ class(#pointer) Context(Apex)
|
|||||||
^self.ntmprs
|
^self.ntmprs
|
||||||
}
|
}
|
||||||
|
|
||||||
(* ---------------------------------
|
/* ---------------------------------
|
||||||
method varargCount
|
method varargCount
|
||||||
{
|
{
|
||||||
method context,
|
method context,
|
||||||
@ -39,7 +39,7 @@ block context...
|
|||||||
^self.home varargAt: index
|
^self.home varargAt: index
|
||||||
}
|
}
|
||||||
|
|
||||||
---------------------------------- *)
|
---------------------------------- */
|
||||||
}
|
}
|
||||||
|
|
||||||
class(#pointer,#final,#limited) MethodContext(Context)
|
class(#pointer,#final,#limited) MethodContext(Context)
|
||||||
@ -161,7 +161,7 @@ class(#pointer,#final,#limited) BlockContext(Context)
|
|||||||
method ifFalse: aBlock
|
method ifFalse: aBlock
|
||||||
{
|
{
|
||||||
##^(self value) ifFalse: aBlock.
|
##^(self value) ifFalse: aBlock.
|
||||||
^if (self value) { (* nothing *) } else { aBlock value }.
|
^if (self value) { /* nothing */ } else { aBlock value }.
|
||||||
}
|
}
|
||||||
|
|
||||||
method ifTrue: trueBlock ifFalse: falseBlock
|
method ifTrue: trueBlock ifFalse: falseBlock
|
||||||
@ -172,15 +172,15 @@ class(#pointer,#final,#limited) BlockContext(Context)
|
|||||||
|
|
||||||
method whileTrue: aBlock
|
method whileTrue: aBlock
|
||||||
{
|
{
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Naive recursive implementation
|
* Naive recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
(self value) ifFalse: [^nil].
|
(self value) ifFalse: [^nil].
|
||||||
aBlock value.
|
aBlock value.
|
||||||
self whileTrue: aBlock.
|
self whileTrue: aBlock.
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
|
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Non-recursive implementation
|
* Non-recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
| pc sp |
|
| pc sp |
|
||||||
@ -197,22 +197,22 @@ class(#pointer,#final,#limited) BlockContext(Context)
|
|||||||
thisContext goto: pc.
|
thisContext goto: pc.
|
||||||
* -------------------------------------------------- *(
|
* -------------------------------------------------- *(
|
||||||
|
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Imperative implementation - == true or ~~ false? match the VM implementation
|
* Imperative implementation - == true or ~~ false? match the VM implementation
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
while ((self value) ~~ false) { aBlock value }.
|
while ((self value) ~~ false) { aBlock value }.
|
||||||
}
|
}
|
||||||
|
|
||||||
method whileTrue
|
method whileTrue
|
||||||
{
|
{
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Naive recursive implementation
|
* Naive recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
(self value) ifFalse: [^nil].
|
(self value) ifFalse: [^nil].
|
||||||
self whileTrue.
|
self whileTrue.
|
||||||
* -------------------------------------------------- */
|
* -------------------------------------------------- */
|
||||||
|
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Non-recursive implementation
|
* Non-recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
| pc |
|
| pc |
|
||||||
@ -221,23 +221,23 @@ class(#pointer,#final,#limited) BlockContext(Context)
|
|||||||
thisContext goto: pc.
|
thisContext goto: pc.
|
||||||
* -------------------------------------------------- */
|
* -------------------------------------------------- */
|
||||||
|
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Imperative implementation
|
* Imperative implementation
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
while ((self value) ~~ false) { }.
|
while ((self value) ~~ false) { }.
|
||||||
}
|
}
|
||||||
|
|
||||||
method whileFalse: aBlock
|
method whileFalse: aBlock
|
||||||
{
|
{
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Naive recursive implementation
|
* Naive recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
(self value) ifTrue: [^nil].
|
(self value) ifTrue: [^nil].
|
||||||
aBlock value.
|
aBlock value.
|
||||||
self whileFalse: aBlock.
|
self whileFalse: aBlock.
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
|
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Non-recursive implementation
|
* Non-recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
* The assignment to 'pc' uses the POP_INTO_TEMPVAR_1.
|
* The assignment to 'pc' uses the POP_INTO_TEMPVAR_1.
|
||||||
@ -257,31 +257,31 @@ class(#pointer,#final,#limited) BlockContext(Context)
|
|||||||
(self value) ifTrue: [ ^nil ]. ## ^self
|
(self value) ifTrue: [ ^nil ]. ## ^self
|
||||||
aBlock value.
|
aBlock value.
|
||||||
thisContext goto: pc.
|
thisContext goto: pc.
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
|
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Imperative implementation
|
* Imperative implementation
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
while ((self value) == false) { aBlock value }.
|
while ((self value) == false) { aBlock value }.
|
||||||
}
|
}
|
||||||
|
|
||||||
method whileFalse
|
method whileFalse
|
||||||
{
|
{
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Naive recursive implementation
|
* Naive recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
(self value) ifTrue: [^nil].
|
(self value) ifTrue: [^nil].
|
||||||
self whileFalse.
|
self whileFalse.
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
|
|
||||||
(* --------------------------------------------------
|
/* --------------------------------------------------
|
||||||
* Non-recursive implementation
|
* Non-recursive implementation
|
||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
| pc |
|
| pc |
|
||||||
pc := thisContext pcplus1.
|
pc := thisContext pcplus1.
|
||||||
(self value) ifTrue: [ ^nil ]. ## ^self
|
(self value) ifTrue: [ ^nil ]. ## ^self
|
||||||
thisContext goto: pc.
|
thisContext goto: pc.
|
||||||
* -------------------------------------------------- *)
|
* -------------------------------------------------- */
|
||||||
while ((self value) == false) { }.
|
while ((self value) == false) { }.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ class(#pointer) CompiledMethod(Object)
|
|||||||
|
|
||||||
method preambleCode
|
method preambleCode
|
||||||
{
|
{
|
||||||
(* TODO: make this a primtive for performance *)
|
/* TODO: make this a primtive for performance */
|
||||||
^(self.preamble bitShift: -4) bitAnd: 16r1F.
|
^(self.preamble bitShift: -4) bitAnd: 16r1F.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class Exception(Apex)
|
|||||||
var signalContext, handlerContext.
|
var signalContext, handlerContext.
|
||||||
var(#get) messageText.
|
var(#get) messageText.
|
||||||
|
|
||||||
(*
|
/*
|
||||||
TODO: can i convert 'thisProcess primError' to a relevant exception?
|
TODO: can i convert 'thisProcess primError' to a relevant exception?
|
||||||
var(#class) primExceptTable.
|
var(#class) primExceptTable.
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ TODO: can i convert 'thisProcess primError' to a relevant exception?
|
|||||||
{
|
{
|
||||||
^self.primExceptTable at: no
|
^self.primExceptTable at: no
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method(#class) signal
|
method(#class) signal
|
||||||
{
|
{
|
||||||
@ -182,8 +182,8 @@ extend Context
|
|||||||
eb := ctx ensureBlock.
|
eb := ctx ensureBlock.
|
||||||
if (eb notNil)
|
if (eb notNil)
|
||||||
{
|
{
|
||||||
(* position of the temporary variable in the ensureBlock that indicates
|
/* position of the temporary variable in the ensureBlock that indicates
|
||||||
* if the block has been evaluated *)
|
* if the block has been evaluated */
|
||||||
pending_pos := ctx basicSize - 1.
|
pending_pos := ctx basicSize - 1.
|
||||||
if (ctx basicAt: pending_pos)
|
if (ctx basicAt: pending_pos)
|
||||||
{
|
{
|
||||||
@ -246,21 +246,21 @@ extend MethodContext
|
|||||||
|
|
||||||
method findExceptionHandlerFor: exception_class
|
method findExceptionHandlerFor: exception_class
|
||||||
{
|
{
|
||||||
(* find an exception handler block for a given exception class.
|
/* find an exception handler block for a given exception class.
|
||||||
*
|
*
|
||||||
* for this to work, self must be an exception handler context.
|
* for this to work, self must be an exception handler context.
|
||||||
* For a single on:do: call,
|
* For a single on:do: call,
|
||||||
* self class specNumInstVars must return 8.(i.e.MethodContext has 8 instance variables.)
|
* self class specNumInstVars must return 8.(i.e.MethodContext has 8 instance variables.)
|
||||||
* basicAt: 8 must be the on: argument.
|
* basicAt: 8 must be the on: argument.
|
||||||
* basicAt: 9 must be the do: argument *)
|
* basicAt: 9 must be the do: argument */
|
||||||
|
|
||||||
| size exc i |
|
| size exc i |
|
||||||
|
|
||||||
if (self isExceptionContext)
|
if (self isExceptionContext)
|
||||||
{
|
{
|
||||||
(* NOTE: the following loop scans all parameters to the on:do: method.
|
/* NOTE: the following loop scans all parameters to the on:do: method.
|
||||||
* if the on:do: method contains local temporary variables,
|
* if the on:do: method contains local temporary variables,
|
||||||
* those must be skipped from scanning. *)
|
* those must be skipped from scanning. */
|
||||||
|
|
||||||
size := self basicSize.
|
size := self basicSize.
|
||||||
##8 priorTo: size by: 2 do: [ :i |
|
##8 priorTo: size by: 2 do: [ :i |
|
||||||
@ -285,7 +285,7 @@ extend MethodContext
|
|||||||
|
|
||||||
method handleException: exception
|
method handleException: exception
|
||||||
{
|
{
|
||||||
(* -----------------------------------------------------------------
|
/* -----------------------------------------------------------------
|
||||||
* <<private>>
|
* <<private>>
|
||||||
* called by Exception>>signal.
|
* called by Exception>>signal.
|
||||||
* this method only exists in the MethodContext and UndefinedObject.
|
* this method only exists in the MethodContext and UndefinedObject.
|
||||||
@ -293,12 +293,12 @@ extend MethodContext
|
|||||||
* a method context or nil. Exception>>signal invokes this method
|
* a method context or nil. Exception>>signal invokes this method
|
||||||
* only for an exception context which is a method context. it
|
* only for an exception context which is a method context. it
|
||||||
* invokes it for nil when no exception context is found.
|
* invokes it for nil when no exception context is found.
|
||||||
* ---------------------------------------------------------------- *)
|
* ---------------------------------------------------------------- */
|
||||||
|
|
||||||
| excblk retval actpos |
|
| excblk retval actpos |
|
||||||
|
|
||||||
(* position of the temporary variable 'exception_active' in MethodContext>>on:do.
|
/* position of the temporary variable 'exception_active' in MethodContext>>on:do.
|
||||||
* for this code to work, it must be the last temporary variable in the method. *)
|
* for this code to work, it must be the last temporary variable in the method. */
|
||||||
actpos := (self basicSize) - 1.
|
actpos := (self basicSize) - 1.
|
||||||
|
|
||||||
excblk := self findExceptionHandlerFor: (exception class).
|
excblk := self findExceptionHandlerFor: (exception class).
|
||||||
@ -312,13 +312,13 @@ extend MethodContext
|
|||||||
|
|
||||||
exception handlerContext: self.
|
exception handlerContext: self.
|
||||||
|
|
||||||
(* -----------------------------------------------------------------
|
/* -----------------------------------------------------------------
|
||||||
* if an exception occurs within an exception handler block,
|
* if an exception occurs within an exception handler block,
|
||||||
* the search will reach this context again as the exception block
|
* the search will reach this context again as the exception block
|
||||||
* is evaluated before actual unwinding. set the temporary variable
|
* is evaluated before actual unwinding. set the temporary variable
|
||||||
* in the exception context to mask out this context from the search
|
* in the exception context to mask out this context from the search
|
||||||
* list.
|
* list.
|
||||||
* ---------------------------------------------------------------- *)
|
* ---------------------------------------------------------------- */
|
||||||
self basicAt: actpos put: false.
|
self basicAt: actpos put: false.
|
||||||
[ retval := excblk value: exception ] ensure: [
|
[ retval := excblk value: exception ] ensure: [
|
||||||
self basicAt: actpos put: true
|
self basicAt: actpos put: true
|
||||||
@ -326,11 +326,11 @@ extend MethodContext
|
|||||||
|
|
||||||
##(self.sender isNil) ifTrue: [ "TODO: CANNOT RETURN" ].
|
##(self.sender isNil) ifTrue: [ "TODO: CANNOT RETURN" ].
|
||||||
|
|
||||||
(* -----------------------------------------------------------------
|
/* -----------------------------------------------------------------
|
||||||
* return to self.sender which is a caller of the exception context (on:do:)
|
* return to self.sender which is a caller of the exception context (on:do:)
|
||||||
* pass the first ensure context between thisContext and self.sender.
|
* pass the first ensure context between thisContext and self.sender.
|
||||||
* [ [Exception signal: 'xxx'] ensure: [20] ] on: Exception do: [:ex | ...]
|
* [ [Exception signal: 'xxx'] ensure: [20] ] on: Exception do: [:ex | ...]
|
||||||
* ---------------------------------------------------------------- *)
|
* ---------------------------------------------------------------- */
|
||||||
thisContext unwindTo: self.sender return: nil.
|
thisContext unwindTo: self.sender return: nil.
|
||||||
System return: retval to: self.sender.
|
System return: retval to: self.sender.
|
||||||
}
|
}
|
||||||
@ -344,14 +344,14 @@ extend BlockContext
|
|||||||
| exception_active |
|
| exception_active |
|
||||||
<exception>
|
<exception>
|
||||||
|
|
||||||
(* -------------------------------
|
/* -------------------------------
|
||||||
thisContext isExceptionContext dump.
|
thisContext isExceptionContext dump.
|
||||||
(thisContext basicSize) dump.
|
(thisContext basicSize) dump.
|
||||||
(thisContext basicAt: 8) dump. ## this should be anException
|
(thisContext basicAt: 8) dump. ## this should be anException
|
||||||
(thisContext basicAt: 9) dump. ## this should be anExceptionBlock
|
(thisContext basicAt: 9) dump. ## this should be anExceptionBlock
|
||||||
(thisContext basicAt: 10) dump. ## this should be handlerActive
|
(thisContext basicAt: 10) dump. ## this should be handlerActive
|
||||||
'on:do: ABOUT TO EVALUE THE RECEIVER BLOCK' dump.
|
'on:do: ABOUT TO EVALUE THE RECEIVER BLOCK' dump.
|
||||||
---------------------------------- *)
|
---------------------------------- */
|
||||||
exception_active := true.
|
exception_active := true.
|
||||||
^self value.
|
^self value.
|
||||||
}
|
}
|
||||||
@ -380,9 +380,9 @@ thisContext isExceptionContext dump.
|
|||||||
pending := true.
|
pending := true.
|
||||||
retval := self value.
|
retval := self value.
|
||||||
|
|
||||||
(* the temporary variable 'pending' may get changed
|
/* the temporary variable 'pending' may get changed
|
||||||
* during evaluation for exception handling.
|
* during evaluation for exception handling.
|
||||||
* it gets chagned in Context>>unwindTo:return: *)
|
* it gets chagned in Context>>unwindTo:return: */
|
||||||
if (pending) { pending := false. aBlock value }.
|
if (pending) { pending := false. aBlock value }.
|
||||||
^retval
|
^retval
|
||||||
}
|
}
|
||||||
@ -476,7 +476,7 @@ extend Apex
|
|||||||
{
|
{
|
||||||
| a b msg ec ex |
|
| a b msg ec ex |
|
||||||
|
|
||||||
(* since method is an argument, the caller can call this method
|
/* since method is an argument, the caller can call this method
|
||||||
* from a context chain where the method context actually doesn't exist.
|
* from a context chain where the method context actually doesn't exist.
|
||||||
* when a primitive method is defined using the #primitive method,
|
* when a primitive method is defined using the #primitive method,
|
||||||
* the VM invokes this primtiveFailed method without creating
|
* the VM invokes this primtiveFailed method without creating
|
||||||
@ -488,16 +488,16 @@ extend Apex
|
|||||||
* on the other handle, in the latter definition, the context
|
* on the other handle, in the latter definition, the context
|
||||||
* for the method is activated first before primitiveFailed is
|
* for the method is activated first before primitiveFailed is
|
||||||
* invoked. in the context chain, the method for xxx is found.
|
* invoked. in the context chain, the method for xxx is found.
|
||||||
*)
|
*/
|
||||||
|
|
||||||
(*System logNl: 'Arguments: '.
|
/*System logNl: 'Arguments: '.
|
||||||
a := 0.
|
a := 0.
|
||||||
b := thisContext vargCount.
|
b := thisContext vargCount.
|
||||||
while (a < b)
|
while (a < b)
|
||||||
{
|
{
|
||||||
System logNl: (thisContext vargAt: a) asString.
|
System logNl: (thisContext vargAt: a) asString.
|
||||||
a := a + 1.
|
a := a + 1.
|
||||||
}.*)
|
}.*/
|
||||||
|
|
||||||
ec := thisProcess primError.
|
ec := thisProcess primError.
|
||||||
msg := thisProcess primErrorMessage.
|
msg := thisProcess primErrorMessage.
|
||||||
@ -509,7 +509,7 @@ extend Apex
|
|||||||
### elsif (ec == Error.Code.EPERM) { self messageProhibited: method name }
|
### elsif (ec == Error.Code.EPERM) { self messageProhibited: method name }
|
||||||
### elsif (ec == Error.Code.ENOIMPL) { self subclassResponsibility: method name }.
|
### elsif (ec == Error.Code.ENOIMPL) { self subclassResponsibility: method name }.
|
||||||
|
|
||||||
(PrimitiveFailureException (* in: method *) withErrorCode: ec) signal: msg.
|
(PrimitiveFailureException /* in: method */ withErrorCode: ec) signal: msg.
|
||||||
}
|
}
|
||||||
|
|
||||||
method(#dual) doesNotUnderstand: message_name
|
method(#dual) doesNotUnderstand: message_name
|
||||||
|
@ -4,7 +4,7 @@ class _FFI(Object) from 'ffi'
|
|||||||
method(#primitive) close.
|
method(#primitive) close.
|
||||||
method(#primitive) getsym(name).
|
method(#primitive) getsym(name).
|
||||||
|
|
||||||
(* TODO: make call variadic? method(#primitive,#variadic) call (func, sig). *)
|
/* TODO: make call variadic? method(#primitive,#variadic) call (func, sig). */
|
||||||
method(#primitive) call(func, sig, args).
|
method(#primitive) call(func, sig, args).
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,12 +48,12 @@ class FFI(Object)
|
|||||||
{
|
{
|
||||||
| f rc |
|
| f rc |
|
||||||
|
|
||||||
(* f := self.funcs at: name ifAbsent: [
|
/* f := self.funcs at: name ifAbsent: [
|
||||||
f := self.ffi getsym(name).
|
f := self.ffi getsym(name).
|
||||||
if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }.
|
if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }.
|
||||||
self.funcs at: name put: f.
|
self.funcs at: name put: f.
|
||||||
f. ## need this as at:put: returns an association
|
f. ## need this as at:put: returns an association
|
||||||
]. *)
|
]. */
|
||||||
|
|
||||||
f := self.funcs at: name ifAbsent: [ nil ].
|
f := self.funcs at: name ifAbsent: [ nil ].
|
||||||
if (f isNil)
|
if (f isNil)
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
###include 'Moo.moo'.
|
###include 'Moo.moo'.
|
||||||
#include 'Socket.moo'.
|
#include 'Socket.moo'.
|
||||||
|
|
||||||
(* -------------------------------------------
|
/* -------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
----------------------------------------------- *)
|
----------------------------------------------- */
|
||||||
|
|
||||||
class Fcgi(Object)
|
class Fcgi(Object)
|
||||||
{
|
{
|
||||||
@ -220,7 +220,7 @@ class Fcgi.ParamRecord(Fcgi.Record)
|
|||||||
if (aString notNil)
|
if (aString notNil)
|
||||||
{
|
{
|
||||||
### TODO: implement this...
|
### TODO: implement this...
|
||||||
(*
|
/*
|
||||||
(aString subStrings: %(char)) do: [:each |
|
(aString subStrings: %(char)) do: [:each |
|
||||||
equal := each indexOf: $=.
|
equal := each indexOf: $=.
|
||||||
equal = 0
|
equal = 0
|
||||||
@ -229,7 +229,7 @@ class Fcgi.ParamRecord(Fcgi.Record)
|
|||||||
tempFields
|
tempFields
|
||||||
at: (each first: equal - 1)
|
at: (each first: equal - 1)
|
||||||
put: (each allButFirst: equal)]
|
put: (each allButFirst: equal)]
|
||||||
] *)
|
] */
|
||||||
}.
|
}.
|
||||||
|
|
||||||
^tempFields
|
^tempFields
|
||||||
@ -239,10 +239,10 @@ class Fcgi.ParamRecord(Fcgi.Record)
|
|||||||
{
|
{
|
||||||
| buffer stream |
|
| buffer stream |
|
||||||
buffer := aStream next: header contentLength.
|
buffer := aStream next: header contentLength.
|
||||||
(* TODO:
|
/* TODO:
|
||||||
stream := ReadStream on: buffer.
|
stream := ReadStream on: buffer.
|
||||||
[stream atEnd] whileFalse: [self readNameValueFrom: stream]
|
[stream atEnd] whileFalse: [self readNameValueFrom: stream]
|
||||||
*)
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
method readNameValueFrom: aStream
|
method readNameValueFrom: aStream
|
||||||
@ -396,11 +396,11 @@ class FcgiSocket(SyncSocket)
|
|||||||
| buf k i hdr |
|
| buf k i hdr |
|
||||||
|
|
||||||
self timeout: 10.
|
self timeout: 10.
|
||||||
(*while (true)
|
/*while (true)
|
||||||
{
|
{
|
||||||
req := self readRequest.
|
req := self readRequest.
|
||||||
|
|
||||||
}. *)
|
}. */
|
||||||
|
|
||||||
buf := ByteArray new: 128.
|
buf := ByteArray new: 128.
|
||||||
'IM RUNNING SERVICE...............' dump.
|
'IM RUNNING SERVICE...............' dump.
|
||||||
@ -416,14 +416,14 @@ class FcgiSocket(SyncSocket)
|
|||||||
## unsigned char paddingLength;
|
## unsigned char paddingLength;
|
||||||
## unsigned char reserved;
|
## unsigned char reserved;
|
||||||
## } FCGI_Header;
|
## } FCGI_Header;
|
||||||
(*
|
/*
|
||||||
ver := self.bs next.
|
ver := self.bs next.
|
||||||
type := self.bs next.
|
type := self.bs next.
|
||||||
reqid := (self.bs next bitShift: 8) bitAnd: (self.bs next). ## can i implement nextUint16??
|
reqid := (self.bs next bitShift: 8) bitAnd: (self.bs next). ## can i implement nextUint16??
|
||||||
clen := (self.bs next bitShift: 8) bitAnd: (self.bs next).
|
clen := (self.bs next bitShift: 8) bitAnd: (self.bs next).
|
||||||
plen := self.bs next.
|
plen := self.bs next.
|
||||||
self.bs next. ## eat up the reserved byte.
|
self.bs next. ## eat up the reserved byte.
|
||||||
*)
|
*/
|
||||||
|
|
||||||
## typedef struct {
|
## typedef struct {
|
||||||
## unsigned char roleB1;
|
## unsigned char roleB1;
|
||||||
@ -440,12 +440,12 @@ class FcgiSocket(SyncSocket)
|
|||||||
## unsigned char reserved[3];
|
## unsigned char reserved[3];
|
||||||
## } FCGI_EndRequestBody;
|
## } FCGI_EndRequestBody;
|
||||||
|
|
||||||
(*
|
/*
|
||||||
if (type == Fcgi.Type.BEGIN_REQUEST)
|
if (type == Fcgi.Type.BEGIN_REQUEST)
|
||||||
{
|
{
|
||||||
} *)
|
} */
|
||||||
|
|
||||||
(*
|
/*
|
||||||
i := 0.
|
i := 0.
|
||||||
while (i < 3)
|
while (i < 3)
|
||||||
{
|
{
|
||||||
@ -459,7 +459,7 @@ class FcgiSocket(SyncSocket)
|
|||||||
self.bs nextPut: k from: buf startingAt: 10.
|
self.bs nextPut: k from: buf startingAt: 10.
|
||||||
}.
|
}.
|
||||||
self.bs flush.
|
self.bs flush.
|
||||||
*)
|
*/
|
||||||
|
|
||||||
self close.
|
self close.
|
||||||
}
|
}
|
||||||
@ -764,7 +764,7 @@ oc := Fcgi.ParamRecord new.
|
|||||||
(oc parseToFields: 'a=b&d=f' separatedBy: $&) dump.
|
(oc parseToFields: 'a=b&d=f' separatedBy: $&) dump.
|
||||||
thisProcess terminate.
|
thisProcess terminate.
|
||||||
|
|
||||||
(*
|
/*
|
||||||
[
|
[
|
||||||
addr := SocketAddress fromString: '1.2.3.4:5555'.
|
addr := SocketAddress fromString: '1.2.3.4:5555'.
|
||||||
##addr := SocketAddress fromString: '127.0.0.1:22'.
|
##addr := SocketAddress fromString: '127.0.0.1:22'.
|
||||||
@ -772,7 +772,7 @@ fcgi := SyncSocket family: (addr family) type: Socket.Type.STREAM.
|
|||||||
fcgi timeout: 5.
|
fcgi timeout: 5.
|
||||||
fcgi connect: addr.
|
fcgi connect: addr.
|
||||||
] on: Exception do: [:ex | ].
|
] on: Exception do: [:ex | ].
|
||||||
*)
|
*/
|
||||||
|
|
||||||
[ self another_proc: 5000 ] fork.
|
[ self another_proc: 5000 ] fork.
|
||||||
[ self another_proc: 5100 ] fork.
|
[ self another_proc: 5100 ] fork.
|
||||||
|
@ -117,22 +117,22 @@ class HttpSocket(SyncSocket)
|
|||||||
| buf k i |
|
| buf k i |
|
||||||
|
|
||||||
self timeout: 10.
|
self timeout: 10.
|
||||||
(*while (true)
|
/*while (true)
|
||||||
{
|
{
|
||||||
req := self readRequest.
|
req := self readRequest.
|
||||||
|
|
||||||
}. *)
|
}. */
|
||||||
|
|
||||||
|
|
||||||
buf := ByteArray new: 128.
|
buf := ByteArray new: 128.
|
||||||
'IM RUNNING SERVICE...............' dump.
|
'IM RUNNING SERVICE...............' dump.
|
||||||
|
|
||||||
(*
|
/*
|
||||||
self readBytesInto: buf.
|
self readBytesInto: buf.
|
||||||
buf dump.
|
buf dump.
|
||||||
self readBytesInto: buf.
|
self readBytesInto: buf.
|
||||||
buf dump.
|
buf dump.
|
||||||
*)
|
*/
|
||||||
|
|
||||||
i := 0.
|
i := 0.
|
||||||
while (i < 3)
|
while (i < 3)
|
||||||
@ -443,7 +443,7 @@ class MyObject(Object)
|
|||||||
{
|
{
|
||||||
| httpd addr |
|
| httpd addr |
|
||||||
|
|
||||||
(*
|
/*
|
||||||
[
|
[
|
||||||
addr := SocketAddress fromString: '1.2.3.4:5555'.
|
addr := SocketAddress fromString: '1.2.3.4:5555'.
|
||||||
##addr := SocketAddress fromString: '127.0.0.1:22'.
|
##addr := SocketAddress fromString: '127.0.0.1:22'.
|
||||||
@ -451,7 +451,7 @@ httpd := SyncSocket family: (addr family) type: Socket.Type.STREAM.
|
|||||||
httpd timeout: 5.
|
httpd timeout: 5.
|
||||||
httpd connect: addr.
|
httpd connect: addr.
|
||||||
] on: Exception do: [:ex | ].
|
] on: Exception do: [:ex | ].
|
||||||
*)
|
*/
|
||||||
|
|
||||||
[ self another_proc: 5000 ] fork.
|
[ self another_proc: 5000 ] fork.
|
||||||
[ self another_proc: 5100 ] fork.
|
[ self another_proc: 5100 ] fork.
|
||||||
|
@ -245,8 +245,8 @@ class(#limited) Number(Magnitude)
|
|||||||
|
|
||||||
method bitShift: aNumber
|
method bitShift: aNumber
|
||||||
{
|
{
|
||||||
(* positive number for left shift.
|
/* positive number for left shift.
|
||||||
* negative number for right shift *)
|
* negative number for right shift */
|
||||||
|
|
||||||
<primitive: #Integer_bitshift>
|
<primitive: #Integer_bitshift>
|
||||||
self primitiveFailed.
|
self primitiveFailed.
|
||||||
@ -267,7 +267,7 @@ class(#limited) Number(Magnitude)
|
|||||||
{
|
{
|
||||||
| i |
|
| i |
|
||||||
i := self.
|
i := self.
|
||||||
(*
|
/*
|
||||||
(step > 0)
|
(step > 0)
|
||||||
ifTrue: [
|
ifTrue: [
|
||||||
[ i <= end ] whileTrue: [
|
[ i <= end ] whileTrue: [
|
||||||
@ -281,7 +281,7 @@ class(#limited) Number(Magnitude)
|
|||||||
i := i - step.
|
i := i - step.
|
||||||
].
|
].
|
||||||
].
|
].
|
||||||
*)
|
*/
|
||||||
if (step > 0)
|
if (step > 0)
|
||||||
{
|
{
|
||||||
while (i <= end)
|
while (i <= end)
|
||||||
@ -309,7 +309,7 @@ class(#limited) Number(Magnitude)
|
|||||||
{
|
{
|
||||||
| i |
|
| i |
|
||||||
i := self.
|
i := self.
|
||||||
(*
|
/*
|
||||||
(step > 0)
|
(step > 0)
|
||||||
ifTrue: [
|
ifTrue: [
|
||||||
[ i < end ] whileTrue: [
|
[ i < end ] whileTrue: [
|
||||||
@ -323,7 +323,7 @@ class(#limited) Number(Magnitude)
|
|||||||
i := i - step.
|
i := i - step.
|
||||||
].
|
].
|
||||||
].
|
].
|
||||||
*)
|
*/
|
||||||
if (step > 0)
|
if (step > 0)
|
||||||
{
|
{
|
||||||
while (i < end)
|
while (i < end)
|
||||||
@ -349,16 +349,16 @@ class(#limited) Number(Magnitude)
|
|||||||
|
|
||||||
method abs
|
method abs
|
||||||
{
|
{
|
||||||
(*self < 0 ifTrue: [^self negated].
|
/*self < 0 ifTrue: [^self negated].
|
||||||
^self.*)
|
^self.*/
|
||||||
^if (self < 0) { self negated } else { self }
|
^if (self < 0) { self negated } else { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
method sign
|
method sign
|
||||||
{
|
{
|
||||||
(* self < 0 ifTrue: [^-1].
|
/* self < 0 ifTrue: [^-1].
|
||||||
self > 0 ifTrue: [^1].
|
self > 0 ifTrue: [^1].
|
||||||
^0.*)
|
^0.*/
|
||||||
^if (self < 0) { -1 } elsif (self > 0) { 1 } else { 0 }
|
^if (self < 0) { -1 } elsif (self > 0) { 1 } else { 0 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,10 @@ class MyObject(Object)
|
|||||||
{
|
{
|
||||||
| d a ffi |
|
| d a ffi |
|
||||||
|
|
||||||
(*k := Mill new.
|
/*k := Mill new.
|
||||||
k register: #abc call: [ Dictionary new ].
|
k register: #abc call: [ Dictionary new ].
|
||||||
a := k make: #abc.
|
a := k make: #abc.
|
||||||
##a dump.*)
|
##a dump.*/
|
||||||
|
|
||||||
d := Dictionary new.
|
d := Dictionary new.
|
||||||
d at: #abc put: 20.
|
d at: #abc put: 20.
|
||||||
@ -55,9 +55,9 @@ class MyObject(Object)
|
|||||||
d at: #moo put: 'good?'.
|
d at: #moo put: 'good?'.
|
||||||
d at: #moo put: 'not good?'.
|
d at: #moo put: 'not good?'.
|
||||||
|
|
||||||
(* (d at: #abc) dump.
|
/* (d at: #abc) dump.
|
||||||
(* (d at: #dddd) dump. *)
|
/* (d at: #dddd) dump. */
|
||||||
(*d do: [:v | v dump].*)
|
/*d do: [:v | v dump].*/
|
||||||
|
|
||||||
d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ].
|
d keysAndValuesDo: [:k :v| System logNl: (k asString) & ' => ' & (v asString) ].
|
||||||
|
|
||||||
@ -72,17 +72,17 @@ class MyObject(Object)
|
|||||||
(d at: #jjjj) dump.
|
(d at: #jjjj) dump.
|
||||||
(d at: #jjjja) dump.
|
(d at: #jjjja) dump.
|
||||||
|
|
||||||
(*
|
/*
|
||||||
System keysAndValuesDo: [:k :v|
|
System keysAndValuesDo: [:k :v|
|
||||||
System logNl: (k asString) & ' => ' & (v asString)
|
System logNl: (k asString) & ' => ' & (v asString)
|
||||||
].
|
].
|
||||||
*)
|
*/
|
||||||
|
|
||||||
##System keysDo: [:k| System logNl: (k asString)]
|
##System keysDo: [:k| System logNl: (k asString)]
|
||||||
|
|
||||||
(*[
|
/*[
|
||||||
[Exception hash dump] ensure: ['xxxx' dump].
|
[Exception hash dump] ensure: ['xxxx' dump].
|
||||||
] on: Exception do: [:ex | ('Exception caught - ' & ex asString) dump ].*)
|
] on: Exception do: [:ex | ('Exception caught - ' & ex asString) dump ].*/
|
||||||
|
|
||||||
ffi := FFI new: '/lib64/libc.so.6'.
|
ffi := FFI new: '/lib64/libc.so.6'.
|
||||||
if (ffi isError)
|
if (ffi isError)
|
||||||
@ -160,12 +160,12 @@ class MyObject(Object)
|
|||||||
]
|
]
|
||||||
]) dump.
|
]) dump.
|
||||||
|
|
||||||
(*
|
/*
|
||||||
a := 5.
|
a := 5.
|
||||||
while (true) {
|
while (true) {
|
||||||
System logNl: a asString.
|
System logNl: a asString.
|
||||||
a := a + 100000000000000.
|
a := a + 100000000000000.
|
||||||
}.*)
|
}.*/
|
||||||
|
|
||||||
|
|
||||||
a := if(false) { 10 } elsif (false) { 20 } elsif (false) { 30} else { 40}.
|
a := if(false) { 10 } elsif (false) { 20 } elsif (false) { 30} else { 40}.
|
||||||
@ -228,24 +228,24 @@ class MyObject(Object)
|
|||||||
#'a b c'
|
#'a b c'
|
||||||
).
|
).
|
||||||
|
|
||||||
(* Dictionary ???
|
/* Dictionary ???
|
||||||
a := %{
|
a := %{
|
||||||
key -> value ,
|
key -> value ,
|
||||||
key -> value ,
|
key -> value ,
|
||||||
key -> value ,
|
key -> value ,
|
||||||
key -> value
|
key -> value
|
||||||
),.
|
),.
|
||||||
*)
|
*/
|
||||||
|
|
||||||
a do: [ :v | v dump].
|
a do: [ :v | v dump].
|
||||||
|
|
||||||
(*
|
/*
|
||||||
## how to handle return inside 'if' like the following???
|
## how to handle return inside 'if' like the following???
|
||||||
## what happens to the stack?
|
## what happens to the stack?
|
||||||
a := if ((k := 20) == 10) {99} else { 100}.
|
a := if ((k := 20) == 10) {99} else { 100}.
|
||||||
k dump.
|
k dump.
|
||||||
a dump.
|
a dump.
|
||||||
*)
|
*/
|
||||||
'---------- END ------------' dump.
|
'---------- END ------------' dump.
|
||||||
##System sleepForSecs: 20.
|
##System sleepForSecs: 20.
|
||||||
}
|
}
|
||||||
@ -260,7 +260,7 @@ class MyObject(Object)
|
|||||||
|
|
||||||
a := 100.
|
a := 100.
|
||||||
## PROBLEM: the following double loop will exhaust the stack
|
## PROBLEM: the following double loop will exhaust the stack
|
||||||
(*
|
/*
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
##111 dump.
|
##111 dump.
|
||||||
@ -272,7 +272,7 @@ class MyObject(Object)
|
|||||||
##[:j :q | (j + q) dump] value: 10 value: 20.
|
##[:j :q | (j + q) dump] value: 10 value: 20.
|
||||||
##if (false) {} else { break }.
|
##if (false) {} else { break }.
|
||||||
}.
|
}.
|
||||||
}.*)
|
}.*/
|
||||||
|
|
||||||
|
|
||||||
a := %{
|
a := %{
|
||||||
@ -285,8 +285,8 @@ class MyObject(Object)
|
|||||||
'ccc' -> 890
|
'ccc' -> 890
|
||||||
}.
|
}.
|
||||||
|
|
||||||
(*a removeKey: 'bbb'.
|
/*a removeKey: 'bbb'.
|
||||||
a remove: :(#bbb).*)
|
a remove: :(#bbb).*/
|
||||||
|
|
||||||
##1 to: 100 do: [ :i | a at: i put: (i * 2) ].
|
##1 to: 100 do: [ :i | a at: i put: (i * 2) ].
|
||||||
a keysAndValuesDo: [:k :v |
|
a keysAndValuesDo: [:k :v |
|
||||||
@ -296,7 +296,7 @@ class MyObject(Object)
|
|||||||
].
|
].
|
||||||
|
|
||||||
(a associationAt: (#aaa -> nil)) dump.
|
(a associationAt: (#aaa -> nil)) dump.
|
||||||
(*
|
/*
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@ -304,12 +304,12 @@ class MyObject(Object)
|
|||||||
[:j :q | (j + q) dump] value: (if (true) { 20 }) value: (if (true) { break }).
|
[:j :q | (j + q) dump] value: (if (true) { 20 }) value: (if (true) { break }).
|
||||||
(1 + (if (false) {} else { break })) dump.
|
(1 + (if (false) {} else { break })) dump.
|
||||||
}
|
}
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(* basicAt: 12 to access the nsdic field. use a proper method once it's defined in Class *)
|
/* basicAt: 12 to access the nsdic field. use a proper method once it's defined in Class */
|
||||||
## (System nsdic) keysAndValuesDo: [:k :v |
|
## (System nsdic) keysAndValuesDo: [:k :v |
|
||||||
## k dump.
|
## k dump.
|
||||||
## v dump.
|
## v dump.
|
||||||
@ -344,7 +344,7 @@ a free.
|
|||||||
System sleepForSecs: 2.
|
System sleepForSecs: 2.
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
#method(#class) main
|
#method(#class) main
|
||||||
{
|
{
|
||||||
| event |
|
| event |
|
||||||
@ -359,12 +359,12 @@ a free.
|
|||||||
event := GUI waitForEvent.
|
event := GUI waitForEvent.
|
||||||
GUI dispatchEvent: event.
|
GUI dispatchEvent: event.
|
||||||
}
|
}
|
||||||
}*)
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
pooldic XXD {
|
pooldic XXD {
|
||||||
#abc := #(1 2 3).
|
#abc := #(1 2 3).
|
||||||
#def := %( 1, 3, 4 ). ## syntax error - literal expected where %( is
|
#def := %( 1, 3, 4 ). ## syntax error - literal expected where %( is
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include 'Process.moo'.
|
#include 'Process.moo'.
|
||||||
#include 'Stream.moo'.
|
#include 'Stream.moo'.
|
||||||
|
|
||||||
(* -------------------------------------------------------------------------- *)
|
/* -------------------------------------------------------------------------- */
|
||||||
#include 'FFI.moo'.
|
#include 'FFI.moo'.
|
||||||
#include 'Stdio.moo'.
|
#include 'Stdio.moo'.
|
||||||
## #include 'Console.moo'.
|
## #include 'Console.moo'.
|
||||||
|
@ -156,11 +156,11 @@ class Mutex(Semaphore)
|
|||||||
^s.
|
^s.
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
TODO: how to prohibit wait and signal???
|
TODO: how to prohibit wait and signal???
|
||||||
method(#prohibited) wait.
|
method(#prohibited) wait.
|
||||||
method(#prohibited) signal.
|
method(#prohibited) signal.
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method lock { ^super wait }
|
method lock { ^super wait }
|
||||||
method unlock { ^super signal }
|
method unlock { ^super signal }
|
||||||
@ -186,16 +186,16 @@ class SemaphoreGroup(Object)
|
|||||||
sem_io_count := 0,
|
sem_io_count := 0,
|
||||||
sem_count := 0.
|
sem_count := 0.
|
||||||
|
|
||||||
(* TODO: good idea to a shortcut way to prohibit a certain method in the heirarchy chain?
|
/* TODO: good idea to a shortcut way to prohibit a certain method in the heirarchy chain?
|
||||||
method(#class,#prohibited) new.
|
method(#class,#prohibited) new.
|
||||||
method(#class,#prohibited) new: size.
|
method(#class,#prohibited) new: size.
|
||||||
method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibility: #xxxx }
|
method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibility: #xxxx }
|
||||||
*)
|
*/
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method(#class) new { self messageProhibited: #new }
|
method(#class) new { self messageProhibited: #new }
|
||||||
method(#class) new: size { self messageProhibited: #new: }
|
method(#class) new: size { self messageProhibited: #new: }
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method(#primitive) addSemaphore: sem.
|
method(#primitive) addSemaphore: sem.
|
||||||
method(#primitive) removeSemaphore: sem.
|
method(#primitive) removeSemaphore: sem.
|
||||||
|
@ -20,10 +20,10 @@ class(#byte) IPAddress(Object)
|
|||||||
|
|
||||||
class(#byte(4)) IP4Address(IPAddress)
|
class(#byte(4)) IP4Address(IPAddress)
|
||||||
{
|
{
|
||||||
(*method(#class) new
|
/*method(#class) new
|
||||||
{
|
{
|
||||||
^self basicNew: 4.
|
^self basicNew: 4.
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
method(#class) fromString: str
|
method(#class) fromString: str
|
||||||
{
|
{
|
||||||
@ -76,10 +76,10 @@ class(#byte(4)) IP4Address(IPAddress)
|
|||||||
while (true).
|
while (true).
|
||||||
|
|
||||||
^self.
|
^self.
|
||||||
(*
|
/*
|
||||||
(@label@)
|
(@label@)
|
||||||
Exception signal: ('invalid IPv4 address ' & str).
|
Exception signal: ('invalid IPv4 address ' & str).
|
||||||
*)
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
method fromString: str
|
method fromString: str
|
||||||
@ -93,10 +93,10 @@ class(#byte(4)) IP4Address(IPAddress)
|
|||||||
|
|
||||||
class(#byte(16)) IP6Address(IP4Address)
|
class(#byte(16)) IP6Address(IP4Address)
|
||||||
{
|
{
|
||||||
(*method(#class) new
|
/*method(#class) new
|
||||||
{
|
{
|
||||||
^self basicNew: 16.
|
^self basicNew: 16.
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
##method(#class) fromString: str
|
##method(#class) fromString: str
|
||||||
##{
|
##{
|
||||||
@ -304,7 +304,7 @@ class SyncSocket(Socket)
|
|||||||
method(#class) new { self messageProhibited: #new }
|
method(#class) new { self messageProhibited: #new }
|
||||||
method(#class) new: size { self messageProhibited: #new: }
|
method(#class) new: size { self messageProhibited: #new: }
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method(#class) __with_handle: handle
|
method(#class) __with_handle: handle
|
||||||
{
|
{
|
||||||
###self addToBeFinalized.
|
###self addToBeFinalized.
|
||||||
@ -319,7 +319,7 @@ class SyncSocket(Socket)
|
|||||||
##^(self new) open(family, type, 0)
|
##^(self new) open(family, type, 0)
|
||||||
^(super new) open(family, type, 0)
|
^(super new) open(family, type, 0)
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method initialize
|
method initialize
|
||||||
{
|
{
|
||||||
@ -437,7 +437,7 @@ class AsyncSocket(Socket)
|
|||||||
var pending_bytes, pending_offset, pending_length.
|
var pending_bytes, pending_offset, pending_length.
|
||||||
var outreadysem, outdonesem, inreadysem.
|
var outreadysem, outdonesem, inreadysem.
|
||||||
|
|
||||||
(* -------------------
|
/* -------------------
|
||||||
socket call-back methods
|
socket call-back methods
|
||||||
socketClosing
|
socketClosing
|
||||||
socketClosed
|
socketClosed
|
||||||
@ -445,7 +445,7 @@ class AsyncSocket(Socket)
|
|||||||
socketDataOut
|
socketDataOut
|
||||||
socketAccepted:from:
|
socketAccepted:from:
|
||||||
socketConnected:
|
socketConnected:
|
||||||
-------------------- *)
|
-------------------- */
|
||||||
|
|
||||||
method initialize
|
method initialize
|
||||||
{
|
{
|
||||||
@ -489,13 +489,13 @@ class AsyncSocket(Socket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method finalize
|
method finalize
|
||||||
{
|
{
|
||||||
'SOCKET FINALIZED...............' dump.
|
'SOCKET FINALIZED...............' dump.
|
||||||
self close.
|
self close.
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method close
|
method close
|
||||||
{
|
{
|
||||||
@ -619,7 +619,7 @@ class AsyncClientSocket(AsyncSocket)
|
|||||||
self onSocketConnected: (soerr == 0).
|
self onSocketConnected: (soerr == 0).
|
||||||
if (soerr == 0) { self beWatched }.
|
if (soerr == 0) { self beWatched }.
|
||||||
}.
|
}.
|
||||||
(* HOW TO HANDLE TIMEOUT? *)
|
/* HOW TO HANDLE TIMEOUT? */
|
||||||
].
|
].
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -726,7 +726,7 @@ class AsyncServerSocket(AsyncSocket)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
class ListenerSocket(Socket)
|
class ListenerSocket(Socket)
|
||||||
{
|
{
|
||||||
var inreadysem.
|
var inreadysem.
|
||||||
@ -806,4 +806,4 @@ class ListenerSocket(Socket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
@ -14,7 +14,7 @@ class Stdio(Object) from 'stdio'
|
|||||||
^(self new) open(name, mode)
|
^(self new) open(name, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
(* ---------------------
|
/* ---------------------
|
||||||
method(#class) stdin
|
method(#class) stdin
|
||||||
{
|
{
|
||||||
self.in isNil ifTrue: [ self.in := ^(super new) open: 0 for: 'r' ].
|
self.in isNil ifTrue: [ self.in := ^(super new) open: 0 for: 'r' ].
|
||||||
@ -32,14 +32,14 @@ class Stdio(Object) from 'stdio'
|
|||||||
self.err isNil ifTrue: [ self.err := ^(super new) open: 2 for: 'w' ].
|
self.err isNil ifTrue: [ self.err := ^(super new) open: 2 for: 'w' ].
|
||||||
^self.err.
|
^self.err.
|
||||||
}
|
}
|
||||||
------------------------ *)
|
------------------------ */
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method format: fmt with: ...
|
method format: fmt with: ...
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method(#variadic) format (fmt)
|
method(#variadic) format (fmt)
|
||||||
{
|
{
|
||||||
|
@ -125,17 +125,17 @@ class ExternalStream(ReadWriteStream)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
## mimic java's interface...
|
## mimic java's interface...
|
||||||
interface ByteStreamable
|
interface ByteStreamable
|
||||||
{
|
{
|
||||||
readBytesInto:
|
readBytesInto:
|
||||||
writeBytesFrom:
|
writeBytesFrom:
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
### TODO: specify interface inside []
|
### TODO: specify interface inside []
|
||||||
(*
|
/*
|
||||||
difficulty: how to ensure that the class implements the defined interface?
|
difficulty: how to ensure that the class implements the defined interface?
|
||||||
|
|
||||||
1) check when a new instance is created.
|
1) check when a new instance is created.
|
||||||
@ -186,7 +186,7 @@ extension String: StringConvertible {
|
|||||||
4) other methods???
|
4) other methods???
|
||||||
|
|
||||||
Let me think about it..
|
Let me think about it..
|
||||||
*)
|
*/
|
||||||
|
|
||||||
class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
|
class ByteStreamAdapter(Object) ### [ByteStreamable, ByteXXX]
|
||||||
{
|
{
|
||||||
@ -383,7 +383,7 @@ class ByteStream(ByteStreamAdapter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
class TextStream(ByteStream)
|
class TextStream(ByteStream)
|
||||||
{
|
{
|
||||||
method initialize
|
method initialize
|
||||||
@ -400,5 +400,5 @@ class TextStream(ByteStream)
|
|||||||
{
|
{
|
||||||
if (self.seq at: 0) bitAnd:
|
if (self.seq at: 0) bitAnd:
|
||||||
}
|
}
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
|
@ -146,13 +146,13 @@ class System(Apex)
|
|||||||
##
|
##
|
||||||
method(#class,#variadic,#primitive) log(level,msg1).
|
method(#class,#variadic,#primitive) log(level,msg1).
|
||||||
|
|
||||||
(*
|
/*
|
||||||
TODO: how to pass all variadic arguments to another variadic methods???
|
TODO: how to pass all variadic arguments to another variadic methods???
|
||||||
method(#class,#variadic) logInfo (msg1)
|
method(#class,#variadic) logInfo (msg1)
|
||||||
{
|
{
|
||||||
^self log (System.Log.INFO,msg1)
|
^self log (System.Log.INFO,msg1)
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
method(#class) atLevel: level log: message
|
method(#class) atLevel: level log: message
|
||||||
{
|
{
|
||||||
<primitive: #System_log>
|
<primitive: #System_log>
|
||||||
@ -214,7 +214,7 @@ TODO: how to pass all variadic arguments to another variadic methods???
|
|||||||
^self atLevel: System.Log.INFO logNl: message and: message2.
|
^self atLevel: System.Log.INFO logNl: message and: message2.
|
||||||
}
|
}
|
||||||
|
|
||||||
(* nsdic access *)
|
/* nsdic access */
|
||||||
method(#class) at: key
|
method(#class) at: key
|
||||||
{
|
{
|
||||||
^self nsdic at: key
|
^self nsdic at: key
|
||||||
@ -225,7 +225,7 @@ TODO: how to pass all variadic arguments to another variadic methods???
|
|||||||
^self nsdic at: key put: value
|
^self nsdic at: key put: value
|
||||||
}
|
}
|
||||||
|
|
||||||
(* raw memory allocation *)
|
/* raw memory allocation */
|
||||||
method(#class,#primitive) malloc (size).
|
method(#class,#primitive) malloc (size).
|
||||||
method(#class,#primitive) calloc (size).
|
method(#class,#primitive) calloc (size).
|
||||||
method(#class,#primitive) free (rawptr).
|
method(#class,#primitive) free (rawptr).
|
||||||
@ -234,7 +234,7 @@ TODO: how to pass all variadic arguments to another variadic methods???
|
|||||||
method(#class,#primitive) calloc: size.
|
method(#class,#primitive) calloc: size.
|
||||||
method(#class,#primitive) free: rawptr.
|
method(#class,#primitive) free: rawptr.
|
||||||
|
|
||||||
(* raw memory access *)
|
/* raw memory access */
|
||||||
method(#class,#primitive) getInt8 (rawptr, offset). ## <primitive: #System__getInt8>
|
method(#class,#primitive) getInt8 (rawptr, offset). ## <primitive: #System__getInt8>
|
||||||
method(#class,#primitive) getInt16 (rawptr, offset).
|
method(#class,#primitive) getInt16 (rawptr, offset).
|
||||||
method(#class,#primitive) getInt32 (rawptr, offset).
|
method(#class,#primitive) getInt32 (rawptr, offset).
|
||||||
|
@ -84,7 +84,7 @@ method(#dual,#liberal) def(x, z) { ^nil }
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
TODO: TODO: compiler enhancement
|
TODO: TODO: compiler enhancement
|
||||||
class X11(Object)
|
class X11(Object)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ TODO: TODO: compiler enhancement
|
|||||||
}
|
}
|
||||||
----> should i support soemthign like ::X11.Rectangle and X11.Rectangle? ::X11.Rectangle alwasy from the top???
|
----> should i support soemthign like ::X11.Rectangle and X11.Rectangle? ::X11.Rectangle alwasy from the top???
|
||||||
-----> or .X11.Rectangle -> to start search from the current name space???
|
-----> or .X11.Rectangle -> to start search from the current name space???
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method(#primitive,#liberal) _open_display(name).
|
method(#primitive,#liberal) _open_display(name).
|
||||||
method(#primitive) _close_display.
|
method(#primitive) _close_display.
|
||||||
@ -595,7 +595,7 @@ extend X11
|
|||||||
self.shell_container := self.Composite new.
|
self.shell_container := self.Composite new.
|
||||||
self.window_registrar := System.Dictionary new: 100.
|
self.window_registrar := System.Dictionary new: 100.
|
||||||
|
|
||||||
(*
|
/*
|
||||||
|
|
||||||
self.llevent_blocks := System.Dictionary new.
|
self.llevent_blocks := System.Dictionary new.
|
||||||
self.llevent_blocks
|
self.llevent_blocks
|
||||||
@ -610,7 +610,7 @@ extend X11
|
|||||||
at: self.LLEventType.DESTROY_NOTIFY put: #__handle_destroy_notify:on:;
|
at: self.LLEventType.DESTROY_NOTIFY put: #__handle_destroy_notify:on:;
|
||||||
at: self.LLEventType.CONFIGURE_NOTIFY put: #__handle_configure_notify:on:;
|
at: self.LLEventType.CONFIGURE_NOTIFY put: #__handle_configure_notify:on:;
|
||||||
at: self.LLEventType.CLIENT_MESSAGE put: #__handle_client_message:on:.
|
at: self.LLEventType.CLIENT_MESSAGE put: #__handle_client_message:on:.
|
||||||
*)
|
*/
|
||||||
self.llevent_blocks := %{
|
self.llevent_blocks := %{
|
||||||
self.LLEventType.KEY_PRESS -> #__handle_key_event:on:,
|
self.LLEventType.KEY_PRESS -> #__handle_key_event:on:,
|
||||||
self.LLEventType.KEY_RELEASE -> #__handle_key_event:on:,
|
self.LLEventType.KEY_RELEASE -> #__handle_key_event:on:,
|
||||||
|
@ -82,7 +82,7 @@ class MyObject(Object)
|
|||||||
^%( v, p ) ## v must be 2000, p must be 6000
|
^%( v, p ) ## v must be 2000, p must be 6000
|
||||||
}
|
}
|
||||||
|
|
||||||
(*
|
/*
|
||||||
method(#class) test_sem_sig
|
method(#class) test_sem_sig
|
||||||
{
|
{
|
||||||
| s |
|
| s |
|
||||||
@ -101,7 +101,7 @@ class MyObject(Object)
|
|||||||
sg add: s3 withAction: [].
|
sg add: s3 withAction: [].
|
||||||
sg wait.
|
sg wait.
|
||||||
}
|
}
|
||||||
*)
|
*/
|
||||||
|
|
||||||
method(#class) main
|
method(#class) main
|
||||||
{
|
{
|
||||||
@ -129,7 +129,7 @@ class MyObject(Object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
(*
|
/*
|
||||||
s1 := TcpSocket new.
|
s1 := TcpSocket new.
|
||||||
|
|
||||||
s1 onEvent: #connected do: [
|
s1 onEvent: #connected do: [
|
||||||
@ -156,4 +156,4 @@ s1 endSend
|
|||||||
|
|
||||||
s1 beginAccept: [callback]
|
s1 beginAccept: [callback]
|
||||||
s1 endAccept -> returns the actual socket
|
s1 endAccept -> returns the actual socket
|
||||||
*)
|
*/
|
||||||
|
@ -224,10 +224,10 @@ class MyObject(TestObject)
|
|||||||
[self getTen] value dump.
|
[self getTen] value dump.
|
||||||
}
|
}
|
||||||
|
|
||||||
(*method(#class) abc
|
/*method(#class) abc
|
||||||
{
|
{
|
||||||
<primitive: #snd_open>
|
<primitive: #snd_open>
|
||||||
}*)
|
}*/
|
||||||
|
|
||||||
method(#class) a: a b: b c: c
|
method(#class) a: a b: b c: c
|
||||||
{
|
{
|
||||||
@ -275,7 +275,7 @@ class MyObject(TestObject)
|
|||||||
|
|
||||||
self test_ffi.
|
self test_ffi.
|
||||||
|
|
||||||
(* -----------------------------
|
/* -----------------------------
|
||||||
PROCESS TESTING
|
PROCESS TESTING
|
||||||
| p |
|
| p |
|
||||||
'000000000000000000' dump.
|
'000000000000000000' dump.
|
||||||
@ -288,7 +288,7 @@ PROCESS TESTING
|
|||||||
'222222222222222222' dump.
|
'222222222222222222' dump.
|
||||||
'333333333333333333' dump.
|
'333333333333333333' dump.
|
||||||
'444444444444444444' dump.
|
'444444444444444444' dump.
|
||||||
---------------------------- *)
|
---------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -306,10 +306,10 @@ PROCESS TESTING
|
|||||||
|
|
||||||
(2r111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 * 128971234897128931) dump.
|
(2r111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 * 128971234897128931) dump.
|
||||||
|
|
||||||
(* (-10000 rem: 3) dump.
|
/* (-10000 rem: 3) dump.
|
||||||
(-10000 mod: 3) dump.
|
(-10000 mod: 3) dump.
|
||||||
(-10000 div: 3) dump.
|
(-10000 div: 3) dump.
|
||||||
(-10000 mdiv: 3) dump. *)
|
(-10000 mdiv: 3) dump. */
|
||||||
|
|
||||||
(7 rem: -3) dump.
|
(7 rem: -3) dump.
|
||||||
(7 mod: -3) dump.
|
(7 mod: -3) dump.
|
||||||
@ -359,7 +359,7 @@ PROCESS TESTING
|
|||||||
|
|
||||||
(2r1111111111111111111111111111111111111111111111111111111111111111 printStringRadix:2) dump.
|
(2r1111111111111111111111111111111111111111111111111111111111111111 printStringRadix:2) dump.
|
||||||
|
|
||||||
(* -----------------------
|
/* -----------------------
|
||||||
|
|
||||||
(16rF0FFFF bitOr: 16r111111) dump.
|
(16rF0FFFF bitOr: 16r111111) dump.
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ PROCESS TESTING
|
|||||||
|
|
||||||
((2r10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 bitAnd: 2r01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010) printStringRadix: 2) dump.
|
((2r10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101 bitAnd: 2r01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010) printStringRadix: 2) dump.
|
||||||
|
|
||||||
--------------------- *)
|
--------------------- */
|
||||||
|
|
||||||
(16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
(16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
||||||
(-16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
(-16rFFFFFFFFFFFFFFFF bitOr: 16rFFFFFFFFFFFFFFFFFFFFFFFF) dump.
|
||||||
@ -445,25 +445,25 @@ PROCESS TESTING
|
|||||||
b dump.
|
b dump.
|
||||||
] value.
|
] value.
|
||||||
'====================' dump.
|
'====================' dump.
|
||||||
([ :a :b | (*a := 20.*) b := [ a + 20 ]. b value.] value: 99 value: 100) dump.
|
([ :a :b | /*a := 20.*/ b := [ a + 20 ]. b value.] value: 99 value: 100) dump.
|
||||||
'====================' dump.
|
'====================' dump.
|
||||||
|
|
||||||
[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. ## not sufficient arguments. it must fail
|
[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. ## not sufficient arguments. it must fail
|
||||||
##[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | 'Exception' dump].
|
##[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | 'Exception' dump].
|
||||||
|
|
||||||
(*
|
/*
|
||||||
FFI isNil dump.
|
FFI isNil dump.
|
||||||
FFI notNil dump.
|
FFI notNil dump.
|
||||||
nil isNil dump.
|
nil isNil dump.
|
||||||
nil notNil dump.
|
nil notNil dump.
|
||||||
nil class dump.
|
nil class dump.
|
||||||
nil class class class dump.
|
nil class class class dump.
|
||||||
*)
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
(* ====================
|
/* ====================
|
||||||
[ a := 20. b := [ a + 20 ]. b value. ] value
|
[ a := 20. b := [ a + 20 ]. b value. ] value
|
||||||
^ ^ ^ ^
|
^ ^ ^ ^
|
||||||
p1 p3 p4 p2
|
p1 p3 p4 p2
|
||||||
@ -522,4 +522,4 @@ method whileTrue: aBlock
|
|||||||
|
|
||||||
[ b < 10 ] whileTrue: [ b dump. b := b + 1 ].
|
[ b < 10 ] whileTrue: [ b dump. b := b + 1 ].
|
||||||
|
|
||||||
========== *)
|
========== */
|
||||||
|
@ -149,7 +149,7 @@ class MyObject(TestObject)
|
|||||||
|
|
||||||
##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj'].
|
##[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj'].
|
||||||
|
|
||||||
(*
|
/*
|
||||||
v1 := [
|
v1 := [
|
||||||
| k |
|
| k |
|
||||||
k := 99.
|
k := 99.
|
||||||
@ -163,7 +163,7 @@ class MyObject(TestObject)
|
|||||||
('EXCETION - ' & ex messageText) dump.
|
('EXCETION - ' & ex messageText) dump.
|
||||||
## Exception signal: 'qqq'.
|
## Exception signal: 'qqq'.
|
||||||
].
|
].
|
||||||
*)
|
*/
|
||||||
|
|
||||||
v1 := self aaa_123.
|
v1 := self aaa_123.
|
||||||
'--------------------------------' dump.
|
'--------------------------------' dump.
|
||||||
|
@ -198,7 +198,7 @@ class MyObject(TestObject)
|
|||||||
## 100 timesRepeat: ['>>>>> END OF MAIN' dump].
|
## 100 timesRepeat: ['>>>>> END OF MAIN' dump].
|
||||||
|
|
||||||
|
|
||||||
(*
|
/*
|
||||||
(Exception isKindOf: Apex) dump.
|
(Exception isKindOf: Apex) dump.
|
||||||
(Exception isMemberOf: Apex) dump.
|
(Exception isMemberOf: Apex) dump.
|
||||||
(Exception isMemberOf: Class) dump.
|
(Exception isMemberOf: Class) dump.
|
||||||
@ -211,7 +211,7 @@ class MyObject(TestObject)
|
|||||||
(Exception isKindOf: Object) dump.
|
(Exception isKindOf: Object) dump.
|
||||||
(Exception isKindOf: (Apex new)) dump.
|
(Exception isKindOf: (Apex new)) dump.
|
||||||
(Exception isKindOf: (Object new)) dump.
|
(Exception isKindOf: (Object new)) dump.
|
||||||
*)
|
*/
|
||||||
|
|
||||||
|
|
||||||
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@' dump.
|
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@' dump.
|
||||||
|
@ -88,11 +88,11 @@ class MyObject(TestObject)
|
|||||||
|
|
||||||
##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ].
|
##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ].
|
||||||
|
|
||||||
(*[
|
/*[
|
||||||
[ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ].
|
[ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ].
|
||||||
] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ].
|
] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ].
|
||||||
|
|
||||||
[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']. *)
|
[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']. */
|
||||||
|
|
||||||
v1 := [
|
v1 := [
|
||||||
[
|
[
|
||||||
|
@ -132,9 +132,9 @@ class MyObject(TestObject)
|
|||||||
v1 puts ('hello', 'world', 'good', C'\n', C'\t', 'under my umbrella 123.', C'\n').
|
v1 puts ('hello', 'world', 'good', C'\n', C'\t', 'under my umbrella 123.', C'\n').
|
||||||
v1 close.
|
v1 close.
|
||||||
|
|
||||||
(*v1 format(10, 20) isNil ifFalse: [
|
/*v1 format(10, 20) isNil ifFalse: [
|
||||||
'Beautiful life' dump.
|
'Beautiful life' dump.
|
||||||
].*)
|
].*/
|
||||||
].
|
].
|
||||||
nil isNil ifTrue: [ 'NIL NIL NIL' dump. ].
|
nil isNil ifTrue: [ 'NIL NIL NIL' dump. ].
|
||||||
(Apex new) notNil ifTrue: [ 'APEX NIL NIL NIL' dump. ].
|
(Apex new) notNil ifTrue: [ 'APEX NIL NIL NIL' dump. ].
|
||||||
|
@ -1114,9 +1114,9 @@ static int skip_comment (moo_t* moo)
|
|||||||
if (c == '"') GET_CHAR (moo); /* keep the next character in lxc */
|
if (c == '"') GET_CHAR (moo); /* keep the next character in lxc */
|
||||||
return 1; /* double-quoted comment */
|
return 1; /* double-quoted comment */
|
||||||
}
|
}
|
||||||
else if (c == '(')
|
else if (c == '/')
|
||||||
{
|
{
|
||||||
/* handle (* ... *) */
|
/* handle block comment encoded in /x x/ where x is * */
|
||||||
lc = moo->c->lxc;
|
lc = moo->c->lxc;
|
||||||
GET_CHAR_TO (moo, c);
|
GET_CHAR_TO (moo, c);
|
||||||
if (c != '*') goto not_comment;
|
if (c != '*') goto not_comment;
|
||||||
@ -1133,7 +1133,7 @@ static int skip_comment (moo_t* moo)
|
|||||||
if (c == MOO_OOCI_EOF) goto unterminated;
|
if (c == MOO_OOCI_EOF) goto unterminated;
|
||||||
|
|
||||||
if (c == '*') goto check_rparen; /* got another * after * */
|
if (c == '*') goto check_rparen; /* got another * after * */
|
||||||
if (c == ')')
|
if (c == '/')
|
||||||
{
|
{
|
||||||
GET_CHAR (moo); /* keep the first meaningful character in lxc */
|
GET_CHAR (moo); /* keep the first meaningful character in lxc */
|
||||||
break;
|
break;
|
||||||
@ -1142,7 +1142,7 @@ static int skip_comment (moo_t* moo)
|
|||||||
}
|
}
|
||||||
while (1);
|
while (1);
|
||||||
|
|
||||||
return 1; /* multi-line comment enclosed in (* and *) */
|
return 1; /* multi-line comment enclosed in /x and x/ where x is * */
|
||||||
}
|
}
|
||||||
else if (c == '#')
|
else if (c == '#')
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user