changed some directives from symbols to plain words including class, method, pooldic, dcl.

introduced stix_pfrc_t as a return code type from a primitive function
This commit is contained in:
hyunghwan.chung 2017-01-06 09:53:40 +00:00
parent af9c144a1c
commit 7779229b52
32 changed files with 1099 additions and 1337 deletions

View File

@ -1,16 +1,16 @@
#class Apex(nil) class Apex(nil)
{ {
#dcl(#class) sysdic. dcl(#class) sysdic.
## ------------------------------------------------------- ## -------------------------------------------------------
## ------------------------------------------------------- ## -------------------------------------------------------
#method(#class) dump method(#class) dump
{ {
<primitive: #_dump> <primitive: #_dump>
} }
#method dump method dump
{ {
<primitive: #_dump> <primitive: #_dump>
} }
@ -18,12 +18,12 @@
## ------------------------------------------------------- ## -------------------------------------------------------
## ------------------------------------------------------- ## -------------------------------------------------------
#method(#class) yourself method(#class) yourself
{ {
^self. ^self.
} }
#method yourself method yourself
{ {
^self. ^self.
} }
@ -31,31 +31,31 @@
## ------------------------------------------------------- ## -------------------------------------------------------
## ------------------------------------------------------- ## -------------------------------------------------------
#method(#class) basicNew method(#class) basicNew
{ {
<primitive: #_basic_new> <primitive: #_basic_new>
self primitiveFailed. self primitiveFailed.
} }
#method(#class) basicNew: anInteger method(#class) basicNew: anInteger
{ {
<primitive: #_basic_new_with_size> <primitive: #_basic_new_with_size>
self primitiveFailed. self primitiveFailed.
} }
#method(#class) ngcNew method(#class) ngcNew
{ {
<primitive: #_ngc_new> <primitive: #_ngc_new>
self primitiveFailed. self primitiveFailed.
} }
#method(#class) ngcNew: anInteger method(#class) ngcNew: anInteger
{ {
<primitive: #_ngc_new_with_size> <primitive: #_ngc_new_with_size>
self primitiveFailed. self primitiveFailed.
} }
#method(#class) new method(#class) new
{ {
| x | | x |
x := self basicNew. x := self basicNew.
@ -63,7 +63,7 @@
^x. ^x.
} }
#method(#class) new: anInteger method(#class) new: anInteger
{ {
| x | | x |
## TODO: check if the class is a fixed class. ## TODO: check if the class is a fixed class.
@ -73,20 +73,20 @@
^x. ^x.
} }
#method initialize method initialize
{ {
"a subclass may override this method." "a subclass may override this method."
^self. ^self.
} }
#method ngcDispose method ngcDispose
{ {
<primitive: #_ngc_dispose> <primitive: #_ngc_dispose>
self primitiveFailed. self primitiveFailed.
} }
## ------------------------------------------------------- ## -------------------------------------------------------
## ------------------------------------------------------- ## -------------------------------------------------------
#method shallowCopy method shallowCopy
{ {
<primitive: #_shallow_copy> <primitive: #_shallow_copy>
self primitiveFailed. self primitiveFailed.
@ -95,12 +95,12 @@
## ------------------------------------------------------- ## -------------------------------------------------------
## ------------------------------------------------------- ## -------------------------------------------------------
#method class method class
{ {
<primitive: #_class> <primitive: #_class>
} }
#method(#class) class method(#class) class
{ {
<primitive: #_class> <primitive: #_class>
^Class ^Class
@ -109,123 +109,152 @@
## ------------------------------------------------------- ## -------------------------------------------------------
## ------------------------------------------------------- ## -------------------------------------------------------
#method basicSize method basicSize
{ {
<primitive: #_basic_size> <primitive: #_basic_size>
self primitiveFailed. self primitiveFailed.
} }
#method(#class) basicSize method(#class) basicSize
{ {
<primitive: #_basic_size> <primitive: #_basic_size>
self primitiveFailed. self primitiveFailed.
} }
#method basicAt: index method basicAt: index
{ {
<primitive: #_basic_at> <primitive: #_basic_at>
self index: index outOfRange: (self basicSize). self index: index outOfRange: (self basicSize).
} }
#method basicAt: index put: anObject method basicAt: index put: anObject
{ {
<primitive: #_basic_at_put> <primitive: #_basic_at_put>
self index: index outOfRange: (self basicSize). self index: index outOfRange: (self basicSize).
} }
#method(#class) basicAt: index method(#class) basicAt: index
{ {
<primitive: #_basic_at> <primitive: #_basic_at>
self index: index outOfRange: (self basicSize). self index: index outOfRange: (self basicSize).
} }
#method(#class) basicAt: index put: anObject method(#class) basicAt: index put: anObject
{ {
<primitive: #_basic_at_put> <primitive: #_basic_at_put>
self index: index outOfRange: (self basicSize). self index: index outOfRange: (self basicSize).
} }
## ------------------------------------------------------- (* ------------------------------------------------------------------
## ------------------------------------------------------- * HASHING
#method(#class) hash * ------------------------------------------------------------------ *)
{ method hash
<primitive: #_hash>
self subclassResponsibility: #hash
}
#method hash
{ {
<primitive: #_hash> <primitive: #_hash>
self subclassResponsibility: #hash self subclassResponsibility: #hash
} }
## ------------------------------------------------------- method(#class) hash
## ------------------------------------------------------- {
<primitive: #_hash>
self subclassResponsibility: #hash
}
#method == anObject (* ------------------------------------------------------------------
* IDENTITY TEST
* ------------------------------------------------------------------ *)
method == anObject
{ {
(* 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 *)
<primitive: #_identical> <primitive: #_identical>
self primitiveFailed.
} }
#method ~~ anObject method ~~ anObject
{ {
<primitive: #_not_identical> <primitive: #_not_identical>
^(self == anObject) not. ^(self == anObject) not.
} }
#method(#class) == anObject method(#class) == anObject
{ {
(* 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 *)
<primitive: #_identical> <primitive: #_identical>
self primitiveFailed.
} }
#method(#class) ~~ anObject method(#class) ~~ anObject
{ {
<primitive: #_not_identical> <primitive: #_not_identical>
^(self == anObject) not. ^(self == anObject) not.
} }
## TODO: add = and ~= for equality check. (* ------------------------------------------------------------------
* EQUALITY TEST
* ------------------------------------------------------------------ *)
method = anObject
{
<primitive: #_equal>
self subclassResponsibility: #=
}
method ~= anObject
{
<primitive: #_not_equal>
^(self = anObject) not.
}
## ------------------------------------------------------- method(#class) = anObject
## COMMON QUERIES {
## ------------------------------------------------------- <primitive: #_equal>
self subclassResponsibility: #=
}
#method isNil method(#class) ~= anObject
{
<primitive: #_not_equal>
^(self = anObject) not.
}
(* ------------------------------------------------------------------
* COMMON QUERIES
* ------------------------------------------------------------------ *)
method isNil
{ {
"^self == nil." "^self == nil."
^false ^false
} }
#method notNil method notNil
{ {
"^(self == nil) not" "^(self == nil) not"
"^self ~= nil." "^self ~= nil."
^true. ^true.
} }
#method(#class) isNil method(#class) isNil
{ {
"^self == nil." "^self == nil."
^false ^false
} }
#method(#class) notNil method(#class) notNil
{ {
"^(self == nil) not" "^(self == nil) not"
"^self ~= nil." "^self ~= nil."
^true. ^true.
} }
#method isError method isError
{ {
^false ^false
} }
#method(#class) isError method(#class) isError
{ {
^false ^false
} }
@ -233,7 +262,7 @@
## ------------------------------------------------------- ## -------------------------------------------------------
## ------------------------------------------------------- ## -------------------------------------------------------
#method(#class) inheritsFrom: aClass method(#class) inheritsFrom: aClass
{ {
| c | | c |
c := self superclass. c := self superclass.
@ -244,7 +273,7 @@
^false ^false
} }
#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,
@ -253,109 +282,103 @@
^aClass == Class ^aClass == Class
} }
#method(#class) isKindOf: aClass method(#class) isKindOf: aClass
{ {
^(self isMemberOf: aClass) or: [self inheritsFrom: aClass]. ^(self isMemberOf: aClass) or: [self inheritsFrom: aClass].
} }
#method isMemberOf: aClass method isMemberOf: aClass
{ {
^self class == aClass ^self class == aClass
} }
#method isKindOf: aClass method isKindOf: aClass
{ {
^(self isMemberOf: aClass) or: [self class inheritsFrom: aClass]. ^(self isMemberOf: aClass) or: [self class inheritsFrom: aClass].
} }
## ------------------------------------------------------- (* -----------------
## ------------------------------------------------------- method(#class) respondsTo: selectorSymbol
"
#method(#class) respondsTo: selectorSymbol
{ {
TODO: find selectorSymbol in the class method dictionary... TODO: find selectorSymbol in the class method dictionary...
} }
#method respondsTo: selectorSymbol method respondsTo: selectorSymbol
{ {
TODO: find selectorSymbol in the method dictionary... TODO: find selectorSymbol in the method dictionary...
} }
" ------------ *)
## ------------------------------------------------------- method exceptionizeError: trueOrFalse
{
<primitive: #_exceptionize_error>
self class cannotExceptionizeError
}
## method(#class) primitiveFailed (* ------------------------------------------------------------------
## { * COMMON ERROR/EXCEPTION HANDLERS
## this method will be added after Exception class has been defined. * ------------------------------------------------------------------ *)
## } method primitiveFailed
#method primitiveFailed
{ {
self class primitiveFailed. self class primitiveFailed.
} }
#method doesNotUnderstand: messageSymbol method doesNotUnderstand: messageSymbol
{ {
self class doesNotUnderstand: messageSymbol self class doesNotUnderstand: messageSymbol
} }
#method(#class) error: msgText method index: index outOfRange: ubound
{
self class index: index outOfRange: ubound.
}
method cannotInstantiate
{
self class cannotInstantiate
}
method subclassResponsibility: message_name
{
self class subclassResponsibility: message_name
}
method cannotExceptionizeError
{
self class cannotExceptionizeError
}
method(#class) error: msgText
{ {
## TODO: implement this ## TODO: implement this
## Error signal: msgText. ## Error signal: msgText.
msgText dump. msgText dump.
} }
#method error: aString method error: aString
{ {
self class error: aString. self class error: aString.
} }
#method index: index outOfRange: ubound
{
self class index: index outOfRange: ubound.
} }
#method cannotInstantiate class Object(Apex)
{
self class cannotInstantiate
}
#method subclassResponsibility: message_name
{
self class subclassResponsibility: message_name
}
#method cannotExceptionizeError
{
self class cannotExceptionizeError
}
#method exceptionizeError: trueOrFalse
{
<primitive: #_exceptionize_error>
self class cannotExceptionizeError
}
}
#class Object(Apex)
{ {
} }
#class UndefinedObject(Apex) class UndefinedObject(Apex)
{ {
#method isNil method isNil
{ {
^true ^true
} }
#method notNil method notNil
{ {
^false. ^false.
} }
#method handleException: exception method handleException: exception
{ {
('### EXCEPTION NOT HANDLED #### ' & exception class name & ' - ' & exception messageText) dump. ('### EXCEPTION NOT HANDLED #### ' & exception class name & ' - ' & exception messageText) dump.
## TODO: debug the current process???? " ## TODO: debug the current process???? "
@ -365,7 +388,7 @@
} }
#pooldic ErrorCode pooldic ErrorCode
{ {
(* migrate it into Error class *) (* migrate it into Error class *)
#NONE := error(0). #NONE := error(0).
@ -373,7 +396,7 @@
#NOENT := error(2). #NOENT := error(2).
} }
#class Error(Apex) class Error(Apex)
{ {
(* ---------------------------- (* ----------------------------
TODO: support constant declaration... TODO: support constant declaration...
@ -385,22 +408,22 @@
} }
-------------------------------- *) -------------------------------- *)
#method isError method isError
{ {
^true ^true
} }
#method asInteger method asInteger
{ {
<primitive: #_error_as_integer> <primitive: #_error_as_integer>
} }
#method asCharacter method asCharacter
{ {
<primitive: #_error_as_character> <primitive: #_error_as_character>
} }
#method asString method asString
{ {
<primitive: #_error_as_string> <primitive: #_error_as_string>
} }

View File

@ -1,90 +1,90 @@
#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)
{ {
#method not method not
{ {
^false ^false
} }
#method & aBoolean method & aBoolean
{ {
^aBoolean ^aBoolean
} }
#method | aBoolean method | aBoolean
{ {
^true ^true
} }
#method and: aBlock method and: aBlock
{ {
^aBlock value ^aBlock value
} }
#method or: aBlock method or: aBlock
{ {
^true ^true
} }
#method ifTrue: trueBlock ifFalse: falseBlock method ifTrue: trueBlock ifFalse: falseBlock
{ {
^trueBlock value. ^trueBlock value.
} }
#method ifTrue: trueBlock method ifTrue: trueBlock
{ {
^trueBlock value. ^trueBlock value.
} }
#method ifFalse: falseBlock method ifFalse: falseBlock
{ {
^nil. ^nil.
} }
} }
#class False(Boolean) class False(Boolean)
{ {
#method not method not
{ {
^true ^true
} }
#method & aBoolean method & aBoolean
{ {
^false ^false
} }
#method | aBoolean method | aBoolean
{ {
^aBoolean ^aBoolean
} }
#method and: aBlock method and: aBlock
{ {
^false ^false
} }
#method or: aBlock method or: aBlock
{ {
^aBlock value ^aBlock value
} }
#method ifTrue: trueBlock ifFalse: falseBlock method ifTrue: trueBlock ifFalse: falseBlock
{ {
^falseBlock value. ^falseBlock value.
} }
#method ifTrue: trueBlock method ifTrue: trueBlock
{ {
^nil. ^nil.
} }
#method ifFalse: falseBlock method ifFalse: falseBlock
{ {
^falseBlock value. ^falseBlock value.
} }

View File

@ -2,45 +2,42 @@
## the Class object should be a variable-pointer object because ## the Class object should be a variable-pointer object because
## it needs to accomodate class instance variables. ## it needs to accomodate class instance variables.
## ##
#class(#pointer) Class(Apex) class(#pointer) Class(Apex)
{ {
#dcl spec selfspec superclass subclasses name instvars classvars classinstvars pooldics instmthdic classmthdic. dcl spec selfspec superclass subclasses name instvars classvars classinstvars pooldics instmthdic classmthdic.
#method(#class) basicNew method(#class) basicNew
{ {
## you must not instantiate a new class this way. ## you must not instantiate a new class this way.
self cannotInstantiate. self cannotInstantiate.
} }
#method(#class) initialize method(#class) initialize
{ {
^self. ^self.
} }
(* most of the following methods can actually become class methods of Apex.
* if the instance varibles can be made accessible from the Apex class. *)
## ######################################################################## method name
## most of the following methods can actually become class methods of Apex.
## if the instance varibles can be made accessible from the Apex class.
## ########################################################################
#method name
{ {
^self.name ^self.name
} }
#method superclass method superclass
{ {
^self.superclass ^self.superclass
} }
#method specNumInstVars method specNumInstVars
{ {
## shift right by 7 bits. ## shift right by 7 bits.
## see stix-prv.h for details. ## see stix-prv.h for details.
^self.spec bitShift: -7 ^self.spec bitShift: -7
} }
"#method inheritsFrom: aSuperclass (*method inheritsFrom: aSuperclass
{ {
| c | | c |
c := self superclass. c := self superclass.
@ -49,5 +46,5 @@
c := c superclass. c := c superclass.
]. ].
^false ^false
}" }*)
} }

View File

@ -1,57 +1,52 @@
#class Collection(Object)
class Collection(Object)
{ {
} }
## ------------------------------------------------------------------------------- ## -------------------------------------------------------------------------------
class(#pointer) Array(Collection)
#class(#pointer) Array(Collection)
{ {
#method size method size
{ {
^self basicSize. ^self basicSize
} }
#method ubound method at: anInteger
{
^(self basicSize - 1).
}
#method at: anInteger
{ {
^self basicAt: anInteger. ^self basicAt: anInteger.
} }
#method at: anInteger put: aValue method at: anInteger put: aValue
{ {
^self basicAt: anInteger put: aValue. ^self basicAt: anInteger put: aValue.
} }
#method first method first
{ {
^self at: 0. ^self at: 0.
} }
#method last method last
{ {
^self at: (self ubound). ^self at: (self basicSize - 1).
} }
#method do: aBlock method do: aBlock
{ {
0 to: (self ubound) do: [:i | aBlock value: (self at: i)]. 0 priorTo: (self basicSize) do: [:i | aBlock value: (self at: i)].
} }
#method copy: anArray method copy: anArray
{ {
0 to: (anArray ubound) do: [:i | self at: i put: (anArray at: i) ]. 0 priorTo: (anArray basicSize) do: [:i | self at: i put: (anArray at: i) ].
} }
} }
## ------------------------------------------------------------------------------- ## -------------------------------------------------------------------------------
#class(#character) String(Array) class(#character) String(Array)
{ {
#method & string method & string
{ {
(* TOOD: make this a primitive for performance. *) (* TOOD: make this a primitive for performance. *)
@ -70,7 +65,7 @@
^newstr ^newstr
} }
#method asString method asString
{ {
^self ^self
} }
@ -78,9 +73,9 @@
## ------------------------------------------------------------------------------- ## -------------------------------------------------------------------------------
#class(#character) Symbol(String) class(#character) Symbol(String)
{ {
#method asString method asString
{ {
(* TODO: make this a primitive for performance *) (* TODO: make this a primitive for performance *)
@ -96,14 +91,14 @@
## ------------------------------------------------------------------------------- ## -------------------------------------------------------------------------------
#class(#byte) ByteArray(Collection) class(#byte) ByteArray(Collection)
{ {
#method at: anInteger method at: anInteger
{ {
^self basicAt: anInteger. ^self basicAt: anInteger.
} }
#method at: anInteger put: aValue method at: anInteger put: aValue
{ {
^self basicAt: anInteger put: aValue. ^self basicAt: anInteger put: aValue.
} }
@ -111,22 +106,22 @@
## ------------------------------------------------------------------------------- ## -------------------------------------------------------------------------------
#class Set(Collection) class Set(Collection)
{ {
#dcl tally bucket. dcl tally bucket.
#method initialize method initialize
{ {
self.tally := 0. self.tally := 0.
self.bucket := Array new: 100. self.bucket := Array new: 100.
} }
#method size method size
{ {
^self.tally ^self.tally
} }
#method at: key method at: key
{ {
| ass | | ass |
ass := self __find: key or_upsert: false with: nil. ass := self __find: key or_upsert: false with: nil.
@ -134,7 +129,7 @@
^ErrorCode.NOENT ^ErrorCode.NOENT
} }
#method at: key ifAbsent: error_block method at: key ifAbsent: error_block
{ {
| ass | | ass |
ass := self __find: key or_upsert: false with: nil. ass := self __find: key or_upsert: false with: nil.
@ -142,13 +137,13 @@
^error_block value. ^error_block value.
} }
#method at: key put: value method at: key put: value
{ {
self __find: key or_upsert: true with: value. self __find: key or_upsert: true with: value.
^value ^value
} }
#method __find: key or_upsert: upsert with: value method __find: key or_upsert: upsert with: value
{ {
| hv ass bs index ntally | | hv ass bs index ntally |
@ -158,7 +153,7 @@
[(ass := self.bucket at: index) notNil] [(ass := self.bucket at: index) notNil]
whileTrue: [ whileTrue: [
[key == ass key] ifTrue: [ [key == ass key] ifTrue: [ (* TODO: change it to equality??? *)
(* found *) (* found *)
upsert ifTrue: [ass value: value]. upsert ifTrue: [ass value: value].
^ass ^ass
@ -181,7 +176,7 @@
^ass ^ass
} }
#method do: block method do: block
{ {
| bs | | bs |
@ -192,7 +187,7 @@
]. ].
} }
#method keysAndValuesDo: block method keysAndValuesDo: block
{ {
| bs | | bs |
@ -204,15 +199,15 @@
} }
} }
#class SymbolSet(Set) class SymbolSet(Set)
{ {
} }
#class Dictionary(Set) class Dictionary(Set)
{ {
} }
#pooldic Log pooldic Log
{ {
## ----------------------------------------------------------- ## -----------------------------------------------------------
## defines log levels ## defines log levels
@ -226,7 +221,7 @@
#FATAL := 16. #FATAL := 16.
} }
#class SystemDictionary(Dictionary) class SystemDictionary(Dictionary)
{ {
## the following methods may not look suitable to be placed ## the following methods may not look suitable to be placed
## inside a system dictionary. but they are here for quick and dirty ## inside a system dictionary. but they are here for quick and dirty
@ -234,27 +229,27 @@
## System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'. ## System logNl: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'.
## ##
#dcl(#pooldic) Log. dcl(#pooldic) Log.
#method atLevel: level log: message method atLevel: level log: message
{ {
<primitive: #_log> <primitive: #_log>
## do nothing upon logging failure ## do nothing upon logging failure
} }
#method atLevel: level log: message and: message2 method atLevel: level log: message and: message2
{ {
<primitive: #_log> <primitive: #_log>
## do nothing upon logging failure ## do nothing upon logging failure
} }
#method atLevel: level log: message and: message2 and: message3 method atLevel: level log: message and: message2 and: message3
{ {
<primitive: #_log> <primitive: #_log>
## do nothing upon logging failure ## do nothing upon logging failure
} }
#method atLevel: level logNl: message method atLevel: level logNl: message
{ {
## the #_log primitive accepts an array. ## the #_log primitive accepts an array.
## so the following lines should work also. ## so the following lines should work also.
@ -267,58 +262,64 @@
^self atLevel: level log: message and: S'\n'. ^self atLevel: level log: message and: S'\n'.
} }
#method atLevel: level logNl: message and: message2 method atLevel: level logNl: message and: message2
{ {
^self atLevel: level log: message and: message2 and: S'\n'. ^self atLevel: level log: message and: message2 and: S'\n'.
} }
#method log: message method log: message
{ {
^self atLevel: Log.INFO log: message. ^self atLevel: Log.INFO log: message.
} }
#method log: message and: message2 method log: message and: message2
{ {
^self atLevel: Log.INFO log: message and: message2. ^self atLevel: Log.INFO log: message and: message2.
} }
#method logNl: message method logNl: message
{ {
^self atLevel: Log.INFO logNl: message. ^self atLevel: Log.INFO logNl: message.
} }
#method logNl: message and: message2 method logNl: message and: message2
{ {
^self atLevel: Log.INFO logNl: message and: message2. ^self atLevel: Log.INFO logNl: message and: message2.
} }
method at: key
{
(key class = Symbol) ifTrue: [InvalidArgumentException signal: 'argument is not a symbol'].
^super at: key.
}
} }
#class Namespace(Set) class Namespace(Set)
{ {
} }
#class PoolDictionary(Set) class PoolDictionary(Set)
{ {
} }
#class MethodDictionary(Dictionary) class MethodDictionary(Dictionary)
{ {
} }
#extend Apex extend Apex
{ {
## ------------------------------------------------------- ## -------------------------------------------------------
## Association has been defined now. let's add association ## Association has been defined now. let's add association
## creating methods ## creating methods
## ------------------------------------------------------- ## -------------------------------------------------------
#method(#class) -> object method(#class) -> object
{ {
^Association new key: self value: object ^Association new key: self value: object
} }
#method -> object method -> object
{ {
^Association new key: self value: object ^Association new key: self value: object
} }

View File

@ -1,46 +1,46 @@
#class Point(Object) class Point(Object)
{ {
#dcl x y. dcl x y.
#method(#class) new method(#class) new
{ {
^self basicNew x: 0 y: 0. ^self basicNew x: 0 y: 0.
} }
#method(#class) x: x y: y method(#class) x: x y: y
{ {
^self basicNew x: x y: y. ^self basicNew x: x y: y.
} }
#method x method x
{ {
^self.x ^self.x
} }
#method y method y
{ {
^self.y ^self.y
} }
#method x: x method x: x
{ {
self.x := x self.x := x
} }
#method y: y method y: y
{ {
self.y := y self.y := y
} }
#method x: x y: y method x: x y: y
{ {
self.x := x. self.x := x.
self.y := y self.y := y
} }
} }
#extend SmallInteger extend SmallInteger
{ {
#method @ y method @ y
{ {
^Point x: self y: y ^Point x: self y: y
} }
@ -49,11 +49,11 @@
#class Console(Object) class Console(Object)
{ {
#dcl handle. dcl handle.
" "
#method finalize method finalize
{ {
handle notNil ifTrue: [ handle notNil ifTrue: [
self _close: handle. self _close: handle.
@ -62,12 +62,12 @@
" "
## #method(#class) input ## method(#class) input
## { ## {
## ^self new _open: filename mode: mode ## ^self new _open: filename mode: mode
## } ## }
#method(#class) output method(#class) output
{ {
| c | | c |
@ -76,73 +76,73 @@
^c ^c
} }
## #method(#class) error ## method(#class) error
## { ## {
## } ## }
#method handle: v method handle: v
{ {
self.handle := v. self.handle := v.
} }
#method close method close
{ {
self _close: self.handle. self _close: self.handle.
self.handle := nil. self.handle := nil.
} }
#method write: text method write: text
{ {
^self _writeOn: self.handle text: text. ^self _writeOn: self.handle text: text.
} }
#method clear method clear
{ {
^self _clear: self.handle ^self _clear: self.handle
} }
#method setCursor: point method setCursor: point
{ {
^self _setCursor: self.handle point: point. ^self _setCursor: self.handle point: point.
} }
" "
#method _open: filename mode: mode method _open: filename mode: mode
{ {
self.handle := self __open: filename mode: mode. self.handle := self __open: filename mode: mode.
^self. ^self.
} }
#method __open: filename mode: mode method __open: filename mode: mode
{ {
<primitive: #console.open> <primitive: #console.open>
##StdioException signal: ('cannot open ' & filename). ##StdioException signal: ('cannot open ' & filename).
} }
" "
#method _open method _open
{ {
<primitive: #console.open> <primitive: #console.open>
} }
#method _close: handle method _close: handle
{ {
<primitive: #console.close> <primitive: #console.close>
self primitiveFailed. self primitiveFailed.
} }
#method _clear: handle method _clear: handle
{ {
<primitive: #console.clear> <primitive: #console.clear>
self primitiveFailed. self primitiveFailed.
} }
#method _writeOn: handle text: text method _writeOn: handle text: text
{ {
<primitive: #console.write> <primitive: #console.write>
self primitiveFailed. self primitiveFailed.
} }
#method _setCursor: handle point: point method _setCursor: handle point: point
{ {
<primitive: #console.setcursor> <primitive: #console.setcursor>
self primitiveFailed. self primitiveFailed.
@ -151,19 +151,19 @@
" "
#method(#class) open method(#class) open
{ {
<primitive: #console.open> <primitive: #console.open>
self primitiveFailed. self primitiveFailed.
} }
#method close method close
{ {
<primitive: #console.close> <primitive: #console.close>
self primitiveFailed. self primitiveFailed.
} }
#method setCursorTo: point method setCursorTo: point
{ {
<primitive: #console.setcursor> <primitive: #console.setcursor>
self primitiveFailed. self primitiveFailed.
@ -195,9 +195,9 @@ Stix define: 'console_write'
---> produces a method like this internally... ---> produces a method like this internally...
#class Console class Console
{ {
#method write: aString upto: length method write: aString upto: length
{ {
<ffi: int console_write (int*, char*, [int, int, char]* )> <== parse the string, create a descriptor table, key is console_write, value is resolved to a function pointer. <ffi: int console_write (int*, char*, [int, int, char]* )> <== parse the string, create a descriptor table, key is console_write, value is resolved to a function pointer.
} }

View File

@ -1,24 +1,24 @@
#class(#pointer) Context(Apex) class(#pointer) Context(Apex)
{ {
#dcl sender ip sp ntmprs. dcl sender ip sp ntmprs.
#method sender method sender
{ {
^self.sender ^self.sender
} }
#method isDead method isDead
{ {
^self.ip < 0 ^self.ip < 0
} }
#method temporaryCount method temporaryCount
{ {
^self.ntmprs ^self.ntmprs
} }
(* --------------------------------- (* ---------------------------------
#method varargCount method varargCount
{ {
method context, method context,
@ -30,7 +30,7 @@ for a block context, it must access homeContext first and call varargCount
^self.home varargCount... ^self.home varargCount...
} }
#method varargAt: index method varargAt: index
{ {
method context method context
^do calculation... ^do calculation...
@ -42,91 +42,91 @@ block context...
---------------------------------- *) ---------------------------------- *)
} }
#class(#pointer) MethodContext(Context) class(#pointer) MethodContext(Context)
{ {
#dcl method receiver home origin. dcl method receiver home origin.
#method pc method pc
{ {
^self.ip ^self.ip
} }
#method pcplus1 method pcplus1
{ {
^self.ip + 1 ^self.ip + 1
} }
#method goto: anInteger method goto: anInteger
{ {
<primitive: #_context_goto> <primitive: #_context_goto>
self primitiveFailed. ## TODO: need to make this a hard failure? self primitiveFailed. ## TODO: need to make this a hard failure?
} }
#method pc: anInteger method pc: anInteger
{ {
self.ip := anInteger. self.ip := anInteger.
} }
#method sp method sp
{ {
^self.sp. ^self.sp.
} }
#method sp: new_sp method sp: new_sp
{ {
self.sp := new_sp self.sp := new_sp
} }
#method pc: new_pc sp: new_sp method pc: new_pc sp: new_sp
{ {
self.ip := new_pc. self.ip := new_pc.
self.sp := new_sp. self.sp := new_sp.
} }
#method method method method
{ {
^self.method ^self.method
} }
#method vargCount method vargCount
{ {
^self basicSize - self class specNumInstVars - self.ntmprs ^self basicSize - self class specNumInstVars - self.ntmprs
} }
#method vargAt: index method vargAt: index
{ {
^self basicAt: (index + self class specNumInstVars + self.ntmprs) ^self basicAt: (index + self class specNumInstVars + self.ntmprs)
} }
} }
#class(#pointer) BlockContext(Context) class(#pointer) BlockContext(Context)
{ {
#dcl nargs source home origin. dcl nargs source home origin.
#method vargCount method vargCount
{ {
^self.home vargCount ^self.home vargCount
} }
#method vargAt: index method vargAt: index
{ {
^self.home vargAt: index ^self.home vargAt: index
} }
#method fork method fork
{ {
"crate a new process in the runnable state" "crate a new process in the runnable state"
^self newProcess resume. ^self newProcess resume.
} }
#method newProcess method newProcess
{ {
"create a new process in the suspended state" "create a new process in the suspended state"
<primitive: #_block_new_process> <primitive: #_block_new_process>
self primitiveFailed. self primitiveFailed.
} }
#method newProcessWith: anArray method newProcessWith: anArray
{ {
"create a new process in the suspended state passing the elements "create a new process in the suspended state passing the elements
of anArray as block arguments" of anArray as block arguments"
@ -134,53 +134,53 @@ block context...
self primitiveFailed. self primitiveFailed.
} }
#method value method value
{ {
<primitive: #_block_value> <primitive: #_block_value>
self primitiveFailed. self primitiveFailed.
} }
#method value: a method value: a
{ {
<primitive: #_block_value> <primitive: #_block_value>
self primitiveFailed. self primitiveFailed.
} }
#method value: a value: b method value: a value: b
{ {
<primitive: #_block_value> <primitive: #_block_value>
self primitiveFailed. self primitiveFailed.
} }
#method value: a value: b value: c method value: a value: b value: c
{ {
<primitive: #_block_value> <primitive: #_block_value>
self primitiveFailed. self primitiveFailed.
} }
#method value: a value: b value: c value: d method value: a value: b value: c value: d
{ {
<primitive: #_block_value> <primitive: #_block_value>
self primitiveFailed. self primitiveFailed.
} }
#method value: a value: b value: c value: d value: e method value: a value: b value: c value: d value: e
{ {
<primitive: #_block_value> <primitive: #_block_value>
self primitiveFailed. self primitiveFailed.
} }
#method ifTrue: aBlock method ifTrue: aBlock
{ {
^(self value) ifTrue: aBlock. ^(self value) ifTrue: aBlock.
} }
#method ifFalse: aBlock method ifFalse: aBlock
{ {
^(self value) ifFalse: aBlock. ^(self value) ifFalse: aBlock.
} }
#method ifTrue: trueBlock ifFalse: falseBlock method ifTrue: trueBlock ifFalse: falseBlock
{ {
^(self value) ifTrue: trueBlock ifFalse: falseBlock ^(self value) ifTrue: trueBlock ifFalse: falseBlock
} }
#method whileTrue: aBlock method whileTrue: aBlock
{ {
## -------------------------------------------------- ## --------------------------------------------------
## Naive implementation ## Naive implementation
@ -208,7 +208,7 @@ block context...
## -------------------------------------------------- ## --------------------------------------------------
} }
#method whileTrue method whileTrue
{ {
## (self value) ifFalse: [^nil]. ## (self value) ifFalse: [^nil].
## self whileTrue. ## self whileTrue.
@ -223,7 +223,7 @@ block context...
## -------------------------------------------------- ## --------------------------------------------------
} }
#method whileFalse: aBlock method whileFalse: aBlock
{ {
## -------------------------------------------------- ## --------------------------------------------------
## Naive implementation ## Naive implementation
@ -256,7 +256,7 @@ block context...
## -------------------------------------------------- ## --------------------------------------------------
} }
#method whileFalse method whileFalse
{ {
## (self value) ifTrue: [^nil]. ## (self value) ifTrue: [^nil].
## self whileFalse. ## self whileFalse.
@ -271,28 +271,55 @@ block context...
## -------------------------------------------------- ## --------------------------------------------------
} }
#method pc method pc
{ {
^self.ip ^self.ip
} }
#method pc: anInteger method pc: anInteger
{ {
self.ip := anInteger. self.ip := anInteger.
} }
#method sp method sp
{ {
^self.sp ^self.sp
} }
#method sp: anInteger method sp: anInteger
{ {
self.sp := anInteger. self.sp := anInteger.
} }
#method restart method restart
{ {
ip := self.source pc. ip := self.source pc.
} }
} }
class(#pointer) CompiledMethod(Object)
{
## dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs code source.
dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs source.
method preamble
{
^self.preamble
}
method preambleCode
{
^(self.preamble bitAnd: 16rFF) bitShift: -2.
}
method owner
{
^self.owner
}
method name
{
^self.name
}
}

View File

@ -4,42 +4,42 @@
## TODO: is it better to inherit from Object??? ## TODO: is it better to inherit from Object???
## or treat Exception specially like UndefinedObject or Class??? ## or treat Exception specially like UndefinedObject or Class???
## ##
#class Exception(Apex) class Exception(Apex)
{ {
#dcl signalContext handlerContext messageText. dcl signalContext handlerContext messageText.
#method(#class) signal method(#class) signal
{ {
^self new signal ^self new signal
} }
#method(#class) signal: text method(#class) signal: text
{ {
^self new signal: text ^self new signal: text
} }
#method handlerContext: context method handlerContext: context
{ {
self.handlerContext := context. self.handlerContext := context.
} }
#method messageText method messageText
{ {
^self.messageText ^self.messageText
} }
#method asString method asString
{ {
^(self class name) & ' - ' & self.messageText. ^(self class name) & ' - ' & self.messageText.
} }
#method __signal method __signal
{ {
self.signalContext := thisContext. self.signalContext := thisContext.
((thisContext sender) findExceptionContext) handleException: self. ((thisContext sender) findExceptionContext) handleException: self.
} }
#method signal method signal
{ {
| exctx exblk retval actpos | | exctx exblk retval actpos |
@ -74,26 +74,26 @@
thisProcess terminate. thisProcess terminate.
} }
#method signal: text method signal: text
{ {
self.messageText := text. self.messageText := text.
^self signal. ^self signal.
} }
#method pass method pass
{ {
## pass the exception to the outer context ## pass the exception to the outer context
((self.handlerContext sender) findExceptionContext) handleException: self. ((self.handlerContext sender) findExceptionContext) handleException: self.
} }
#method return: value method return: value
{ {
(self.handlerContext notNil) ifTrue: [ (self.handlerContext notNil) ifTrue: [
Processor return: value to: self.handlerContext. Processor return: value to: self.handlerContext.
]. ].
} }
#method retry method retry
{ {
## TODO: verify if return:to: causes unnecessary stack growth. ## TODO: verify if return:to: causes unnecessary stack growth.
(self.handlerContext notNil) ifTrue: [ (self.handlerContext notNil) ifTrue: [
@ -102,7 +102,7 @@
]. ].
} }
#method resume: value method resume: value
{ {
## TODO: verify if return:to: causes unnecessary stack growth. ## TODO: verify if return:to: causes unnecessary stack growth.
## is this correct??? ## is this correct???
@ -115,31 +115,31 @@
]. ].
} }
#method resume method resume
{ {
^self resume: nil. ^self resume: nil.
} }
} }
##============================================================================ ##============================================================================
#extend Context extend Context
{ {
#method isExceptionContext method isExceptionContext
{ {
^false ^false
} }
#method isEnsureContext method isEnsureContext
{ {
^false ^false
} }
#method ensureBlock method ensureBlock
{ {
^nil ^nil
} }
#method findExceptionContext method findExceptionContext
{ {
| ctx | | ctx |
ctx := self. ctx := self.
@ -150,7 +150,7 @@
^nil ^nil
} }
#method unwindTo: context return: retval method unwindTo: context return: retval
{ {
## ------------------------------------------------------------------- ## -------------------------------------------------------------------
## <<private>> ## <<private>>
@ -183,21 +183,21 @@
} }
##============================================================================ ##============================================================================
#extend MethodContext extend MethodContext
{ {
#method isExceptionContext method isExceptionContext
{ {
## 10 - STIX_METHOD_PREAMBLE_EXCEPTION in VM. ## 10 - STIX_METHOD_PREAMBLE_EXCEPTION in VM.
^self.method preambleCode == 10. ^self.method preambleCode == 10.
} }
#method isEnsureContext method isEnsureContext
{ {
## 10 - STIX_METHOD_PREAMBLE_ENSURE in VM. ## 10 - STIX_METHOD_PREAMBLE_ENSURE in VM.
^self.method preambleCode == 11 ^self.method preambleCode == 11
} }
#method ensureBlock method ensureBlock
{ {
## TODO: change 8 to a constant when stix is enhanced to support constant definition ## TODO: change 8 to a constant when stix is enhanced to support constant definition
@ -213,7 +213,7 @@
} }
#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.
* *
@ -242,7 +242,7 @@
^nil. ^nil.
} }
#method handleException: exception method handleException: exception
{ {
(* ----------------------------------------------------------------- (* -----------------------------------------------------------------
* <<private>> * <<private>>
@ -295,9 +295,9 @@
} }
##============================================================================ ##============================================================================
#extend BlockContext extend BlockContext
{ {
#method on: anException do: anExceptionBlock method on: anException do: anExceptionBlock
{ {
| exception_active | | exception_active |
<exception> <exception>
@ -314,7 +314,7 @@ thisContext isExceptionContext dump.
^self value. ^self value.
} }
#method on: exc1 do: blk1 on: exc2 do: blk2 method on: exc1 do: blk1 on: exc2 do: blk2
{ {
| exception_active | | exception_active |
<exception> <exception>
@ -322,7 +322,7 @@ thisContext isExceptionContext dump.
^self value. ^self value.
} }
#method ensure: aBlock method ensure: aBlock
{ {
| retval done | | retval done |
<ensure> <ensure>
@ -339,7 +339,7 @@ thisContext isExceptionContext dump.
^retval ^retval
} }
#method ifCurtailed: aBlock method ifCurtailed: aBlock
{ {
| v ok | | v ok |
@ -351,33 +351,37 @@ thisContext isExceptionContext dump.
##============================================================================ ##============================================================================
#class InstantiationFailureException(Exception) class InstantiationFailureException(Exception)
{ {
} }
#class NoSuchMessageException(Exception) class NoSuchMessageException(Exception)
{ {
} }
#class PrimitiveFailureException(Exception) class PrimitiveFailureException(Exception)
{ {
} }
#class IndexOutOfRangeException(Exception) class IndexOutOfRangeException(Exception)
{ {
} }
#class SubclassResponsibilityException(Exception) class SubclassResponsibilityException(Exception)
{ {
} }
#class ErrorExceptionizationFailureException(Exception) class InvalidArgumentException(Exception)
{ {
} }
#extend Apex class ErrorExceptionizationFailureException(Exception)
{ {
#method(#class) primitiveFailed }
extend Apex
{
method(#class) primitiveFailed
{ {
## TODO: implement this ## TODO: implement this
## experimental backtrace... ## experimental backtrace...
@ -393,29 +397,29 @@ ctx := thisContext.
PrimitiveFailureException signal: 'PRIMITIVE FAILED'. PrimitiveFailureException signal: 'PRIMITIVE FAILED'.
} }
#method(#class) cannotInstantiate method(#class) cannotInstantiate
{ {
## TOOD: accept a class ## TOOD: accept a class
InstantiationFailureException signal: 'Cannot instantiate'. InstantiationFailureException signal: 'Cannot instantiate'.
} }
#method(#class) doesNotUnderstand: message_name method(#class) doesNotUnderstand: message_name
{ {
## TODO: implement this properly ## TODO: implement this properly
NoSuchMessageException signal: (message_name & ' not understood by ' & (self name)). NoSuchMessageException signal: (message_name & ' not understood by ' & (self name)).
} }
#method(#class) index: index outOfRange: ubound method(#class) index: index outOfRange: ubound
{ {
IndexOutOfRangeException signal: 'Out of range'. IndexOutOfRangeException signal: 'Out of range'.
} }
#method(#class) subclassResponsibility: message_name method(#class) subclassResponsibility: message_name
{ {
SubclassResponsibilityException signal: ('Subclass must implment ' & message_name). SubclassResponsibilityException signal: ('Subclass must implment ' & message_name).
} }
#method(#class) cannotExceptionizeError method(#class) cannotExceptionizeError
{ {
## todo: accept the object ## todo: accept the object
ErrorExceptionizationFailureException signal: 'Cannot exceptionize an error' ErrorExceptionizationFailureException signal: 'Cannot exceptionize an error'

View File

@ -1,35 +1,35 @@
#class(#pointer) Process(Object) class(#pointer) Process(Object)
{ {
#dcl initial_context current_context state sp prev next sem. dcl initial_context current_context state sp prev next sem.
#method new method new
{ {
"instantiation is not allowed" "instantiation is not allowed"
^nil. "TODO: raise an exception" ^nil. "TODO: raise an exception"
} }
#method prev method prev
{ {
^self.prev. ^self.prev.
} }
#method next method next
{ {
^self.next. ^self.next.
} }
#method next: process method next: process
{ {
self.next := process. self.next := process.
} }
#method prev: process method prev: process
{ {
self.prev := process. self.prev := process.
} }
#method resume method resume
{ {
<primitive: #_process_resume> <primitive: #_process_resume>
self primitiveFailed self primitiveFailed
@ -37,19 +37,19 @@
##^Processor resume: self. ##^Processor resume: self.
} }
#method _terminate method _terminate
{ {
<primitive: #_process_terminate> <primitive: #_process_terminate>
self primitiveFailed self primitiveFailed
} }
#method _suspend method _suspend
{ {
<primitive: #_process_suspend> <primitive: #_process_suspend>
self primitiveFailed self primitiveFailed
} }
#method terminate method terminate
{ {
##search from the top contextof the process down to intial_contextand find ensure blocks and execute them. ##search from the top contextof the process down to intial_contextand find ensure blocks and execute them.
## if a different process calls 'terminate' on a process, ## if a different process calls 'terminate' on a process,
@ -80,28 +80,28 @@
^self _terminate ^self _terminate
} }
#method yield method yield
{ {
<primitive: #_process_yield> <primitive: #_process_yield>
self primitiveFailed self primitiveFailed
} }
#method sp method sp
{ {
^self.sp. ^self.sp.
} }
#method initialContext method initialContext
{ {
^self.initial_context ^self.initial_context
} }
} }
#class Semaphore(Object) class Semaphore(Object)
{ {
#dcl count waiting_head waiting_tail heapIndex fireTimeSec fireTimeNsec. dcl count waiting_head waiting_tail heapIndex fireTimeSec fireTimeNsec.
#method(#class) forMutualExclusion method(#class) forMutualExclusion
{ {
| sem | | sem |
sem := self new. sem := self new.
@ -109,7 +109,7 @@
^sem ^sem
} }
#method initialize method initialize
{ {
self.count := 0. self.count := 0.
self.heapIndex := -1. self.heapIndex := -1.
@ -119,31 +119,31 @@
## ================================================================== ## ==================================================================
#method signal method signal
{ {
<primitive: #_semaphore_signal> <primitive: #_semaphore_signal>
self primitiveFailed. self primitiveFailed.
} }
#method wait method wait
{ {
<primitive: #_semaphore_wait> <primitive: #_semaphore_wait>
self primitiveFailed. self primitiveFailed.
} }
#method waitWithTimeout: seconds method waitWithTimeout: seconds
{ {
<primitive: #_semaphore_wait> <primitive: #_semaphore_wait>
self primitiveFailed self primitiveFailed
} }
#method waitWithTimeout: seconds and: nanoSeconds method waitWithTimeout: seconds and: nanoSeconds
{ {
<primitive: #_semaphore_wait> <primitive: #_semaphore_wait>
self primitiveFailed self primitiveFailed
} }
#method critical: aBlock method critical: aBlock
{ {
self wait. self wait.
^aBlock ensure: [ self signal ] ^aBlock ensure: [ self signal ]
@ -151,53 +151,53 @@
## ================================================================== ## ==================================================================
#method heapIndex method heapIndex
{ {
^heapIndex ^heapIndex
} }
#method heapIndex: anIndex method heapIndex: anIndex
{ {
heapIndex := anIndex heapIndex := anIndex
} }
#method fireTime method fireTime
{ {
^fireTimeSec ^fireTimeSec
} }
#method fireTime: anInteger method fireTime: anInteger
{ {
self.fireTimeSec := anInteger. self.fireTimeSec := anInteger.
} }
#method youngerThan: aSemaphore method youngerThan: aSemaphore
{ {
^self.fireTimeSec < (aSemaphore fireTime) ^self.fireTimeSec < (aSemaphore fireTime)
} }
} }
#class SemaphoreHeap(Object) class SemaphoreHeap(Object)
{ {
#dcl arr size. dcl arr size.
#method initialize method initialize
{ {
self.size := 0. self.size := 0.
self.arr := Array new: 100. self.arr := Array new: 100.
} }
#method size method size
{ {
^self.size ^self.size
} }
#method at: anIndex method at: anIndex
{ {
^self.arr at: anIndex. ^self.arr at: anIndex.
} }
#method insert: aSemaphore method insert: aSemaphore
{ {
| index | | index |
@ -217,7 +217,7 @@
^self siftUp: index ^self siftUp: index
} }
#method popTop method popTop
{ {
| top | | top |
@ -226,7 +226,7 @@
^top ^top
} }
#method updateAt: anIndex with: aSemaphore method updateAt: anIndex with: aSemaphore
{ {
| item | | item |
@ -241,7 +241,7 @@
ifFalse: [ self siftDown: anIndex ]. ifFalse: [ self siftDown: anIndex ].
} }
#method deleteAt: anIndex method deleteAt: anIndex
{ {
| item | | item |
@ -268,22 +268,22 @@
] ]
} }
#method parentIndex: anIndex method parentIndex: anIndex
{ {
^(anIndex - 1) quo: 2 ^(anIndex - 1) quo: 2
} }
#method leftChildIndex: anIndex method leftChildIndex: anIndex
{ {
^(anIndex * 2) + 1. ^(anIndex * 2) + 1.
} }
#method rightChildIndex: anIndex method rightChildIndex: anIndex
{ {
^(anIndex * 2) + 2. ^(anIndex * 2) + 2.
} }
#method siftUp: anIndex method siftUp: anIndex
{ {
| pindex cindex par item stop | | pindex cindex par item stop |
@ -319,7 +319,7 @@
^cindex ^cindex
} }
#method siftDown: anIndex method siftDown: anIndex
{ {
| base capa cindex item | | base capa cindex item |
@ -359,22 +359,22 @@
} }
} }
#class ProcessScheduler(Object) class ProcessScheduler(Object)
{ {
#dcl tally active runnable_head runnable_tail sem_heap. dcl tally active runnable_head runnable_tail sem_heap.
#method new method new
{ {
"instantiation is not allowed" "instantiation is not allowed"
^nil. "TODO: raise an exception" ^nil. "TODO: raise an exception"
} }
#method activeProcess method activeProcess
{ {
^self.active. ^self.active.
} }
#method resume: process method resume: process
{ {
<primitive: #_processor_schedule> <primitive: #_processor_schedule>
self primitiveFailed. self primitiveFailed.
@ -396,45 +396,45 @@
} }
" "
#method yield method yield
{ {
<primitive: #_processor_yield> <primitive: #_processor_yield>
self primitiveFailed self primitiveFailed
} }
" "
#method signal: semaphore after: secs method signal: semaphore after: secs
{ {
<primitive: #_processor_add_timed_semaphore> <primitive: #_processor_add_timed_semaphore>
self primitiveFailed. self primitiveFailed.
} }
#method signal: semaphore after: secs and: nanosecs method signal: semaphore after: secs and: nanosecs
{ {
<primitive: #_processor_add_timed_semaphore> <primitive: #_processor_add_timed_semaphore>
self primitiveFailed. self primitiveFailed.
} }
#method unsignal: semaphore method unsignal: semaphore
{ {
<primitive: #_processor_remove_semaphore> <primitive: #_processor_remove_semaphore>
self primitiveFailed. self primitiveFailed.
} }
"#method signal: semaphore onInput: file "method signal: semaphore onInput: file
{ {
}" }"
"#method signal: semaphore onOutput: file "method signal: semaphore onOutput: file
{ {
}" }"
#method return: object to: context method return: object to: context
{ {
<primitive: #_processor_return_to> <primitive: #_processor_return_to>
self primitiveFailed. self primitiveFailed.
} }
#method sleepFor: secs method sleepFor: secs
{ {
## ----------------------------------------------------- ## -----------------------------------------------------
## put the calling process to sleep for given seconds. ## put the calling process to sleep for given seconds.
@ -445,7 +445,7 @@
s wait. s wait.
} }
#method sleepFor: secs and: nanosecs method sleepFor: secs and: nanosecs
{ {
## ----------------------------------------------------- ## -----------------------------------------------------
## put the calling process to sleep for given seconds. ## put the calling process to sleep for given seconds.

View File

@ -1,44 +1,44 @@
#class(#byte) Stdio(Object) from 'stdio' class(#byte) Stdio(Object) from 'stdio'
{ {
#dcl(#class) in out err. dcl(#class) in out err.
(* (*
* The following methods are generated by the module. * The following methods are generated by the module.
* #method(#class) _newInstSize { <primitive: #stdio._newInstSize> } * method(#class) _newInstSize { <primitive: #stdio._newInstSize> }
* #method open: name for: mode { <primitive: #stdio.open> } * method open: name for: mode { <primitive: #stdio.open> }
* #method close { <primitive: #stdio.close> } * method close { <primitive: #stdio.close> }
*) *)
#method(#class) new: size method(#class) new: size
{ {
## ignore the specified size ## ignore the specified size
^(super new: (self _newInstSize)) ^(super new: (self _newInstSize))
} }
#method(#class) new method(#class) new
{ {
^(super new: (self _newInstSize)) ^(super new: (self _newInstSize))
} }
#method(#class) open: name for: mode method(#class) open: name for: mode
{ {
^(self new) open: name for: mode ^(self new) open: name for: 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' ].
^self.in. ^self.in.
} }
#method(#class) stdout method(#class) stdout
{ {
self.out isNil ifTrue: [ self.out := ^(super new) open: 1 for: 'w' ]. self.out isNil ifTrue: [ self.out := ^(super new) open: 1 for: 'w' ].
^self.out. ^self.out.
} }
#method(#class) stderr method(#class) stderr
{ {
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.
@ -46,37 +46,36 @@
------------------------ *) ------------------------ *)
(* (*
#method format: fmt with: ... method format: fmt with: ...
{ {
} }
*) *)
#method format (fmt) method format (fmt)
{ {
| a b c ubound | | a b c |
'THIS IS FORMAT' dump. 'THIS IS FORMAT' dump.
fmt dump. fmt dump.
thisContext temporaryCount dump. thisContext temporaryCount dump.
ubound := thisContext vargCount - 1. 0 priorTo: (thisContext vargCount) do: [:k |
0 to: ubound do: [:k |
(thisContext vargAt: k) dump. (thisContext vargAt: k) dump.
]. ].
} }
} }
#extend Stdio extend Stdio
{ {
#method xxxx method xxxx
{ {
self basicSize dump. self basicSize dump.
} }
} }
#class(#byte) Stdio2(Stdio) class(#byte) Stdio2(Stdio)
{ {
#method(#class) new method(#class) new
{ {
##self prohibited ##self prohibited
##raise exception. prohibited... ##raise exception. prohibited...

View File

@ -1,343 +1,23 @@
#include 'Apex.st'. #include 'Apex.st'.
#include 'Class.st'.
#include 'Boolean.st'.
#########################################################################################
#class Magnitude(Object)
{
}
#class Association(Magnitude)
{
#dcl key value.
#method(#class) key: key value: value
{
^self new key: key value: value
}
#method key: key value: value
{
self.key := key.
self.value := value.
}
#method key
{
^self.key
}
#method value
{
^self.value
}
}
#class Character(Magnitude)
{
## #method basicSize
## {
## ^0
## }
}
#class Number(Magnitude)
{
#method + aNumber
{
<primitive: #_integer_add>
self primitiveFailed.
}
#method - aNumber
{
<primitive: #_integer_sub>
self primitiveFailed.
}
#method * aNumber
{
<primitive: #_integer_mul>
self primitiveFailed.
}
#method quo: aNumber
{
<primitive: #_integer_quo>
self primitiveFailed.
}
#method rem: aNumber
{
<primitive: #_integer_rem>
self primitiveFailed.
}
#method // aNumber
{
<primitive: #_integer_quo2>
self primitiveFailed.
}
#method \\ aNumber
{
<primitive: #_integer_rem2>
self primitiveFailed.
}
#method = aNumber
{
<primitive: #_integer_eq>
self primitiveFailed.
}
#method ~= aNumber
{
<primitive: #_integer_ne>
self primitiveFailed.
}
#method < aNumber
{
<primitive: #_integer_lt>
self primitiveFailed.
}
#method > aNumber
{
<primitive: #_integer_gt>
self primitiveFailed.
}
#method <= aNumber
{
<primitive: #_integer_le>
self primitiveFailed.
}
#method >= aNumber
{
<primitive: #_integer_ge>
self primitiveFailed.
}
#method negated
{
<primitive: #_integer_negated>
^0 - self.
}
#method bitAt: index
{
<primitive: #_integer_bitat>
^(self bitShift: index negated) bitAnd: 1.
}
#method bitAnd: aNumber
{
<primitive: #_integer_bitand>
self primitiveFailed.
}
#method bitOr: aNumber
{
<primitive: #_integer_bitor>
self primitiveFailed.
}
#method bitXor: aNumber
{
<primitive: #_integer_bitxor>
self primitiveFailed.
}
#method bitInvert
{
<primitive: #_integer_bitinv>
^-1 - self.
}
#method bitShift: aNumber
{
(* positive number for left shift.
* negative number for right shift *)
<primitive: #_integer_bitshift>
self primitiveFailed.
}
#method asString
{
^self printStringRadix: 10
}
#method printStringRadix: aNumber
{
<primitive: #_integer_inttostr>
self primitiveFailed.
}
#method to: end by: step do: aBlock
{
| i |
i := self.
(step > 0)
ifTrue: [
[ i <= end ] whileTrue: [
aBlock value: i.
i := i + step.
].
]
ifFalse: [
[ i >= end ] whileTrue: [
aBlock value: i.
i := i - step.
].
].
}
#method to: end do: aBlock
{
^self to: end by: 1 do: aBlock.
}
#method priorTo: end by: step do: aBlock
{
| i |
i := self.
(step > 0)
ifTrue: [
[ i < end ] whileTrue: [
aBlock value: i.
i := i + step.
].
]
ifFalse: [
[ i > end ] whileTrue: [
aBlock value: i.
i := i - step.
].
].
}
#method priorTo: end do: aBlock
{
^self priorTo: end by: 1 do: aBlock.
}
#method abs
{
self < 0 ifTrue: [^self negated].
^self.
}
#method sign
{
self < 0 ifTrue: [^-1].
self > 0 ifTrue: [^1].
^0.
}
}
#class Integer(Number)
{
#method timesRepeat: aBlock
{
1 to: self by: 1 do: [ :count | aBlock value ].
}
}
#class SmallInteger(Integer)
{
## #method basicSize
## {
## ^0
## }
#method asError
{
<primitive: #_smooi_as_error>
}
#method asCharacter
{
<primitive: #_smooi_as_character>
}
}
#class(#liword) LargeInteger(Integer)
{
}
#class(#liword) LargePositiveInteger(LargeInteger)
{
#method abs
{
^self.
}
#method sign
{
^1.
}
}
#class(#liword) LargeNegativeInteger(LargeInteger)
{
#method abs
{
^self negated.
}
#method sign
{
^-1.
}
}
#########################################################################################
#include 'Collect.st'.
#class(#pointer) CompiledMethod(Object)
{
## #dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs code source.
#dcl owner name preamble preamble_data_1 preamble_data_2 ntmprs nargs source.
#method preamble
{
^self.preamble
}
#method preambleCode
{
^(self.preamble bitAnd: 16rFF) bitShift: -2.
}
#method owner
{
^self.owner
}
#method name
{
^self.name
}
}
#include 'Context.st'. #include 'Context.st'.
#include 'Except.st'. #include 'Except.st'.
#include 'Class.st'.
#include 'Boolean.st'.
#include 'Magnitu.st'.
#include 'Collect.st'.
#include 'Process.st'. #include 'Process.st'.
#class FFI(Object)
{
#dcl name handle funcs.
#method(#class) new: aString class FFI(Object)
{
dcl name handle funcs.
method(#class) new: aString
{ {
^self new open: aString. ^self new open: aString.
} }
#method open: aString method open: aString
{ {
self.funcs := Dictionary new. self.funcs := Dictionary new.
self.name := aString. self.name := aString.
@ -353,13 +33,13 @@
^self. ^self.
} }
#method close method close
{ {
self privateClose: self.handle. self privateClose: self.handle.
self.handle := nil. self.handle := nil.
} }
#method call: aFunctionName withSig: aString withArgs: anArray method call: aFunctionName withSig: aString withArgs: anArray
{ {
| f | | f |
@ -375,23 +55,23 @@ f isNil ifTrue: [ self error: 'No such function' ].
^self privateCall: f withSig: aString withArgs: anArray ^self privateCall: f withSig: aString withArgs: anArray
} }
#method privateOpen: aString method privateOpen: aString
{ {
<primitive: #_ffi_open> <primitive: #_ffi_open>
^nil. ## TODO: Error signal: 'can not open' ^nil. ## TODO: Error signal: 'can not open'
} }
#method privateClose: aHandle method privateClose: aHandle
{ {
<primitive: #_ffi_close> <primitive: #_ffi_close>
} }
#method privateCall: aSymbol withSig: aString withArgs: anArray method privateCall: aSymbol withSig: aString withArgs: anArray
{ {
<primitive: #_ffi_call> <primitive: #_ffi_call>
} }
#method privateGetSymbol: aString in: aHandle method privateGetSymbol: aString in: aHandle
{ {
<primitive: #_ffi_getsym> <primitive: #_ffi_getsym>
^nil. ^nil.

View File

@ -1,8 +1,8 @@
#include 'Stix.st'. #include 'Stix.st'.
#class MyObject(Object) class MyObject(Object)
{ {
#method(#class) main method(#class) main
{ {
| errmsgs synerrmsgs f | | errmsgs synerrmsgs f |
@ -72,7 +72,8 @@
'undefined class' 'undefined class'
'duplicate class' 'duplicate class'
'contradictory class definition' 'contradictory class definition'
'#dcl not allowed' 'wrong class name'
'dcl not allowed'
'wrong method name' 'wrong method name'
'duplicate method name' 'duplicate method name'
'duplicate argument name' 'duplicate argument name'
@ -109,7 +110,7 @@
f close. f close.
} }
#method(#class) emitMessages: errmsgs named: name on: f method(#class) emitMessages: errmsgs named: name on: f
{ {
| c prefix | | c prefix |
prefix := name & '_'. prefix := name & '_'.
@ -134,7 +135,7 @@
f puts: S'};\n'. f puts: S'};\n'.
} }
#method(#class) printString: s prefix: prefix index: index on: f method(#class) printString: s prefix: prefix index: index on: f
{ {
| c | | c |
c := s size - 1. c := s size - 1.

View File

@ -9,35 +9,35 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. #declare(#classinst) t1 t2.
#method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |
t1 dump. t1 dump.
@ -47,17 +47,17 @@
^self xxxx. ^self xxxx.
} }
#method(#class) zzz method(#class) zzz
{ {
'zzzzzzzzzzzzzzzzzz' dump. 'zzzzzzzzzzzzzzzzzz' dump.
^self. ^self.
} }
#method(#class) yyy method(#class) yyy
{ {
^[123456789 dump. ^200]. ^[123456789 dump. ^200].
} }
#method(#class) main method(#class) main
{ {
'START OF MAIN' dump. 'START OF MAIN' dump.
['1111111' dump. '111111111' dump. '22222222222' dump. ['1111111' dump. '111111111' dump. '22222222222' dump.

View File

@ -9,35 +9,35 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. #declare(#classinst) t1 t2.
#method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |
t1 dump. t1 dump.
@ -47,17 +47,17 @@
^self xxxx. ^self xxxx.
} }
#method(#class) zzz method(#class) zzz
{ {
'zzzzzzzzzzzzzzzzzz' dump. 'zzzzzzzzzzzzzzzzzz' dump.
^self. ^self.
} }
#method(#class) yyy method(#class) yyy
{ {
^[123456789 dump. ^200]. ^[123456789 dump. ^200].
} }
#method(#class) main2 method(#class) main2
{ {
'START OF MAIN2' dump. 'START OF MAIN2' dump.
##[thisContext dump. ^100] newProcess resume. ##[thisContext dump. ^100] newProcess resume.
@ -70,14 +70,14 @@
'EDN OF MAIN2' dump. 'EDN OF MAIN2' dump.
} }
#method(#class) main1 method(#class) main1
{ {
'START OF MAIN1' dump. 'START OF MAIN1' dump.
self main2. self main2.
'END OF MAIN1' dump. 'END OF MAIN1' dump.
} }
#method(#class) main method(#class) main
{ {
'START OF MAIN' dump. 'START OF MAIN' dump.
self main1. self main1.

View File

@ -9,35 +9,35 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. #declare(#classinst) t1 t2.
#method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |
t1 dump. t1 dump.
@ -47,7 +47,7 @@
^self xxxx. ^self xxxx.
} }
#method(#class) main method(#class) main
{ {
'START OF MAIN' dump. 'START OF MAIN' dump.
'EDN OF MAIN' dump. 'EDN OF MAIN' dump.

View File

@ -9,35 +9,35 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. #declare(#classinst) t1 t2.
#method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |
t1 dump. t1 dump.
@ -47,7 +47,7 @@
^self xxxx. ^self xxxx.
} }
#method(#class) main method(#class) main
{ {
'START OF MAIN' dump. 'START OF MAIN' dump.
Processor activeProcess terminate. Processor activeProcess terminate.

View File

@ -9,50 +9,50 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) t1 t2. dcl(#classinst) t1 t2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#dcl(#class) C B A. dcl(#class) C B A.
#method getTrue method getTrue
{ {
^true. ^true.
} }
#method getTrue: anInteger method getTrue: anInteger
{ {
^ anInteger ^ anInteger
} }
#method getFalse method getFalse
{ {
^false ^false
} }
#method yyy: aBlock method yyy: aBlock
{ {
| a | | a |
a := aBlock value. a := aBlock value.
@ -62,14 +62,14 @@
##a := Stix.MyCOM.HashTable new. ##a := Stix.MyCOM.HashTable new.
} }
#method xxx: aBlock method xxx: aBlock
{ {
| a | | a |
a := self yyy: aBlock. a := self yyy: aBlock.
'KKKKKKKKKKKKKKKKKKKKKKKKKKKKK' dump. 'KKKKKKKKKKKKKKKKKKKKKKKKKKKKK' dump.
^a. ^a.
} }
#method(#class) main2 method(#class) main2
{ {
| a b c sum | | a b c sum |
@ -139,7 +139,7 @@
##a dump. ##a dump.
} }
#method(#class) main55 method(#class) main55
{ {
|a b c| |a b c|
@ -148,7 +148,7 @@
## [ b < 5 ] whileTrue: [ b dump. b := b + 1 ]. ## [ b < 5 ] whileTrue: [ b dump. b := b + 1 ].
} }
#method(#class) getTen method(#class) getTen
{ {
^10 ^10
} }
@ -158,7 +158,7 @@
" this sample demonstrates what happens when a block context returns to the origin's caller " this sample demonstrates what happens when a block context returns to the origin's caller
after the caller has already returned. " after the caller has already returned. "
#method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |
t1 dump. t1 dump.
@ -168,7 +168,7 @@
t1 := t1 + 1. t1 := t1 + 1.
self xxxx self xxxx
} }
#method(#class) yyyy method(#class) yyyy
{ {
|c1| |c1|
t1 := 1. t1 := 1.
@ -177,14 +177,14 @@
999 dump. 999 dump.
^c1. ^c1.
} }
#method(#class) main66 method(#class) main66
{ {
self yyyy. self yyyy.
t2 := t2 value. "can t2 return? it should return somewhere into the method context of yyy. but it has already terminated" t2 := t2 value. "can t2 return? it should return somewhere into the method context of yyy. but it has already terminated"
t2 dump. t2 dump.
} }
#method(#class) mainj method(#class) mainj
{ {
|k1| |k1|
t1 := 1. t1 := 1.
@ -195,7 +195,7 @@
} }
## ---------------------------------------------------------------------- ## ----------------------------------------------------------------------
#method(#class) main22 method(#class) main22
{ {
|a b c d e f g h i j k sum | |a b c d e f g h i j k sum |
@ -224,31 +224,31 @@
[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
{ {
c dump. c dump.
} }
#method(#class) a: a b: b c: c d: d e: e f: f g: g h: h method(#class) a: a b: b c: c d: d e: e f: f g: g h: h
{ {
h dump. h dump.
} }
#method(#class) a: a b: b c: c d: d e: e f: f g: g method(#class) a: a b: b c: c d: d e: e f: f g: g
{ {
g dump. g dump.
} }
#method(#class) getABlock method(#class) getABlock
{ {
^ [ 'a block returned by getABlock' dump. "^ self"] ^ [ 'a block returned by getABlock' dump. "^ self"]
} }
#method(#class) main method(#class) main
{ {
" "
| ffi | | ffi |
@ -502,12 +502,12 @@ self represents the receiver. that is bc->origin->receiver which is mc1->receive
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
#method ifTrue: trueBlock method ifTrue: trueBlock
{ {
^trueBlock value. ^trueBlock value.
} }
#method whileTrue: aBlock method whileTrue: aBlock
{ {
(self value) ifTrue: [aBlock value. self whileTrue: aBlock]. (self value) ifTrue: [aBlock value. self whileTrue: aBlock].
} }

View File

@ -9,59 +9,59 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) t1 t2. dcl(#classinst) t1 t2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#dcl(#class) C B A. dcl(#class) C B A.
#method getTrue method getTrue
{ {
^true. ^true.
} }
#method getTrue: anInteger method getTrue: anInteger
{ {
^ anInteger ^ anInteger
} }
#method getFalse method getFalse
{ {
^false ^false
} }
#method a { ^ 10 } method a { ^ 10 }
#method b { ^ 20 } method b { ^ 20 }
#method c { ^ 30 } method c { ^ 30 }
#method(#class) a: a b: b c: c method(#class) a: a b: b c: c
{ {
^ a + b + c. ^ a + b + c.
} }
#method(#class) getBlock method(#class) getBlock
{ {
| a | | a |
a := 7777777. a := 7777777.
@ -73,7 +73,7 @@
^[self a: a b: 3 c: ([[[^6] value] value ] value)]. ^[self a: a b: 3 c: ([[[^6] value] value ] value)].
} }
#method(#class) main method(#class) main
{ {
" "
| k | | k |

View File

@ -9,59 +9,59 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) t1 t2. dcl(#classinst) t1 t2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#dcl(#class) C B A. dcl(#class) C B A.
#method getTrue method getTrue
{ {
^true. ^true.
} }
#method getTrue: anInteger method getTrue: anInteger
{ {
^ anInteger ^ anInteger
} }
#method getFalse method getFalse
{ {
^false ^false
} }
#method a { ^ 10 } method a { ^ 10 }
#method b { ^ 20 } method b { ^ 20 }
#method c { ^ 30 } method c { ^ 30 }
#method(#class) a: a b: b c: c method(#class) a: a b: b c: c
{ {
^ a + b + c. ^ a + b + c.
} }
#method(#class) main method(#class) main
{ {
| p p2 | | p p2 |
'START OF MAIN' dump. 'START OF MAIN' dump.

View File

@ -9,35 +9,35 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2 t3. #declare(#classinst) t1 t2 t3.
#method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |
t1 dump. t1 dump.
@ -48,7 +48,7 @@
^self xxxx. ^self xxxx.
} }
#method(#class) main method(#class) main
{ {
t3 := ['1111' dump. ^20.]. t3 := ['1111' dump. ^20.].
t1 := 1. t1 := 1.

View File

@ -9,43 +9,43 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. #declare(#classinst) t1 t2.
#method(#class) main2 method(#class) main2
{ {
'START OF MAIN2' dump. 'START OF MAIN2' dump.
t1 value. t1 value.
'END OF MAIN2' dump. 'END OF MAIN2' dump.
} }
#method(#class) main1 method(#class) main1
{ {
'START OF MAIN1' dump. 'START OF MAIN1' dump.
self main2. self main2.
@ -54,7 +54,7 @@
} }
#method(#class) main method(#class) main
{ {
'START OF MAIN' dump. 'START OF MAIN' dump.
t1 := ['BLOCK #1' dump. ^100]. t1 := ['BLOCK #1' dump. ^100].

View File

@ -9,55 +9,55 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
#method test999 method test999
{ {
^self.Q ^self.Q
} }
} }
#class B.TestObject(Object) class B.TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
#method test000 method test000
{ {
^self.Q ^self.Q
} }
} }
#pooldic ABC pooldic ABC
{ {
#KKK := 20. #KKK := 20.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#method(#class) main111 method(#class) main111
{ {
| s3 | | s3 |
s3 := Semaphore new. s3 := Semaphore new.
@ -67,7 +67,7 @@
} }
#method(#class) main987 method(#class) main987
{ {
|t1 t2 s1 s2 s3| |t1 t2 s1 s2 s3|
@ -112,7 +112,7 @@
} }
#method(#class) aaa_123 method(#class) aaa_123
{ {
| v1 | | v1 |
v1 := [ v1 := [
@ -130,7 +130,7 @@
]. ].
^v1 ^v1
} }
#method(#class) main method(#class) main
{ {
| v1 | | v1 |
'START OF MAIN' dump. 'START OF MAIN' dump.
@ -171,7 +171,7 @@
'END OF MAIN' dump. 'END OF MAIN' dump.
} }
#method(#class) main22222 method(#class) main22222
{ {
|t1 t2 s1 s2 s3| |t1 t2 s1 s2 s3|
@ -211,7 +211,7 @@
'END OF MAIN' dump. 'END OF MAIN' dump.
} }
#method(#class) test_semaphore_heap method(#class) test_semaphore_heap
{ {
| sempq a | | sempq a |
sempq := SemaphoreHeap new. sempq := SemaphoreHeap new.

View File

@ -9,35 +9,35 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#method(#class) main2 method(#class) main2
{ {
| k q | | k q |
'BEGINNING OF main2' dump. 'BEGINNING OF main2' dump.
@ -56,12 +56,12 @@
'END OF main2' dump. 'END OF main2' dump.
} }
#method(#class) raise_exception method(#class) raise_exception
{ {
Exception signal: 'bad exceptinon'. Exception signal: 'bad exceptinon'.
} }
#method(#class) test3 method(#class) test3
{ {
| k j g_ex | | k j g_ex |
j := 20. j := 20.
@ -90,7 +90,7 @@
'END OF TEST3' dump. 'END OF TEST3' dump.
} }
#method(#class) test4_1 method(#class) test4_1
{ {
| k j | | k j |
j := 20. j := 20.
@ -113,7 +113,7 @@
'END OF TEST4_1' dump. 'END OF TEST4_1' dump.
} }
#method(#class) test4 method(#class) test4
{ {
'BEGINNING OF TEST4' dump. 'BEGINNING OF TEST4' dump.
[ self test4_1 ] on: Exception do: [:ex | 'Excepton in test4_1' dump. ex messageText dump. ex resume]. [ self test4_1 ] on: Exception do: [:ex | 'Excepton in test4_1' dump. ex messageText dump. ex resume].
@ -121,7 +121,7 @@
} }
#method(#class) test5 method(#class) test5
{ {
| k j | | k j |
'BEGINNING OF TEST5' dump. 'BEGINNING OF TEST5' dump.
@ -142,7 +142,7 @@
'END OF TEST5' dump. 'END OF TEST5' dump.
} }
#method(#class) test11 method(#class) test11
{ {
## exception is raised in a new process. it can't be captured ## exception is raised in a new process. it can't be captured
## by an exception handler of a calling process. ## by an exception handler of a calling process.
@ -157,7 +157,7 @@
'END OF test11' dump. 'END OF test11' dump.
} }
#method(#class) test12 method(#class) test12
{ {
'BEGINNING OF test12' dump. 'BEGINNING OF test12' dump.
[ [
@ -174,7 +174,7 @@
'END OF test12' dump. 'END OF test12' dump.
} }
#method(#class) main method(#class) main
{ {
'>>>>> BEGINNING OF MAIN' dump. '>>>>> BEGINNING OF MAIN' dump.

View File

@ -9,55 +9,55 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
#method test999 method test999
{ {
^self.Q ^self.Q
} }
} }
#class B.TestObject(Object) class B.TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
#method test000 method test000
{ {
^self.Q ^self.Q
} }
} }
#pooldic ABC pooldic ABC
{ {
#KKK := 20. #KKK := 20.
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#method(#class) main method(#class) main
{ {
| v1 v2 | | v1 v2 |
System logNl: 'START OF MAIN'. System logNl: 'START OF MAIN'.

View File

@ -9,58 +9,58 @@
## use #extend to extend a class ## use #extend to extend a class
## using #class for both feels confusing. ## using #class for both feels confusing.
#extend Apex extend Apex
{ {
} }
#extend SmallInteger extend SmallInteger
{ {
#method getTrue: anInteger method getTrue: anInteger
{ {
^anInteger + 9999. ^anInteger + 9999.
} }
#method inc method inc
{ {
^self + 1. ^self + 1.
} }
} }
#class TestObject(Object) class TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
#method test999 method test999
{ {
^self.Q ^self.Q
} }
} }
#class B.TestObject(Object) class B.TestObject(Object)
{ {
#dcl(#class) Q R. dcl(#class) Q R.
#dcl(#classinst) a1 a2. dcl(#classinst) a1 a2.
#method test000 method test000
{ {
^self.Q ^self.Q
} }
} }
#pooldic ABC pooldic ABC
{ {
#KKK := 20. #KKK := 20.
} }
#pooldic SRX.ABC pooldic SRX.ABC
{ {
#JJJ := 1000. #JJJ := 1000.
} }
#class MyConsole(Console) class MyConsole(Console)
{ {
#method box: origin corner: corner method box: origin corner: corner
{ {
| tmp | | tmp |
self setCursor: origin. self setCursor: origin.
@ -88,11 +88,11 @@
} }
} }
#class MyObject(TestObject) class MyObject(TestObject)
{ {
#dcl(#pooldic) ABC SRX.ABC. dcl(#pooldic) ABC SRX.ABC.
#method(#class) main method(#class) main
{ {
| v1 v2 | | v1 v2 |
@ -190,23 +190,26 @@
(v1 := self t001(20)) isError ifTrue: [('t001 Error 333....' & v1 asInteger asString) dump]. (v1 := self t001(20)) isError ifTrue: [('t001 Error 333....' & v1 asInteger asString) dump].
error(9999) dump. error(9999) dump.
error(9999) asInteger dump. error(9999) asInteger dump.
v2 := (16rFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF) basicAt: 1 put: 1; yourself.
v2 dump.
} }
#method(#class) varg_test() method(#class) varg_test()
{ {
0 to: (thisContext vargCount - 1) do: [:k | 0 to: (thisContext vargCount - 1) do: [:k |
(thisContext vargAt: k) dump. (thisContext vargAt: k) dump.
]. ].
^999 ^999
} }
#method(#class) varg_test2(a,b,c) method(#class) varg_test2(a,b,c)
{ {
0 to: (thisContext vargCount - 1) do: [:k | 0 to: (thisContext vargCount - 1) do: [:k |
(thisContext vargAt: k) dump. (thisContext vargAt: k) dump.
]. ].
^a ^a
} }
#method(#class) varg_test3(a,b,c,d,e,f) method(#class) varg_test3(a,b,c,d,e,f)
{ {
0 to: (thisContext vargCount - 1) do: [:k | 0 to: (thisContext vargCount - 1) do: [:k |
(thisContext vargAt: k) dump. (thisContext vargAt: k) dump.
@ -215,7 +218,7 @@
^f ^f
} }
#method(#class) t001(a) method(#class) t001(a)
{ {
a isNil ifTrue: [^error(10)]. a isNil ifTrue: [^error(10)].
(a = 20) ifTrue: [^error]. (a = 20) ifTrue: [^error].
@ -230,9 +233,9 @@
} }
} }
#extend MyObject extend MyObject
{ {
#method(#class) main2 method(#class) main2
{ {
System logNl: KKK. System logNl: KKK.
System logNl: SRX.ABC.JJJ. System logNl: SRX.ABC.JJJ.

View File

@ -324,12 +324,12 @@ int stix_inttooow (stix_t* stix, stix_oop_t x, stix_oow_t* w)
if (v < 0) if (v < 0)
{ {
*w = -v; *w = -v;
return -1; return -1; /* negative number negated - kind of an error */
} }
else else
{ {
*w = v; *w = v;
return 1; return 1; /* zero or positive number */
} }
} }

View File

@ -76,24 +76,24 @@ static struct voca_t
} vocas[] = { } vocas[] = {
{ 5, { '#','b','y','t','e' } }, { 5, { '#','b','y','t','e' } },
{ 10, { '#','c','h','a','r','a','c','t','e','r' } }, { 10, { '#','c','h','a','r','a','c','t','e','r' } },
{ 5, { 'c','l','a','s','s' } },
{ 6, { '#','c','l','a','s','s' } }, { 6, { '#','c','l','a','s','s' } },
{ 10, { '#','c','l','a','s','s','i','n','s','t' } }, { 10, { '#','c','l','a','s','s','i','n','s','t' } },
{ 4, { '#','d','c','l' } }, { 3, { 'd','c','l' } },
{ 8, { '#','d','e','c','l','a','r','e' } }, { 7, { 'd','e','c','l','a','r','e' } },
{ 6, { 'e','n','s','u','r','e', } }, { 6, { 'e','n','s','u','r','e', } },
{ 5, { 'e','r','r','o','r' } }, { 5, { 'e','r','r','o','r' } },
{ 9, { 'e','x','c','e','p','t','i','o','n' } }, { 9, { 'e','x','c','e','p','t','i','o','n' } },
{ 7, { '#','e','x','t','e','n','d' } }, { 6, { 'e','x','t','e','n','d' } },
{ 5, { 'f','a','l','s','e' } }, { 5, { 'f','a','l','s','e' } },
{ 4, { 'f','r','o','m' } }, { 4, { 'f','r','o','m' } },
{ 9, { '#','h','a','l','f','w','o','r','d' } }, { 9, { '#','h','a','l','f','w','o','r','d' } },
{ 8, { '#','i','n','c','l','u','d','e' } }, { 8, { '#','i','n','c','l','u','d','e' } },
{ 7, { '#','l','i','w','o','r','d' } }, { 7, { '#','l','i','w','o','r','d' } },
{ 5, { '#','m','a','i','n' } }, { 6, { 'm','e','t','h','o','d' } },
{ 7, { '#','m','e','t','h','o','d' } },
{ 4, { '#','m','t','h' } },
{ 3, { 'n','i','l' } }, { 3, { 'n','i','l' } },
{ 8, { '#','p','o','i','n','t','e','r' } }, { 8, { '#','p','o','i','n','t','e','r' } },
{ 7, { 'p','o','o','l','d','i','c' } },
{ 8, { '#','p','o','o','l','d','i','c' } }, { 8, { '#','p','o','o','l','d','i','c' } },
{ 10, { 'p','r','i','m','i','t','i','v','e',':' } }, { 10, { 'p','r','i','m','i','t','i','v','e',':' } },
{ 4, { 's','e','l','f' } }, { 4, { 's','e','l','f' } },
@ -112,10 +112,11 @@ static struct voca_t
enum voca_id_t enum voca_id_t
{ {
VOCA_BYTE, VOCA_BYTE_S,
VOCA_CHARACTER, VOCA_CHARACTER_S,
VOCA_CLASS, VOCA_CLASS,
VOCA_CLASSINST, VOCA_CLASS_S,
VOCA_CLASSINST_S,
VOCA_DCL, VOCA_DCL,
VOCA_DECLARE, VOCA_DECLARE,
VOCA_ENSURE, VOCA_ENSURE,
@ -124,22 +125,21 @@ enum voca_id_t
VOCA_EXTEND, VOCA_EXTEND,
VOCA_FALSE, VOCA_FALSE,
VOCA_FROM, VOCA_FROM,
VOCA_HALFWORD, VOCA_HALFWORD_S,
VOCA_INCLUDE, VOCA_INCLUDE_S,
VOCA_LIWORD, VOCA_LIWORD_S,
VOCA_MAIN,
VOCA_METHOD, VOCA_METHOD,
VOCA_MTH,
VOCA_NIL, VOCA_NIL,
VOCA_POINTER, VOCA_POINTER_S,
VOCA_POOLDIC, VOCA_POOLDIC,
VOCA_POOLDIC_S,
VOCA_PRIMITIVE_COLON, VOCA_PRIMITIVE_COLON,
VOCA_SELF, VOCA_SELF,
VOCA_SUPER, VOCA_SUPER,
VOCA_THIS_CONTEXT, VOCA_THIS_CONTEXT,
VOCA_THIS_PROCESS, VOCA_THIS_PROCESS,
VOCA_TRUE, VOCA_TRUE,
VOCA_WORD, VOCA_WORD_S,
VOCA_VBAR, VOCA_VBAR,
VOCA_GT, VOCA_GT,
@ -279,6 +279,30 @@ static int is_reserved_word (const stix_oocs_t* ucs)
return 0; return 0;
} }
static int is_restricted_word (const stix_oocs_t* ucs)
{
/* not fully reserved. but restricted in a certain context */
static int rw[] =
{
VOCA_CLASS,
VOCA_DCL,
VOCA_DECLARE,
VOCA_EXTEND,
VOCA_METHOD,
VOCA_POOLDIC,
VOCA_FROM
};
int i;
for (i = 0; i < STIX_COUNTOF(rw); i++)
{
if (is_word(ucs, rw[i])) return 1;
}
return 0;
}
static int begin_include (stix_t* stix); static int begin_include (stix_t* stix);
static int end_include (stix_t* stix); static int end_include (stix_t* stix);
@ -2535,21 +2559,21 @@ static int compile_class_level_variables (stix_t* stix)
/* process variable modifiers */ /* process variable modifiers */
GET_TOKEN (stix); GET_TOKEN (stix);
if (is_token_symbol(stix, VOCA_CLASS)) if (is_token_symbol(stix, VOCA_CLASS_S))
{ {
/* #dcl(#class) */ /* dcl(#class) */
dcl_type = VAR_CLASS; dcl_type = VAR_CLASS;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
else if (is_token_symbol(stix, VOCA_CLASSINST)) else if (is_token_symbol(stix, VOCA_CLASSINST_S))
{ {
/* #dcl(#classinst) */ /* dcl(#classinst) */
dcl_type = VAR_CLASSINST; dcl_type = VAR_CLASSINST;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
else if (is_token_symbol(stix, VOCA_POOLDIC)) else if (is_token_symbol(stix, VOCA_POOLDIC_S))
{ {
/* #dcl(#pooldic) - import a pool dictionary */ /* dcl(#pooldic) - import a pool dictionary */
dcl_type = VAR_GLOBAL; /* this is not a real type. use for branching below */ dcl_type = VAR_GLOBAL; /* this is not a real type. use for branching below */
GET_TOKEN (stix); GET_TOKEN (stix);
} }
@ -2922,34 +2946,17 @@ static int compile_method_primitive (stix_t* stix)
{ {
/* a built-in primitive function is not found /* a built-in primitive function is not found
* check if it is a primitive function identifier */ * check if it is a primitive function identifier */
#if 0
const stix_ooch_t* us;
us = stix_findoochar (tptr, tlen, '_');
if (us > tptr && us < tptr + tlen - 1)
{
stix_oow_t lit_idx; stix_oow_t lit_idx;
/* the symbol literal contains an underscore.
* and it is neither the first nor the last character */ if (stix_findoochar (tptr, tlen, '.') &&
if (add_symbol_literal(stix, TOKEN_NAME(stix), 1, &lit_idx) >= 0 && add_symbol_literal(stix, TOKEN_NAME(stix), 1, &lit_idx) >= 0 &&
STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(lit_idx)) STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(lit_idx))
{ {
stix->c->mth.pftype = 2; /* named primitive */ /* external named primitive containing a period. */
stix->c->mth.pftype = 2;
stix->c->mth.pfnum = lit_idx; stix->c->mth.pfnum = lit_idx;
break; break;
} }
}
#else
stix_oow_t lit_idx;
if (add_symbol_literal(stix, TOKEN_NAME(stix), 1, &lit_idx) >= 0 &&
STIX_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(lit_idx))
{
stix->c->mth.pftype = 2; /* named primitive */
stix->c->mth.pfnum = lit_idx;
break;
}
#endif
/* wrong primitive number */ /* wrong primitive number */
set_syntax_error (stix, STIX_SYNERR_PFID, TOKEN_LOC(stix), TOKEN_NAME(stix)); set_syntax_error (stix, STIX_SYNERR_PFID, TOKEN_LOC(stix), TOKEN_NAME(stix));
@ -4671,9 +4678,9 @@ static int compile_method_definition (stix_t* stix)
/* process method modifiers */ /* process method modifiers */
GET_TOKEN (stix); GET_TOKEN (stix);
if (is_token_symbol(stix, VOCA_CLASS)) if (is_token_symbol(stix, VOCA_CLASS_S))
{ {
/* #method(#class) */ /* method(#class) */
stix->c->mth.type = STIX_METHOD_CLASS; stix->c->mth.type = STIX_METHOD_CLASS;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
@ -4837,7 +4844,7 @@ static int __compile_class_definition (stix_t* stix, int extend)
* variable-modifier := "(" (#class | #classinst)? ")" * variable-modifier := "(" (#class | #classinst)? ")"
* variable-list := identifier* * variable-list := identifier*
* *
* method-definition := (#mth | #method) method-modifier? method-actual-definition * method-definition := method method-modifier? method-actual-definition
* method-modifier := "(" (#class | #instance)? ")" * method-modifier := "(" (#class | #instance)? ")"
* method-actual-definition := method-name "{" method-tempraries? method-primitive? method-statements* "}" * method-actual-definition := method-name "{" method-tempraries? method-primitive? method-statements* "}"
* *
@ -4853,44 +4860,44 @@ static int __compile_class_definition (stix_t* stix, int extend)
GET_TOKEN (stix); GET_TOKEN (stix);
if (is_token_symbol(stix, VOCA_BYTE)) if (is_token_symbol(stix, VOCA_BYTE_S))
{ {
/* #class(#byte) */ /* class(#byte) */
stix->c->cls.flags |= CLASS_INDEXED; stix->c->cls.flags |= CLASS_INDEXED;
stix->c->cls.indexed_type = STIX_OBJ_TYPE_BYTE; stix->c->cls.indexed_type = STIX_OBJ_TYPE_BYTE;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
else if (is_token_symbol(stix, VOCA_CHARACTER)) else if (is_token_symbol(stix, VOCA_CHARACTER_S))
{ {
/* #class(#character) */ /* class(#character) */
stix->c->cls.flags |= CLASS_INDEXED; stix->c->cls.flags |= CLASS_INDEXED;
stix->c->cls.indexed_type = STIX_OBJ_TYPE_CHAR; stix->c->cls.indexed_type = STIX_OBJ_TYPE_CHAR;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
else if (is_token_symbol(stix, VOCA_HALFWORD)) else if (is_token_symbol(stix, VOCA_HALFWORD_S))
{ {
/* #class(#halfword) */ /* class(#halfword) */
stix->c->cls.flags |= CLASS_INDEXED; stix->c->cls.flags |= CLASS_INDEXED;
stix->c->cls.indexed_type = STIX_OBJ_TYPE_HALFWORD; stix->c->cls.indexed_type = STIX_OBJ_TYPE_HALFWORD;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
else if (is_token_symbol(stix, VOCA_WORD)) else if (is_token_symbol(stix, VOCA_WORD_S))
{ {
/* #class(#word) */ /* class(#word) */
stix->c->cls.flags |= CLASS_INDEXED; stix->c->cls.flags |= CLASS_INDEXED;
stix->c->cls.indexed_type = STIX_OBJ_TYPE_WORD; stix->c->cls.indexed_type = STIX_OBJ_TYPE_WORD;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
else if (is_token_symbol(stix, VOCA_POINTER)) else if (is_token_symbol(stix, VOCA_POINTER_S))
{ {
/* #class(#pointer) */ /* class(#pointer) */
stix->c->cls.flags |= CLASS_INDEXED; stix->c->cls.flags |= CLASS_INDEXED;
stix->c->cls.indexed_type = STIX_OBJ_TYPE_OOP; stix->c->cls.indexed_type = STIX_OBJ_TYPE_OOP;
GET_TOKEN (stix); GET_TOKEN (stix);
} }
else if (is_token_symbol(stix, VOCA_LIWORD)) else if (is_token_symbol(stix, VOCA_LIWORD_S))
{ {
/* #class(#biatom) */ /* class(#liword) */
stix->c->cls.flags |= CLASS_INDEXED; stix->c->cls.flags |= CLASS_INDEXED;
stix->c->cls.indexed_type = STIX_OBJ_TYPE_LIWORD; stix->c->cls.indexed_type = STIX_OBJ_TYPE_LIWORD;
GET_TOKEN (stix); GET_TOKEN (stix);
@ -4913,6 +4920,15 @@ static int __compile_class_definition (stix_t* stix, int extend)
return -1; return -1;
} }
#if 0
if (TOKEN_TYPE(stix) == STIX_IOTOK_IDENT && is_restricted_word (TOKEN_NAME(stix)))
{
/* wrong class name */
set_syntax_error (stix, STIX_SYNERR_CLASSNAME, TOKEN_LOC(stix), TOKEN_NAME(stix));
return -1;
}
#endif
/* copy the class name */ /* copy the class name */
if (set_class_fqn(stix, TOKEN_NAME(stix)) <= -1) return -1; if (set_class_fqn(stix, TOKEN_NAME(stix)) <= -1) return -1;
stix->c->cls.fqn_loc = stix->c->tok.loc; stix->c->cls.fqn_loc = stix->c->tok.loc;
@ -5115,13 +5131,12 @@ static int __compile_class_definition (stix_t* stix, int extend)
stix_oop_char_t pds; stix_oop_char_t pds;
/* when a class is extended, a new variable cannot be added */ /* when a class is extended, a new variable cannot be added */
if (is_token_symbol(stix, VOCA_DCL) || is_token_symbol(stix, VOCA_DECLARE)) if (is_token_word(stix, VOCA_DCL) || is_token_word(stix, VOCA_DECLARE))
{ {
set_syntax_error (stix, STIX_SYNERR_DCLBANNED, TOKEN_LOC(stix), TOKEN_NAME(stix)); set_syntax_error (stix, STIX_SYNERR_DCLBANNED, TOKEN_LOC(stix), TOKEN_NAME(stix));
return -1; return -1;
} }
#ifdef MTHDIC #ifdef MTHDIC
/* use the method dictionary of an existing class object */ /* use the method dictionary of an existing class object */
stix->c->cls.mthdic_oop[STIX_METHOD_INSTANCE] = stix->c->cls.self_oop->mthdic[STIX_METHOD_INSTANCE]; stix->c->cls.mthdic_oop[STIX_METHOD_INSTANCE] = stix->c->cls.self_oop->mthdic[STIX_METHOD_INSTANCE];
@ -5182,9 +5197,9 @@ static int __compile_class_definition (stix_t* stix, int extend)
{ {
/* a new class including an internally defined class object */ /* a new class including an internally defined class object */
while (is_token_symbol(stix, VOCA_DCL) || is_token_symbol(stix, VOCA_DECLARE)) while (is_token_word(stix, VOCA_DCL) || is_token_word(stix, VOCA_DECLARE))
{ {
/* variable definition. #dcl or #declare */ /* variable definition. dcl or declare */
GET_TOKEN (stix); GET_TOKEN (stix);
if (compile_class_level_variables(stix) <= -1) return -1; if (compile_class_level_variables(stix) <= -1) return -1;
} }
@ -5197,9 +5212,9 @@ static int __compile_class_definition (stix_t* stix, int extend)
} }
} }
while (is_token_symbol(stix, VOCA_MTH) || is_token_symbol(stix, VOCA_METHOD)) while (is_token_word(stix, VOCA_METHOD))
{ {
/* method definition. #mth or #method */ /* method definition. method */
GET_TOKEN (stix); GET_TOKEN (stix);
if (compile_method_definition(stix) <= -1) return -1; if (compile_method_definition(stix) <= -1) return -1;
} }
@ -5478,7 +5493,7 @@ static int compile_stream (stix_t* stix)
while (TOKEN_TYPE(stix) != STIX_IOTOK_EOF) while (TOKEN_TYPE(stix) != STIX_IOTOK_EOF)
{ {
if (is_token_symbol(stix, VOCA_INCLUDE)) if (is_token_symbol(stix, VOCA_INCLUDE_S))
{ {
/* #include 'xxxx' */ /* #include 'xxxx' */
GET_TOKEN (stix); GET_TOKEN (stix);
@ -5489,21 +5504,21 @@ static int compile_stream (stix_t* stix)
} }
if (begin_include(stix) <= -1) return -1; if (begin_include(stix) <= -1) return -1;
} }
else if (is_token_symbol(stix, VOCA_CLASS)) else if (is_token_word(stix, VOCA_CLASS))
{ {
/* #class Selfclass(Superclass) { } */ /* class Selfclass(Superclass) { } */
GET_TOKEN (stix); GET_TOKEN (stix);
if (compile_class_definition(stix, 0) <= -1) return -1; if (compile_class_definition(stix, 0) <= -1) return -1;
} }
else if (is_token_symbol(stix, VOCA_EXTEND)) else if (is_token_word(stix, VOCA_EXTEND))
{ {
/* #extend Selfclass {} */ /* extend Selfclass {} */
GET_TOKEN (stix); GET_TOKEN (stix);
if (compile_class_definition(stix, 1) <= -1) return -1; if (compile_class_definition(stix, 1) <= -1) return -1;
} }
else if (is_token_symbol(stix, VOCA_POOLDIC)) else if (is_token_word(stix, VOCA_POOLDIC))
{ {
/* #pooldic SharedPoolDic { #ABC := 20. #DEFG := 'ayz' } */ /* pooldic SharedPoolDic { #ABC := 20. #DEFG := 'ayz' } */
GET_TOKEN (stix); GET_TOKEN (stix);
if (compile_pooldic_definition(stix) <= -1) return -1; if (compile_pooldic_definition(stix) <= -1) return -1;
} }

View File

@ -97,32 +97,33 @@ static stix_ooch_t synerrstr_26[] = {'w','r','o','n','g',' ','d','i','r','e','c'
static stix_ooch_t synerrstr_27[] = {'u','n','d','e','f','i','n','e','d',' ','c','l','a','s','s','\0'}; static stix_ooch_t synerrstr_27[] = {'u','n','d','e','f','i','n','e','d',' ','c','l','a','s','s','\0'};
static stix_ooch_t synerrstr_28[] = {'d','u','p','l','i','c','a','t','e',' ','c','l','a','s','s','\0'}; static stix_ooch_t synerrstr_28[] = {'d','u','p','l','i','c','a','t','e',' ','c','l','a','s','s','\0'};
static stix_ooch_t synerrstr_29[] = {'c','o','n','t','r','a','d','i','c','t','o','r','y',' ','c','l','a','s','s',' ','d','e','f','i','n','i','t','i','o','n','\0'}; static stix_ooch_t synerrstr_29[] = {'c','o','n','t','r','a','d','i','c','t','o','r','y',' ','c','l','a','s','s',' ','d','e','f','i','n','i','t','i','o','n','\0'};
static stix_ooch_t synerrstr_30[] = {'#','d','c','l',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'}; static stix_ooch_t synerrstr_30[] = {'w','r','o','n','g',' ','c','l','a','s','s',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_31[] = {'w','r','o','n','g',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_31[] = {'#','d','c','l',' ','n','o','t',' ','a','l','l','o','w','e','d','\0'};
static stix_ooch_t synerrstr_32[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_32[] = {'w','r','o','n','g',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_33[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_33[] = {'d','u','p','l','i','c','a','t','e',' ','m','e','t','h','o','d',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_34[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_34[] = {'d','u','p','l','i','c','a','t','e',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_35[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_35[] = {'d','u','p','l','i','c','a','t','e',' ','t','e','m','p','o','r','a','r','y',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_36[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_36[] = {'d','u','p','l','i','c','a','t','e',' ','v','a','r','i','a','b','l','e',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_37[] = {'c','a','n','n','o','t',' ','a','s','s','i','g','n',' ','t','o',' ','a','r','g','u','m','e','n','t','\0'}; static stix_ooch_t synerrstr_37[] = {'d','u','p','l','i','c','a','t','e',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_38[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'}; static stix_ooch_t synerrstr_38[] = {'c','a','n','n','o','t',' ','a','s','s','i','g','n',' ','t','o',' ','a','r','g','u','m','e','n','t','\0'};
static stix_ooch_t synerrstr_39[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'}; static stix_ooch_t synerrstr_39[] = {'u','n','d','e','c','l','a','r','e','d',' ','v','a','r','i','a','b','l','e','\0'};
static stix_ooch_t synerrstr_40[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'}; static stix_ooch_t synerrstr_40[] = {'u','n','u','s','a','b','l','e',' ','v','a','r','i','a','b','l','e',' ','i','n',' ','c','o','m','p','i','l','e','d',' ','c','o','d','e','\0'};
static stix_ooch_t synerrstr_41[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'}; static stix_ooch_t synerrstr_41[] = {'i','n','a','c','c','e','s','s','i','b','l','e',' ','v','a','r','i','a','b','l','e','\0'};
static stix_ooch_t synerrstr_42[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'}; static stix_ooch_t synerrstr_42[] = {'a','m','b','i','g','u','o','u','s',' ','v','a','r','i','a','b','l','e','\0'};
static stix_ooch_t synerrstr_43[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'}; static stix_ooch_t synerrstr_43[] = {'w','r','o','n','g',' ','e','x','p','r','e','s','s','i','o','n',' ','p','r','i','m','a','r','y','\0'};
static stix_ooch_t synerrstr_44[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'}; static stix_ooch_t synerrstr_44[] = {'t','o','o',' ','m','a','n','y',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
static stix_ooch_t synerrstr_45[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'}; static stix_ooch_t synerrstr_45[] = {'t','o','o',' ','m','a','n','y',' ','a','r','g','u','m','e','n','t','s','\0'};
static stix_ooch_t synerrstr_46[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'}; static stix_ooch_t synerrstr_46[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','t','e','m','p','o','r','a','r','i','e','s','\0'};
static stix_ooch_t synerrstr_47[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'}; static stix_ooch_t synerrstr_47[] = {'t','o','o',' ','m','a','n','y',' ','b','l','o','c','k',' ','a','r','g','u','m','e','n','t','s','\0'};
static stix_ooch_t synerrstr_48[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'}; static stix_ooch_t synerrstr_48[] = {'t','o','o',' ','l','a','r','g','e',' ','b','l','o','c','k','\0'};
static stix_ooch_t synerrstr_49[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'}; static stix_ooch_t synerrstr_49[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','n','u','m','b','e','r','\0'};
static stix_ooch_t synerrstr_50[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_50[] = {'w','r','o','n','g',' ','p','r','i','m','i','t','i','v','e',' ','f','u','n','c','t','i','o','n',' ','i','d','e','n','t','i','f','i','e','r','\0'};
static stix_ooch_t synerrstr_51[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'}; static stix_ooch_t synerrstr_51[] = {'w','r','o','n','g',' ','m','o','d','u','l','e',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_52[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_52[] = {'#','i','n','c','l','u','d','e',' ','e','r','r','o','r','\0'};
static stix_ooch_t synerrstr_53[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_53[] = {'w','r','o','n','g',' ','n','a','m','e','s','p','a','c','e',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_54[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'}; static stix_ooch_t synerrstr_54[] = {'w','r','o','n','g',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_55[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'}; static stix_ooch_t synerrstr_55[] = {'d','u','p','l','i','c','a','t','e',' ','p','o','o','l',' ','d','i','c','t','i','o','n','a','r','y',' ','n','a','m','e','\0'};
static stix_ooch_t synerrstr_56[] = {'l','i','t','e','r','a','l',' ','e','x','p','e','c','t','e','d','\0'};
static stix_ooch_t* synerrstr[] = static stix_ooch_t* synerrstr[] =
{ {
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7, synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
@ -131,7 +132,8 @@ static stix_ooch_t* synerrstr[] =
synerrstr_24, synerrstr_25, synerrstr_26, synerrstr_27, synerrstr_28, synerrstr_29, synerrstr_30, synerrstr_31, synerrstr_24, synerrstr_25, synerrstr_26, synerrstr_27, synerrstr_28, synerrstr_29, synerrstr_30, synerrstr_31,
synerrstr_32, synerrstr_33, synerrstr_34, synerrstr_35, synerrstr_36, synerrstr_37, synerrstr_38, synerrstr_39, synerrstr_32, synerrstr_33, synerrstr_34, synerrstr_35, synerrstr_36, synerrstr_37, synerrstr_38, synerrstr_39,
synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47, synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47,
synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55 synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55,
synerrstr_56
}; };
#endif #endif
/* END: GENERATED WITH generr.st */ /* END: GENERATED WITH generr.st */

File diff suppressed because it is too large Load Diff

View File

@ -747,8 +747,16 @@ struct stix_cb_t
* ========================================================================= */ * ========================================================================= */
#define STIX_MOD_NAME_LEN_MAX 120 #define STIX_MOD_NAME_LEN_MAX 120
enum stix_pfrc_t
{
STIX_PF_HARD_FAILURE = -1,
STIX_PF_FAILURE = 0,
STIX_PF_SUCCESS = 1
};
typedef enum stix_pfrc_t stix_pfrc_t;
/* primitive function implementation type */ /* primitive function implementation type */
typedef int (*stix_pfimpl_t) ( typedef stix_pfrc_t (*stix_pfimpl_t) (
stix_t* stix, stix_t* stix,
stix_ooi_t nargs stix_ooi_t nargs
); );
@ -1088,6 +1096,7 @@ enum stix_synerrnum_t
STIX_SYNERR_CLASSUNDEF, /* undefined class */ STIX_SYNERR_CLASSUNDEF, /* undefined class */
STIX_SYNERR_CLASSDUP, /* duplicate class */ STIX_SYNERR_CLASSDUP, /* duplicate class */
STIX_SYNERR_CLASSCONTRA, /* contradictory class */ STIX_SYNERR_CLASSCONTRA, /* contradictory class */
STIX_SYNERR_CLASSNAME, /* wrong class name */
STIX_SYNERR_DCLBANNED, /* #dcl not allowed */ STIX_SYNERR_DCLBANNED, /* #dcl not allowed */
STIX_SYNERR_MTHNAME, /* wrong method name */ STIX_SYNERR_MTHNAME, /* wrong method name */
STIX_SYNERR_MTHNAMEDUP, /* duplicate method name */ STIX_SYNERR_MTHNAMEDUP, /* duplicate method name */

View File

@ -30,7 +30,7 @@ variable-definition := (#dcl | #declare) variable-modifier? variable-list "."
variable-modifier := "(" (#class | #classinst)? ")" variable-modifier := "(" (#class | #classinst)? ")"
variable-list := identifier* variable-list := identifier*
method-definition := (#mth | #method) method-modifier? method-actual-definition method-definition := #method method-modifier? method-actual-definition
method-modifier := "(" (#class | #instance) ")" method-modifier := "(" (#class | #instance) ")"
method-actual-definition := method-name "{" method-tempraries? method-primitive? method-statements* "}" method-actual-definition := method-name "{" method-tempraries? method-primitive? method-statements* "}"

View File

@ -48,7 +48,7 @@ struct console_t
}; };
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
static int pf_open (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_open (stix_t* stix, stix_ooi_t nargs)
{ {
#if defined(_WIN32) #if defined(_WIN32)
HANDLE h; HANDLE h;
@ -119,10 +119,10 @@ static int pf_open (stix_t* stix, stix_ooi_t nargs)
#endif #endif
STIX_STACK_SETRET (stix, nargs, STIX_SMOOI_TO_OOP((stix_oow_t)con)); STIX_STACK_SETRET (stix, nargs, STIX_SMOOI_TO_OOP((stix_oow_t)con));
return 1; return STIX_PF_SUCCESS;
} }
static int pf_close (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_close (stix_t* stix, stix_ooi_t nargs)
{ {
#if defined(_WIN32) #if defined(_WIN32)
HANDLE h; HANDLE h;
@ -139,10 +139,10 @@ static int pf_close (stix_t* stix, stix_ooi_t nargs)
stix_freemem (stix, con); stix_freemem (stix, con);
STIX_STACK_SETRETTORCV (stix, nargs); STIX_STACK_SETRETTORCV (stix, nargs);
return 1; return STIX_PF_SUCCESS;
} }
static int pf_write (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_write (stix_t* stix, stix_ooi_t nargs)
{ {
console_t* con; console_t* con;
stix_oop_char_t oomsg; stix_oop_char_t oomsg;
@ -157,7 +157,7 @@ static int pf_write (stix_t* stix, stix_ooi_t nargs)
if (STIX_CLASSOF(stix,oomsg) != stix->_string) if (STIX_CLASSOF(stix,oomsg) != stix->_string)
{ {
/* TODO: invalid message */ /* TODO: invalid message */
return 0; return STIX_PF_FAILURE;
} }
ucspos = 0; ucspos = 0;
@ -171,7 +171,7 @@ static int pf_write (stix_t* stix, stix_ooi_t nargs)
if (n != -2 || ucslen <= 0) if (n != -2 || ucslen <= 0)
{ {
stix_seterrnum (stix, STIX_EECERR); stix_seterrnum (stix, STIX_EECERR);
return -1; return STIX_PF_HARD_FAILURE;
} }
} }
@ -182,10 +182,10 @@ static int pf_write (stix_t* stix, stix_ooi_t nargs)
} }
STIX_STACK_SETRETTORCV (stix, nargs); /* TODO: change return code */ STIX_STACK_SETRETTORCV (stix, nargs); /* TODO: change return code */
return 1; return STIX_PF_SUCCESS;
} }
static int pf_clear (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_clear (stix_t* stix, stix_ooi_t nargs)
{ {
console_t* con; console_t* con;
@ -194,10 +194,10 @@ static int pf_clear (stix_t* stix, stix_ooi_t nargs)
write (con->fd, con->clear, strlen(con->clear)); write (con->fd, con->clear, strlen(con->clear));
STIX_STACK_SETRETTORCV (stix, nargs); STIX_STACK_SETRETTORCV (stix, nargs);
return 1; return STIX_PF_SUCCESS;
} }
static int pf_setcursor (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_setcursor (stix_t* stix, stix_ooi_t nargs)
{ {
console_t* con; console_t* con;
stix_oop_oop_t point; stix_oop_oop_t point;
@ -209,44 +209,16 @@ static int pf_setcursor (stix_t* stix, stix_ooi_t nargs)
/* TODO: error check, class check, size check.. */ /* TODO: error check, class check, size check.. */
if (STIX_OBJ_GET_SIZE(point) != 2) if (STIX_OBJ_GET_SIZE(point) != 2)
{ {
return 0; return STIX_PF_FAILURE;
} }
cup = tiparm (con->cup, STIX_OOP_TO_SMOOI(point->slot[1]), STIX_OOP_TO_SMOOI(point->slot[0])); cup = tiparm (con->cup, STIX_OOP_TO_SMOOI(point->slot[1]), STIX_OOP_TO_SMOOI(point->slot[0]));
write (con->fd, cup, strlen(cup)); /* TODO: error check */ write (con->fd, cup, strlen(cup)); /* TODO: error check */
STIX_STACK_SETRETTORCV (stix, nargs); STIX_STACK_SETRETTORCV (stix, nargs);
return 1; return STIX_PF_SUCCESS;
} }
#if 0
static int pf_setcursorto (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
stix_oop_oop_t point;
char* cup;
rcv = STIX_STACK_GETRCV(stix, nargs);
con = STIX_OOP_TO_SMOOI(
con = STIX_OOP_TO_SMOOI(STIX_STACK_GETARG(stix, nargs, 0));
point = STIX_STACK_GETARG(stix, nargs, 1);
/* TODO: error check, class check, size check.. */
if (STIX_OBJ_GET_SIZE(point) != 2)
{
return 0;
}
cup = tiparm (con->cup, STIX_OOP_TO_SMOOI(point->slot[1]), STIX_OOP_TO_SMOOI(point->slot[0]));
write (con->fd, cup, strlen(cup)); /* TODO: error check */
STIX_STACK_SETRETTORCV (stix, nargs);
return 1;
}
#endif
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
typedef struct fnctab_t fnctab_t; typedef struct fnctab_t fnctab_t;

View File

@ -39,14 +39,14 @@ struct stdio_t
FILE* fp; FILE* fp;
}; };
static int pf_newinstsize (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_newinstsize (stix_t* stix, stix_ooi_t nargs)
{ {
stix_ooi_t newinstsize = STIX_SIZEOF(stdio_t) - STIX_SIZEOF(stix_obj_t); stix_ooi_t newinstsize = STIX_SIZEOF(stdio_t) - STIX_SIZEOF(stix_obj_t);
STIX_STACK_SETRET (stix, nargs, STIX_SMOOI_TO_OOP(newinstsize)); STIX_STACK_SETRET (stix, nargs, STIX_SMOOI_TO_OOP(newinstsize));
return 1; return STIX_PF_SUCCESS;
} }
static int pf_open (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_open (stix_t* stix, stix_ooi_t nargs)
{ {
stix_oop_char_t name; stix_oop_char_t name;
stix_oop_char_t mode; stix_oop_char_t mode;
@ -84,14 +84,14 @@ static int pf_open (stix_t* stix, stix_ooi_t nargs)
} }
STIX_STACK_SETRETTORCV (stix, nargs); STIX_STACK_SETRETTORCV (stix, nargs);
return 1; return STIX_PF_SUCCESS;
reterr: reterr:
STIX_STACK_SETRETTOERROR (stix, nargs); STIX_STACK_SETRETTOERROR (stix, nargs);
return 1; return STIX_PF_SUCCESS;
} }
static int pf_close (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_close (stix_t* stix, stix_ooi_t nargs)
{ {
stdio_t* rcv; stdio_t* rcv;
@ -103,17 +103,17 @@ static int pf_close (stix_t* stix, stix_ooi_t nargs)
} }
STIX_STACK_SETRETTORCV (stix, nargs); STIX_STACK_SETRETTORCV (stix, nargs);
return 1; return STIX_PF_SUCCESS;
} }
static int pf_gets (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_gets (stix_t* stix, stix_ooi_t nargs)
{ {
/* return how many bytes have been written.. */ /* return how many bytes have been written.. */
STIX_STACK_SETRETTORCV (stix, nargs); STIX_STACK_SETRETTORCV (stix, nargs);
return 1; return STIX_PF_SUCCESS;
} }
static int __pf_puts (stix_t* stix, stix_ooi_t nargs, stix_oow_t limit) static stix_pfrc_t __pf_puts (stix_t* stix, stix_ooi_t nargs, stix_oow_t limit)
{ {
stdio_t* rcv; stdio_t* rcv;
stix_ooi_t i; stix_ooi_t i;
@ -181,19 +181,19 @@ static int __pf_puts (stix_t* stix, stix_ooi_t nargs, stix_oow_t limit)
} }
STIX_STACK_SETRETTORCV (stix, nargs); STIX_STACK_SETRETTORCV (stix, nargs);
return 1; return STIX_PF_SUCCESS;
reterr: reterr:
STIX_STACK_SETRETTOERROR (stix, nargs); STIX_STACK_SETRETTOERROR (stix, nargs);
return 1; return STIX_PF_SUCCESS;
} }
static int pf_putc (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_putc (stix_t* stix, stix_ooi_t nargs)
{ {
return __pf_puts (stix, nargs, 1); return __pf_puts (stix, nargs, 1);
} }
static int pf_puts (stix_t* stix, stix_ooi_t nargs) static stix_pfrc_t pf_puts (stix_t* stix, stix_ooi_t nargs)
{ {
return __pf_puts (stix, nargs, STIX_TYPE_MAX(stix_oow_t)); return __pf_puts (stix, nargs, STIX_TYPE_MAX(stix_oow_t));
} }