2015-10-08 14:26:04 +00:00
|
|
|
#class Apex(nil)
|
|
|
|
{
|
|
|
|
#dcl(#class) sysdic.
|
|
|
|
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
|
|
|
#method(#class) dump
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_dump>
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#method dump
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_dump>
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
|
|
|
#method(#class) yourself
|
|
|
|
{
|
|
|
|
^self.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method yourself
|
|
|
|
{
|
|
|
|
^self.
|
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
2015-10-15 14:40:08 +00:00
|
|
|
#method(#class) basicNew
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_basic_new>
|
2015-10-08 14:26:04 +00:00
|
|
|
self primitiveFailed.
|
|
|
|
}
|
|
|
|
|
2015-10-15 14:40:08 +00:00
|
|
|
#method(#class) basicNew: anInteger
|
2015-10-08 14:26:04 +00:00
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_basic_new_with_size>
|
2015-10-08 14:26:04 +00:00
|
|
|
self primitiveFailed.
|
|
|
|
}
|
|
|
|
|
2015-12-27 18:02:59 +00:00
|
|
|
#method(#class) ngcNew
|
|
|
|
{
|
|
|
|
<primitive: #_ngc_new>
|
|
|
|
self primitiveFailed.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) ngcNew: anInteger
|
|
|
|
{
|
|
|
|
<primitive: #_ngc_new_with_size>
|
|
|
|
self primitiveFailed.
|
|
|
|
}
|
|
|
|
|
2015-10-15 14:40:08 +00:00
|
|
|
#method(#class) new
|
|
|
|
{
|
|
|
|
| x |
|
|
|
|
x := self basicNew.
|
|
|
|
x initialize. "TODO: assess if it's good to call 'initialize' from new."
|
|
|
|
^x.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) new: anInteger
|
|
|
|
{
|
|
|
|
| x |
|
2016-11-18 18:11:13 +00:00
|
|
|
## TODO: check if the class is a fixed class.
|
|
|
|
## if so, raise an exception.
|
2015-10-15 14:40:08 +00:00
|
|
|
x := self basicNew: anInteger.
|
|
|
|
x initialize. "TODO: assess if it's good to call 'initialize' from new."
|
|
|
|
^x.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method initialize
|
|
|
|
{
|
|
|
|
"a subclass may override this method."
|
|
|
|
^self.
|
|
|
|
}
|
|
|
|
|
2015-12-27 18:02:59 +00:00
|
|
|
#method ngcDispose
|
|
|
|
{
|
|
|
|
<primitive: #_ngc_dispose>
|
|
|
|
self primitiveFailed.
|
|
|
|
}
|
2015-10-30 15:36:37 +00:00
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
#method shallowCopy
|
|
|
|
{
|
|
|
|
<primitive: #_shallow_copy>
|
|
|
|
self primitiveFailed.
|
|
|
|
}
|
|
|
|
|
2015-10-08 14:26:04 +00:00
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
|
|
|
#method class
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_class>
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) class
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_class>
|
2015-10-08 14:26:04 +00:00
|
|
|
^Class
|
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
|
|
|
#method basicSize
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_basic_size>
|
|
|
|
self primitiveFailed.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) basicSize
|
|
|
|
{
|
|
|
|
<primitive: #_basic_size>
|
|
|
|
self primitiveFailed.
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#method basicAt: anInteger
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_basic_at>
|
2016-05-03 10:10:28 +00:00
|
|
|
## TODO: chagne it to 'self outOfRangeError' or something.
|
2015-10-08 14:26:04 +00:00
|
|
|
self error: 'out of range'.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method basicAt: anInteger put: anObject
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_basic_at_put>
|
2015-10-08 14:26:04 +00:00
|
|
|
self error: 'out of range'.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) basicAt: anInteger
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_basic_at>
|
2015-10-08 14:26:04 +00:00
|
|
|
self error: 'out of range'.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) basicAt: anInteger put: anObject
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_basic_at_put>
|
2015-10-08 14:26:04 +00:00
|
|
|
self error: 'out of range'.
|
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
|
|
|
#method == anObject
|
|
|
|
{
|
|
|
|
"check if the receiver is identical to anObject.
|
|
|
|
this doesn't compare the contents"
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_identical>
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#method ~~ anObject
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_not_identical>
|
2015-10-08 14:26:04 +00:00
|
|
|
^(self == anObject) not.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) == anObject
|
|
|
|
{
|
|
|
|
"check if the receiver is identical to anObject.
|
|
|
|
this doesn't compare the contents"
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_identical>
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) ~~ anObject
|
|
|
|
{
|
2015-10-15 14:40:08 +00:00
|
|
|
<primitive: #_not_identical>
|
2015-10-08 14:26:04 +00:00
|
|
|
^(self == anObject) not.
|
|
|
|
}
|
|
|
|
|
|
|
|
## TODO: add = and ~= for equality check.
|
|
|
|
|
2016-11-18 18:11:13 +00:00
|
|
|
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## COMMON QUERIES
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
2015-10-08 14:26:04 +00:00
|
|
|
#method isNil
|
|
|
|
{
|
|
|
|
"^self == nil."
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
|
|
|
#method notNil
|
|
|
|
{
|
|
|
|
"^(self == nil) not"
|
|
|
|
"^self ~= nil."
|
|
|
|
^true.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) isNil
|
|
|
|
{
|
|
|
|
"^self == nil."
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) notNil
|
|
|
|
{
|
|
|
|
"^(self == nil) not"
|
|
|
|
"^self ~= nil."
|
|
|
|
^true.
|
|
|
|
}
|
|
|
|
|
2016-11-18 18:11:13 +00:00
|
|
|
#method isError
|
|
|
|
{
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) isError
|
|
|
|
{
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
2016-05-07 01:37:44 +00:00
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
|
|
|
#method(#class) inheritsFrom: aClass
|
|
|
|
{
|
|
|
|
| c |
|
|
|
|
c := self superclass.
|
|
|
|
[c notNil] whileTrue: [
|
|
|
|
[ c == aClass ] ifTrue: [^true].
|
|
|
|
c := c superclass.
|
|
|
|
].
|
|
|
|
^false
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) isMemberOf: aClass
|
|
|
|
{
|
|
|
|
## a class object is an instance of Class
|
|
|
|
## but Class inherits from Apex. On the other hand,
|
|
|
|
## most of ordinary classes are under Object again under Apex.
|
|
|
|
## special consideration is required here.
|
|
|
|
^aClass == Class
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) isKindOf: aClass
|
|
|
|
{
|
|
|
|
^(self isMemberOf: aClass) or: [self inheritsFrom: aClass].
|
|
|
|
}
|
|
|
|
|
|
|
|
#method isMemberOf: aClass
|
|
|
|
{
|
|
|
|
^self class == aClass
|
|
|
|
}
|
|
|
|
|
|
|
|
#method isKindOf: aClass
|
|
|
|
{
|
|
|
|
^(self isMemberOf: aClass) or: [self class inheritsFrom: aClass].
|
|
|
|
}
|
|
|
|
|
2015-10-08 14:26:04 +00:00
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
"
|
|
|
|
#method(#class) respondsTo: selectorSymbol
|
|
|
|
{
|
|
|
|
TODO: find selectorSymbol in the class method dictionary...
|
|
|
|
}
|
|
|
|
|
|
|
|
#method respondsTo: selectorSymbol
|
|
|
|
{
|
|
|
|
TODO: find selectorSymbol in the method dictionary...
|
|
|
|
}
|
|
|
|
"
|
|
|
|
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
2016-05-03 10:10:28 +00:00
|
|
|
## method(#class) primitiveFailed
|
2016-05-02 13:59:28 +00:00
|
|
|
## {
|
|
|
|
## this method will be added after Exception class has been defined.
|
|
|
|
## }
|
2015-10-08 14:26:04 +00:00
|
|
|
|
|
|
|
#method primitiveFailed
|
|
|
|
{
|
|
|
|
self class primitiveFailed.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method doesNotUnderstand: messageSymbol
|
|
|
|
{
|
|
|
|
self class doesNotUnderstand: messageSymbol
|
|
|
|
}
|
|
|
|
|
|
|
|
#method(#class) error: msgText
|
|
|
|
{
|
|
|
|
## TODO: implement this
|
|
|
|
## Error signal: msgText.
|
|
|
|
msgText dump.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method error: aString
|
|
|
|
{
|
|
|
|
self class error: aString.
|
|
|
|
}
|
|
|
|
|
2016-05-03 10:10:28 +00:00
|
|
|
#method cannotInstantiate
|
|
|
|
{
|
|
|
|
self class cannotInstantiate
|
|
|
|
}
|
2015-10-08 14:26:04 +00:00
|
|
|
}
|
2016-05-13 15:10:34 +00:00
|
|
|
|
|
|
|
#class Object(Apex)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#class UndefinedObject(Apex)
|
|
|
|
{
|
|
|
|
#method isNil
|
|
|
|
{
|
|
|
|
^true
|
|
|
|
}
|
|
|
|
|
|
|
|
#method notNil
|
|
|
|
{
|
|
|
|
^false.
|
|
|
|
}
|
2016-06-22 13:43:49 +00:00
|
|
|
|
|
|
|
#method handleException: exception
|
|
|
|
{
|
2016-12-13 15:18:19 +00:00
|
|
|
('### EXCEPTION NOT HANDLED #### ' & exception class name & ' - ' & exception messageText) dump.
|
2016-06-22 13:43:49 +00:00
|
|
|
## TODO: debug the current process???? "
|
|
|
|
## TODO: ensure to execute ensure blocks as well....
|
2016-06-23 15:35:28 +00:00
|
|
|
####Processor activeProcess terminate.
|
2016-06-22 13:43:49 +00:00
|
|
|
}
|
2016-05-13 15:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|