Object subclass: #JoyDefinition instanceVariableNames: 'name code' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyDefinition methodsFor: 'printing' stamp: 'e-itoh 10/5/2007 21:11'! printOn: aStream aStream nextPutAll: '<'; nextPutAll: name asString; nextPutAll: ' == '; nextPutAll: code asString; nextPutAll: '.>'! ! !JoyDefinition methodsFor: 'private' stamp: 'e-itoh 10/5/2007 21:09'! setName: aSymbol code: aJoyNode name := aSymbol. code := aJoyNode! ! !JoyDefinition methodsFor: 'accessing' stamp: 'e-itoh 10/5/2007 21:54'! code ^ code! ! !JoyDefinition methodsFor: 'accessing' stamp: 'e-itoh 10/8/2007 19:42'! code: aJoyList code := aJoyList! ! !JoyDefinition methodsFor: 'accessing' stamp: 'e-itoh 10/5/2007 21:54'! name ^ name! ! !JoyDefinition methodsFor: 'accessing' stamp: 'e-itoh 10/8/2007 13:51'! name: aString name := aString! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! JoyDefinition class instanceVariableNames: ''! !JoyDefinition class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/8/2007 21:42'! newName: aSymbol code: aJoyList ^ self basicNew setName: aSymbol code: aJoyList! ! Object subclass: #JoyLibrary instanceVariableNames: 'codes' classVariableNames: 'DefaultJoyLibrary' poolDictionaries: '' category: 'Joy-Base'! !JoyLibrary methodsFor: 'printing' stamp: 'e-itoh 10/8/2007 14:02'! printOn: aStream aStream nextPutAll: '<'. codes keys do: [:each | aStream nextPutAll: each; nextPutAll: ' ']. aStream nextPutAll: '>'! ! !JoyLibrary methodsFor: 'accessing' stamp: 'e-itoh 10/5/2007 21:53'! addDefinition: aJoyDefinition self name: aJoyDefinition name code: aJoyDefinition code! ! !JoyLibrary methodsFor: 'accessing' stamp: 'e-itoh 10/5/2007 17:01'! codeOf: aString ^ codes at: aString asSymbol! ! !JoyLibrary methodsFor: 'accessing' stamp: 'e-itoh 10/8/2007 13:58'! includesName: aString ^ codes includesKey: aString asSymbol! ! !JoyLibrary methodsFor: 'accessing' stamp: 'e-itoh 10/5/2007 16:53'! initialize codes := Dictionary new! ! !JoyLibrary methodsFor: 'accessing' stamp: 'e-itoh 10/5/2007 16:54'! name: aString code: aJoyNode codes at: aString asSymbol put: aJoyNode! ! !JoyLibrary methodsFor: 'accessing' stamp: 'e-itoh 10/8/2007 20:03'! names ^ codes keys! ! !JoyLibrary methodsFor: 'accessing' stamp: 'e-itoh 10/8/2007 13:59'! removeName: aString codes removeKey: aString asSymbol! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! JoyLibrary class instanceVariableNames: ''! !JoyLibrary class methodsFor: 'accessing' stamp: 'e-itoh 10/7/2007 21:41'! default DefaultJoyLibrary ifNil: [DefaultJoyLibrary := self basicNew initialize]. ^ DefaultJoyLibrary! ! !JoyLibrary class methodsFor: 'accessing' stamp: 'e-itoh 10/7/2007 21:40'! new self shouldNotImplement! ! !JoyLibrary class methodsFor: 'accessing' stamp: 'e-itoh 10/7/2007 21:41'! reset DefaultJoyLibrary := nil! ! Object subclass: #JoyMachine instanceVariableNames: 'stack stepper conts dump op opcont arg library' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:27'! popDump dump removeLast! ! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:27'! saveStack dump addLast: stack! ! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:33'! saved1 ^ dump last! ! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:33'! saved2 ^ dump last next! ! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:33'! saved3 ^ dump last next next! ! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:33'! saved4 ^ dump last next next next! ! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:33'! saved5 ^ dump last next next next next! ! !JoyMachine methodsFor: 'dump accessing' stamp: 'e-itoh 10/4/2007 15:33'! saved6 ^ dump last next next next next next! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/10/2007 22:07'! exec: aJoyNode self execList: (JoyList new: aJoyNode)! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/12/2007 10:03'! execList: aJoyList self clear. aJoyList ifNil: [^ self]. self saveList: aJoyList. [[self step] whileTrue] on: Error do: [:e | self inform: e messageText. self clear]! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/5/2007 11:20'! gotoOp: aSymbol op := aSymbol! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/11/2007 00:06'! nextOp | top | opcont isNil ifTrue: [conts isEmpty ifTrue: [^ false] ifFalse: [opcont := conts removeLast. op := nil. ^ true]]. top := opcont node. opcont := opcont next. top isModule ifTrue: [opcont notNil ifTrue: [conts addLast: opcont]. opcont := library codeOf: top name. op := nil. ^ true]. top isPrimitive ifTrue: [op := top name. arg := top argument. ^ true]. op := #pushNode:. arg := top. ^ true! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/10/2007 22:16'! saveList: aJoyList opcont notNil ifTrue: [conts addLast: opcont. opcont := JoyList joyNil]. conts addLast: aJoyList! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/4/2007 21:18'! saveOp: nextOp self saveOp: nextOp arg: nil! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/10/2007 22:08'! saveOp: nextOp arg: anObject | list | list := JoyList new: (JoyPrimitive newName: nextOp arg: anObject). self saveList: list! ! !JoyMachine methodsFor: 'execution' stamp: 'e-itoh 10/10/2007 23:28'! step | nextOp nextArg | op ifNil: [self nextOp ifFalse: [^ false]. op ifNil: [^ true]]. nextOp := op. nextArg := arg. op := nil. arg := nil. nextOp isUnary ifTrue: [stepper perform: nextOp] ifFalse: [stepper perform: nextOp with: nextArg]. ^ true! ! !JoyMachine methodsFor: 'initialization' stamp: 'e-itoh 10/10/2007 22:15'! clear conts := OrderedCollection new. dump := OrderedCollection new. op := nil. arg := nil. opcont := JoyList joyNil! ! !JoyMachine methodsFor: 'initialization' stamp: 'e-itoh 10/10/2007 22:13'! initialize stack := JoyList joyNil. stepper := JoyStepper new machine: self. library := JoyLibrary default. self clear! ! !JoyMachine methodsFor: 'stack accessing' stamp: 'e-itoh 10/4/2007 19:42'! popStack stack := stack next! ! !JoyMachine methodsFor: 'stack accessing' stamp: 'e-itoh 10/8/2007 11:06'! pushNode: aJoyNode stack := JoyList new: aJoyNode next: stack! ! !JoyMachine methodsFor: 'stack accessing' stamp: 'e-itoh 10/4/2007 17:39'! stack ^ stack! ! !JoyMachine methodsFor: 'stack accessing' stamp: 'e-itoh 10/8/2007 11:16'! stack: aJoyList stack := aJoyList! ! !JoyMachine methodsFor: 'accessing' stamp: 'e-itoh 10/5/2007 16:57'! library ^ library! ! !JoyMachine methodsFor: 'accessing' stamp: 'e-itoh 10/6/2007 07:12'! recover stack := dump first! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! JoyMachine class instanceVariableNames: ''! !JoyMachine class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:03'! sample1 "JoyMachine sample1" | m | m := JoyMachine new. m exec: (JoyNumber newFrom: 1). m exec: (JoyNumber newFrom: 2). m exec: (JoyNumber newFrom: 3). m exec: (JoyPrimitive newFrom: #plus). m exec: (JoyPrimitive newFrom: #plus). ^ m stack! ! !JoyMachine class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 22:08'! sample2 | m n2 n | m := JoyMachine new. n2 := JoyList new: (JoyNumber newFrom: 2). n := JoyList new: (JoyNumber newFrom: 1) next: n2. m exec: n. m exec: (JoyPrimitive newFrom: #i). ^ m stack! ! !JoyMachine class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 22:17'! sample3 | m n n1 n2 | m := JoyMachine new. m exec: (JoyNumber newFrom: 3). n := JoyList new: (JoyNumber newFrom: 0). m exec: n. n := JoyList new: (JoyPrimitive newFrom: #plus). n1 := JoyList new: (JoyPrimitive newFrom: #mul) next: n. n2 := JoyList new: (JoyPrimitive newFrom: #dup) next: n1. m exec: n2. m exec: (JoyPrimitive newFrom: #primrec). ^ m stack! ! !JoyMachine class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 22:09'! sample4 | m n3 n4 n5 n n1 n2 | m := JoyMachine new. n3 := JoyList new: (JoyNumber newFrom: 2). n4 := JoyList new: (JoyPrimitive newFrom: #i). n5 := JoyList new: n3 next: n4. n := JoyList new: (JoyNumber newFrom: 1). n1 := JoyList new: (JoyPrimitive newFrom: #i) next: n5. n2 := JoyList new: n next: n1. m exec: n2. m exec: (JoyPrimitive newFrom: #i). ^ m stack! ! Object subclass: #JoyNode instanceVariableNames: 'v' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyNode methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 11:36'! isModule ^ false! ! !JoyNode methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 19:33'! isPrimitive ^ false! ! !JoyNode methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 19:08'! isSymbol ^ false! ! !JoyNode methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 22:55'! printOn: aStream aStream nextPutAll: '<'; nextPutAll: v asString; nextPutAll: '>'! ! !JoyNode methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 18:27'! setV: anObject v := anObject! ! !JoyNode methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/7/2007 20:30'! titleString ^ v asString! ! !JoyNode methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 18:29'! v ^ v! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! JoyNode class instanceVariableNames: ''! !JoyNode class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:03'! newFrom: anObject ^ self basicNew setV: anObject! ! JoyNode subclass: #JoyBoolean instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyBoolean methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/12/2007 10:27'! boolAnd: other ^ self v and: [other v]! ! !JoyBoolean methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/12/2007 10:28'! boolOr: other ^ self v or: [other v]! ! !JoyBoolean methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/12/2007 10:28'! boolXor: other ^ self v ~= other v! ! !JoyBoolean methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 22:47'! ifTrue: aTrueBlock ifFalse: aFalseBlock v ifTrue: aTrueBlock ifFalse: aFalseBlock! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! JoyBoolean class instanceVariableNames: ''! !JoyBoolean class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:03'! false ^ self newFrom: false! ! !JoyBoolean class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:03'! true ^ self newFrom: true! ! JoyNode subclass: #JoyList instanceVariableNames: 'next' classVariableNames: 'JoyNil' poolDictionaries: '' category: 'Joy-Base'! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 22:07'! concat: other | top prev cur list | top := JoyList new: self node. prev := top. cur := next. [cur notNil] whileTrue: [list := JoyList new: cur node. prev next: list. prev := list. cur := cur next]. prev next: other. ^ top! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 14:06'! cons: aJoyNode ^ JoyList new: aJoyNode next: self ! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:35'! first ^ self node! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 21:54'! isNil ^ self == JoyNil! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/11/2007 21:01'! next self isNil ifTrue: [self error: 'can not get next of nil']. ^ next! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/11/2007 20:38'! next: aJoyList "aJoyList == nil ifTrue: [self halt]." next := aJoyList! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/11/2007 21:00'! node self isNil ifTrue: [self error: 'can not get node of nil']. ^ v! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 21:54'! notNil ^ self ~= JoyNil! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 21:56'! printOn: aStream | l | self isNil ifTrue: [^ aStream nextPutAll: '[!!]']. aStream nextPutAll: '['; nextPutAll: v asString. l := next. [l notNil] whileTrue: [aStream nextPutAll: ' '. l node printOn: aStream. l := l next]. aStream nextPutAll: ']'! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:35'! rest ^ next! ! !JoyList methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/11/2007 20:38'! setNode: aJoyNode next: aJoyList "aJoyList == nil ifTrue: [self halt]." v := aJoyNode. next := aJoyList! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! JoyList class instanceVariableNames: ''! !JoyList class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 21:53'! initialize JoyNil ifNil: [JoyNil := JoyList new: #bottom next: #bottom]! ! !JoyList class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 21:54'! joyNil ^ JoyNil! ! !JoyList class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/10/2007 22:06'! new: aJoyNode ^ self new: aJoyNode next: JoyNil! ! !JoyList class methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/8/2007 11:15'! new: aJoyNode next: aJoyList ^ self basicNew setNode: aJoyNode next: aJoyList! ! JoyNode subclass: #JoyModule instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyModule methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 11:36'! isModule ^ true! ! !JoyModule methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 17:02'! name ^ v! ! JoyNode subclass: #JoyNumber instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:04'! * other ^ JoyNumber newFrom: self num * other num! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:04'! + other ^ JoyNumber newFrom: self num + other num! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:04'! - other ^ JoyNumber newFrom: self num - other num! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:04'! / other ^ JoyNumber newFrom: self num / other num! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:46'! eql: other ^ self num = other num! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:50'! leql: other ^ self num <= other num! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:48'! less: other ^ self num < other num! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:47'! null ^ self num = 0! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 18:29'! num ^ v! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 22:32'! pred ^ JoyNumber newFrom: self num - 1! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/8/2007 11:07'! primrecWith: aJoyMachine v to: 1 by: -1 do: [:i | aJoyMachine pushNode: (JoyNumber newFrom: i)]. ^ v! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 20:36'! rem: other ^ JoyNumber newFrom: (self num rem: other num)! ! !JoyNumber methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 22:32'! succ ^ JoyNumber newFrom: self num + 1! ! JoyNumber subclass: #JoyChar instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyChar methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:43'! char ^ v! ! !JoyChar methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:20'! printOn: aStream aStream nextPutAll: '<'''; nextPutAll: v asString; nextPutAll: '>'! ! !JoyChar methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 22:25'! succ ^ JoyChar newFrom: (Character value: self char asciiValue + 1)! ! JoyNode subclass: #JoyPrimitive instanceVariableNames: 'argument' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyPrimitive methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 21:17'! argument ^ argument! ! !JoyPrimitive methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 21:17'! argument: anObject argument := anObject! ! !JoyPrimitive methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 19:33'! isPrimitive ^ true! ! !JoyPrimitive methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 19:09'! isSymbol ^ true! ! !JoyPrimitive methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 19:10'! name ^ v! ! !JoyPrimitive methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/4/2007 20:12'! printOn: aStream aStream nextPutAll: '<@'; nextPutAll: v asString; nextPutAll: '>'! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! JoyPrimitive class instanceVariableNames: ''! !JoyPrimitive class methodsFor: 'accessing' stamp: 'e-itoh 10/8/2007 20:39'! names ^ JoyStepper selectors select: [:each | ((each includes: $X) or: [each includes: $:]) not]! ! !JoyPrimitive class methodsFor: 'instance creation' stamp: 'e-itoh 10/6/2007 07:18'! newName: aSymbol arg: anObject | prim | prim := super newFrom: aSymbol. prim argument: anObject. ^ prim! ! Object subclass: #JoyStepper instanceVariableNames: 'machine' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/9/2007 22:27'! branch machine saveStack. machine stack: machine saved4. machine saveOp: #popDumpX. machine saveList: (machine saved3 node v ifTrue: [machine saved2] ifFalse: [machine saved1]) node! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/8/2007 11:02'! dip machine saveStack. machine popStack; popStack. machine saveOp: #dipX2. machine saveList: machine saved1 node! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/8/2007 11:07'! dipX2 machine pushNode: machine saved2 node. machine popDump! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/9/2007 22:27'! i machine saveStack. machine popStack. machine saveOp: #popDumpX. machine saveList: machine saved1 node! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/8/2007 11:03'! ifte machine saveStack. machine stack: machine saved4. machine saveOp: #ifteX2. machine saveList: machine saved3 node! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/9/2007 22:27'! ifteX2 | result | result := machine stack node. machine stack: machine saved4. machine saveOp: #popDumpX. result v ifTrue: [machine saveList: machine saved2 node] ifFalse: [machine saveList: machine saved1 node]! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/8/2007 11:04'! primrec | n | machine saveStack. machine popStack; popStack; popStack. n := machine saved3 node primrecWith: machine. machine saveOp: #primrecX2: arg: n. machine saveList: machine saved2 node! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/8/2007 11:04'! primrecX2: anObject anObject ~= 0 ifTrue: [machine saveOp: #primrecX2: arg: anObject - 1. machine saveList: machine saved1 node] ifFalse: [machine popDump]! ! !JoyStepper methodsFor: 'general combinators' stamp: 'e-itoh 10/8/2007 11:04'! x machine saveList: machine stack node! ! !JoyStepper methodsFor: 'general operators' stamp: 'e-itoh 10/8/2007 11:07'! dup machine pushNode: machine stack node! ! !JoyStepper methodsFor: 'general operators' stamp: 'e-itoh 10/11/2007 22:35'! id ! ! !JoyStepper methodsFor: 'general operators' stamp: 'e-itoh 10/5/2007 10:45'! pop machine popStack! ! !JoyStepper methodsFor: 'general operators' stamp: 'e-itoh 10/8/2007 11:12'! pushNode: aJoyNode machine pushNode: aJoyNode! ! !JoyStepper methodsFor: 'general operators' stamp: 'e-itoh 10/8/2007 11:04'! swap | n1 n2 | machine saveStack. n1 := JoyList new: machine saved1 node next: machine stack next next. n2 := JoyList new: machine saved2 node next: n1. machine stack: n2. machine popDump! ! !JoyStepper methodsFor: 'predicates' stamp: 'e-itoh 10/9/2007 19:52'! eql | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack node eql: stack next node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'predicates' stamp: 'e-itoh 10/9/2007 19:51'! geql | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack node leql: stack next node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'predicates' stamp: 'e-itoh 10/9/2007 19:49'! greater | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack node less: stack next node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'predicates' stamp: 'e-itoh 10/9/2007 19:50'! leql | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack next node leql: stack node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'predicates' stamp: 'e-itoh 10/9/2007 19:49'! less | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack next node less: stack node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'predicates' stamp: 'e-itoh 10/9/2007 19:53'! neql | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack node eql: stack next node) not. machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'predicates' stamp: 'e-itoh 10/9/2007 19:47'! null | stack node | stack := machine stack. node := JoyBoolean newFrom: stack node null. machine stack: (JoyList new: node next: stack next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/12/2007 10:28'! and | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack node boolAnd: stack next node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/9/2007 20:20'! concat | stack node | stack := machine stack. node := stack next node isNil ifTrue: [stack node] ifFalse: [stack node isNil ifTrue: [stack next node] ifFalse: [stack next node concat: stack node]]. machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/10/2007 22:09'! cons | stack arg1 arg2 list node | stack := machine stack. arg1 := stack node. arg2 := stack next node. node := arg1 ifNil: [JoyList new: arg2] ifNotNil: [arg1 cons: arg2]. list := JoyList new: node next: stack next next. machine stack: list! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/8/2007 11:02'! div | stack node | stack := machine stack. node := stack node / stack next node. machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/9/2007 19:33'! first | stack arg1 list | stack := machine stack. arg1 := stack node first. list := JoyList new: arg1 next: stack next. machine stack: list! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/8/2007 11:03'! minus | stack node | stack := machine stack. node := stack node - stack next node. machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/8/2007 11:03'! mul | stack node | stack := machine stack. node := stack node * stack next node. machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/12/2007 10:28'! or | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack node boolOr: stack next node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/8/2007 11:03'! plus | stack node | stack := machine stack. node := stack node + stack next node. machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/8/2007 11:03'! pred | stack node | stack := machine stack. node := stack node pred. machine stack: (JoyList new: node next: stack next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/9/2007 20:38'! rem | stack node | stack := machine stack. node := stack next node rem: stack node. machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/9/2007 19:36'! rest | stack arg1 list | stack := machine stack. arg1 := stack node rest. list := JoyList new: arg1 next: stack next. machine stack: list! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/8/2007 11:04'! succ | stack node | stack := machine stack. node := stack node succ. machine stack: (JoyList new: node next: stack next)! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/9/2007 19:41'! uncons | arg1 stack list | machine saveStack. stack := machine stack. arg1 := stack node. list := JoyList new: arg1 first next: stack next. machine stack: (JoyList new: arg1 rest next: list). machine popDump! ! !JoyStepper methodsFor: 'simple operators' stamp: 'e-itoh 10/12/2007 10:28'! xor | stack node | stack := machine stack. node := JoyBoolean newFrom: (stack node boolXor: stack next node). machine stack: (JoyList new: node next: stack next next)! ! !JoyStepper methodsFor: 'private' stamp: 'e-itoh 10/4/2007 15:47'! machine: aJoyMachine machine := aJoyMachine! ! !JoyStepper methodsFor: 'private' stamp: 'e-itoh 10/9/2007 22:27'! popDumpX machine popDump! ! JoyNode subclass: #JoyString instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Joy-Base'! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 20:01'! concat: other ^ JoyString newFrom: self str , other str! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:44'! cons: aJoyNode ^ JoyString newFrom: (self str copyWithFirst: aJoyNode char)! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:46'! eql: other ^ self str = other str! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:34'! first ^ JoyChar newFrom: (v at: 1)! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:53'! leql: other ^ self str <= other str! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:53'! less: other ^ self str < other str! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:55'! null ^ self str isEmpty! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 20:39'! printOn: aStream aStream nextPutAll: '<"'; nextPutAll: v; nextPutAll: '">'! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/9/2007 19:42'! rest ^ JoyString newFrom: self str allButFirst! ! !JoyString methodsFor: 'as yet unclassified' stamp: 'e-itoh 10/5/2007 18:48'! str ^ v! ! JoyList initialize!