2015-10-08 14:26:04 +00:00
|
|
|
#class Collection(Object)
|
|
|
|
{
|
|
|
|
}
|
2016-05-13 15:10:34 +00:00
|
|
|
|
|
|
|
## -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#class(#pointer) Array(Collection)
|
|
|
|
{
|
|
|
|
#method size
|
|
|
|
{
|
|
|
|
^self basicSize.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method ubound
|
|
|
|
{
|
|
|
|
^(self basicSize - 1).
|
|
|
|
}
|
|
|
|
|
|
|
|
#method at: anInteger
|
|
|
|
{
|
|
|
|
^self basicAt: anInteger.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method at: anInteger put: aValue
|
|
|
|
{
|
|
|
|
^self basicAt: anInteger put: aValue.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method first
|
|
|
|
{
|
|
|
|
^self at: 0.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method last
|
|
|
|
{
|
|
|
|
^self at: (self ubound).
|
|
|
|
}
|
|
|
|
|
|
|
|
#method do: aBlock
|
|
|
|
{
|
|
|
|
0 to: (self ubound) do: [:i | aBlock value: (self at: i)].
|
|
|
|
}
|
|
|
|
|
|
|
|
#method copy: anArray
|
|
|
|
{
|
|
|
|
0 to: (anArray ubound) do: [:i | self at: i put: (anArray at: i) ].
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#class(#character) String(Array)
|
|
|
|
{
|
2016-12-13 15:18:19 +00:00
|
|
|
#method & aString
|
2016-05-13 15:10:34 +00:00
|
|
|
{
|
|
|
|
## concatenate two strings.
|
|
|
|
## TOOD: make this a primitive for performance.
|
2016-06-13 15:52:09 +00:00
|
|
|
| newsize newstr self_ubound |
|
2016-06-22 03:23:14 +00:00
|
|
|
|
2016-05-13 15:10:34 +00:00
|
|
|
newsize := self basicSize + aString basicSize.
|
|
|
|
##newstr := self class basicNew: newsize.
|
2016-06-13 15:52:09 +00:00
|
|
|
newstr := String basicNew: newsize. ## TODO: redefine , for symbol... it's a work arouind... symbols are not concatenated to a symbol at this moment.
|
2016-05-13 15:10:34 +00:00
|
|
|
self_ubound := self ubound.
|
2016-06-22 03:23:14 +00:00
|
|
|
|
|
|
|
0 to: self_ubound do: [:i | newstr at: i put: (self at: i) ].
|
|
|
|
0 to: (aString ubound) do: [:i | newstr at: (i + self_ubound + 1) put: (aString at: i) ].
|
|
|
|
|
2016-05-13 15:10:34 +00:00
|
|
|
^newstr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#class(#character) Symbol(String)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#class(#byte) ByteArray(Collection)
|
|
|
|
{
|
|
|
|
#method at: anInteger
|
|
|
|
{
|
|
|
|
^self basicAt: anInteger.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method at: anInteger put: aValue
|
|
|
|
{
|
|
|
|
^self basicAt: anInteger put: aValue.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## -------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#class Set(Collection)
|
|
|
|
{
|
|
|
|
#dcl tally bucket.
|
|
|
|
}
|
|
|
|
|
|
|
|
#class SymbolSet(Set)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#class Dictionary(Set)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-30 13:44:37 +00:00
|
|
|
#pooldic Log
|
2016-05-13 15:10:34 +00:00
|
|
|
{
|
2016-06-30 13:44:37 +00:00
|
|
|
## -----------------------------------------------------------
|
2016-07-01 16:31:47 +00:00
|
|
|
## defines log levels
|
2016-06-30 13:44:37 +00:00
|
|
|
## these items must follow defintions in stix.h
|
|
|
|
## -----------------------------------------------------------
|
2016-07-01 16:31:47 +00:00
|
|
|
|
2016-06-30 13:44:37 +00:00
|
|
|
#DEBUG := 1.
|
|
|
|
#INFO := 2.
|
|
|
|
#WARN := 4.
|
|
|
|
#ERROR := 8.
|
|
|
|
#FATAL := 16.
|
2016-05-13 15:10:34 +00:00
|
|
|
}
|
|
|
|
|
2016-06-30 13:44:37 +00:00
|
|
|
#class SystemDictionary(Dictionary)
|
|
|
|
{
|
|
|
|
## the following methods may not look suitable to be placed
|
|
|
|
## inside a system dictionary. but they are here for quick and dirty
|
|
|
|
## output production from the stix code.
|
|
|
|
## System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'.
|
|
|
|
##
|
|
|
|
|
|
|
|
#dcl(#pooldic) Log.
|
|
|
|
|
2016-07-01 16:31:47 +00:00
|
|
|
#method atLevel: level log: message
|
|
|
|
{
|
|
|
|
<primitive: #_log>
|
|
|
|
## do nothing upon logging failure
|
|
|
|
}
|
|
|
|
|
|
|
|
#method atLevel: level log: message and: message2
|
|
|
|
{
|
|
|
|
<primitive: #_log>
|
|
|
|
## do nothing upon logging failure
|
|
|
|
}
|
|
|
|
|
|
|
|
#method atLevel: level log: message and: message2 and: message3
|
2016-06-30 13:44:37 +00:00
|
|
|
{
|
|
|
|
<primitive: #_log>
|
|
|
|
## do nothing upon logging failure
|
|
|
|
}
|
|
|
|
|
2016-07-01 16:31:47 +00:00
|
|
|
#method atLevel: level logNl: message
|
2016-06-30 13:44:37 +00:00
|
|
|
{
|
2016-07-01 16:31:47 +00:00
|
|
|
## the #_log primitive accepts an array.
|
|
|
|
## so the following lines should work also.
|
|
|
|
## | x |
|
|
|
|
## x := Array new: 2.
|
|
|
|
## x at: 0 put: message.
|
|
|
|
## x at: 1 put: S'\n'.
|
|
|
|
## ^self atLevel: level log: x.
|
|
|
|
|
|
|
|
^self atLevel: level log: message and: S'\n'.
|
|
|
|
}
|
|
|
|
|
|
|
|
#method atLevel: level logNl: message and: message2
|
|
|
|
{
|
|
|
|
^self atLevel: level log: message and: message2 and: S'\n'.
|
2016-06-30 13:44:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#method log: message
|
|
|
|
{
|
2016-07-01 16:31:47 +00:00
|
|
|
^self atLevel: Log.INFO log: message.
|
2016-06-30 13:44:37 +00:00
|
|
|
}
|
|
|
|
|
2016-07-04 15:36:10 +00:00
|
|
|
#method log: message and: message2
|
|
|
|
{
|
|
|
|
^self atLevel: Log.INFO log: message and: message2.
|
|
|
|
}
|
|
|
|
|
2016-06-30 13:44:37 +00:00
|
|
|
#method logNl: message
|
|
|
|
{
|
2016-07-01 16:31:47 +00:00
|
|
|
^self atLevel: Log.INFO logNl: message.
|
2016-06-30 13:44:37 +00:00
|
|
|
}
|
2016-07-04 15:36:10 +00:00
|
|
|
|
|
|
|
#method logNl: message and: message2
|
|
|
|
{
|
|
|
|
^self atLevel: Log.INFO logNl: message and: message2.
|
|
|
|
}
|
2016-06-30 13:44:37 +00:00
|
|
|
}
|
2016-05-13 15:10:34 +00:00
|
|
|
|
|
|
|
#class Namespace(Set)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#class PoolDictionary(Set)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#class MethodDictionary(Dictionary)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-07-01 16:31:47 +00:00
|
|
|
#extend Apex
|
|
|
|
{
|
|
|
|
## -------------------------------------------------------
|
|
|
|
## Association has been defined now. let's add association
|
|
|
|
## creating methods
|
|
|
|
## -------------------------------------------------------
|
|
|
|
|
|
|
|
#method(#class) -> object
|
|
|
|
{
|
|
|
|
^Association new key: self value: object
|
|
|
|
}
|
|
|
|
|
|
|
|
#method -> object
|
|
|
|
{
|
|
|
|
^Association new key: self value: object
|
|
|
|
}
|
|
|
|
}
|