
# fileIn("s8/library/sharing/Stringifier.st")
smalltalk.addClass("Stringifier",smalltalk.Object,["origin","rememberedSet","id","markedObjects","objectHandlers"],"Stringifier")

smalltalk.bind(smalltalk.Stringifier.__class__,"constructEventsTriggered",0
,smalltalk.__f__("""(self):
	#Stringifier class>>#constructEventsTriggered
	return smalltalk.object_comma_(smalltalk.superReceiver(smalltalk.Stringifier.__class__,self).constructEventsTriggered(),smalltalk.newArray(["needsOrigin","prepare:","needsStringifier","aboutToReset","reset","aboutToClose","needsObjectHandlers","objectHandlersContents","needsHandlerFor:"])) 
""","Stringifier_class_constructEventsTriggered")
,"events","""constructEventsTriggered
	" Private - Return the events managed by instances of the receiver. "

	^super constructEventsTriggered
	,#(	#needsOrigin
		#prepare: #needsStringifier
		#aboutToReset #reset #aboutToClose
		#needsObjectHandlers #objectHandlersContents
		#needsHandlerFor:
	)""",nil)

smalltalk.bind(smalltalk.Stringifier.__class__,"@","_at"
,smalltalk.__f__("""(self,anObject):
	#Stringifier class>>#@
	return self.new().literalForOne_(anObject) 
""","Stringifier_class__at")
,"converting","""@ anObject
	" Returns the literal to send to a remote system to obtain a copy of anObject. "

	^self new literalForOne: anObject""",nil)

smalltalk.bind(smalltalk.Stringifier.__class__,"to:",0
,smalltalk.__f__("""(self,target):
	#Stringifier class>>#to:
	return self.new().yourself() 
""","Stringifier_class_to_")
,"instantiation","""to: target
	" Returns an instance of the receiver. "

	^self new
		"target: target; - ignored"
		yourself""",nil)

smalltalk.bind(smalltalk.Stringifier,"origin",0
,smalltalk.__f__("""(self):
	#Stringifier>>#origin
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@origin",nil))):
		self.initializeOrigin() 
	 
	return getattr(self,"@origin",nil) 
""","Stringifier_origin")
,"accessing","""origin
	" Returns the origin of the receiver. "

	origin isNil ifTrue: [ self initializeOrigin ].
	^origin""",nil)

smalltalk.bind(smalltalk.Stringifier,"id",0
,smalltalk.__f__("""(self):
	#Stringifier>>#id
	return getattr(self,"@id",nil) 
""","Stringifier_id")
,"accessing","""id
	" Returns the id of the receiver (can be nil). "

	^id""",nil)

smalltalk.bind(smalltalk.Stringifier,"origin:",0
,smalltalk.__f__("""(self,aSymbol):
	#Stringifier>>#origin:
	smalltalk.basic_at_put(self,"@origin",aSymbol) 
	return self 
""","Stringifier_origin_")
,"accessing","""origin: aSymbol
	" Set the origin of the receiver. "

	origin := aSymbol""",nil)

smalltalk.bind(smalltalk.Stringifier,"tagStart",0
,smalltalk.__f__("""(self):
	#Stringifier>>#tagStart
	return smalltalk.String(" ") 
""","Stringifier_tagStart")
,"constants","""tagStart
	" Private - Returns the tag start mask. "

	^' '""",nil)

smalltalk.bind(smalltalk.Stringifier,"markID",0
,smalltalk.__f__("""(self):
	#Stringifier>>#markID
	return smalltalk.object_comma_(self.tagStart(),smalltalk.String("id")) 
""","Stringifier_markID")
,"constants","""markID
	" Private - Returns the id mark token. "

	^self tagStart ,#id""",nil)

smalltalk.bind(smalltalk.Stringifier,"defaultOrigin",0
,smalltalk.__f__("""(self):
	#Stringifier>>#defaultOrigin
	if smalltalk.b(smalltalk.Smalltalk.includesKey_(smalltalk.String("OrderedCollection"))):
		return smalltalk.String("VSE") 
	 
	return smalltalk.String("S8") 
""","Stringifier_defaultOrigin")
,"initialize","""defaultOrigin
	" Private - Initialize the default origin. "

	(Smalltalk includesKey: #OrderedCollection) ifTrue: [ ^#VSE ].
	^#S8""",nil)

smalltalk.bind(smalltalk.Stringifier,"initializeOrigin",0
,smalltalk.__f__("""(self):
	#Stringifier>>#initializeOrigin
	def __blk1__():
		return self.defaultOrigin() 
	smalltalk.basic_at_put(self,"@origin",self.triggerEvent_ifNotHandled_(smalltalk.String("needsOrigin"),smalltalk.blk(__blk1__,0))) 
	return self 
""","Stringifier_initializeOrigin")
,"initialize","""initializeOrigin
	" Private - Initialize the origin (hosting platform). "

	origin := self
		triggerEvent: #needsOrigin
		ifNotHandled: [ self defaultOrigin ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"initializeRememberedSet",0
,smalltalk.__f__("""(self):
	#Stringifier>>#initializeRememberedSet
	def __blk1__():
		return smalltalk.IdentityDictionary.new() 
	def __blk2__():
		return self 
	smalltalk.basic_at_put(self,"@rememberedSet",smalltalk.if_true_false_(smalltalk.Smalltalk.includesKey_(smalltalk.String("IdentityDictionary")),smalltalk.blk(__blk1__,0),smalltalk.blk(__blk2__,0))) 
	return self 
""","Stringifier_initializeRememberedSet")
,"initialize","""initializeRememberedSet
	" Private - Initialize the walked objects cache. "

	rememberedSet := (Smalltalk includesKey: #IdentityDictionary)
		ifTrue: [ IdentityDictionary new ]
		ifFalse: [ self ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"reset",0
,smalltalk.__f__("""(self):
	#Stringifier>>#reset
	self.triggerEvent_(smalltalk.String("aboutToReset")) 
	self.forgetObjects() 
	smalltalk.basic_at_put(self,"@rememberedSet",smalltalk.basic_at_put(self,"@id",nil)) 
	self.triggerEvent_(smalltalk.String("reset")) 
	return self 
""","Stringifier_reset")
,"configuration","""reset
	" Private - Reset the receiver to initial state. "

	self triggerEvent: #aboutToReset.
	self forgetObjects.
	rememberedSet := id := nil.
	self triggerEvent: #reset""",nil)

smalltalk.bind(smalltalk.Stringifier,"close",0
,smalltalk.__f__("""(self):
	#Stringifier>>#close
	self.triggerEvent_(smalltalk.String("aboutToClose")) 
	self.reset() 
	return self 
""","Stringifier_close")
,"configuration","""close
	" Private - Close the receiver.
	REQUIRED in platforms where there is no support for IdentityDictionary (e.g. S8 systems). "

	self triggerEvent: #aboutToClose.
	self reset.""",nil)

smalltalk.bind(smalltalk.Stringifier,"initializeObjectHandlers",0
,smalltalk.__f__("""(self):
	#Stringifier>>#initializeObjectHandlers
	def __blk1__():
		return smalltalk.PoolDictionary.new() 
	def __blk2__():
		def __blk3__():
			return self.initializeS8ObjectHandlers() 
		if smalltalk.b(smalltalk.isObject_equalTo_(self.origin(),smalltalk.String("VSE"))):
			self.initializeVSEObjectHandlers() 
		 
		return smalltalk.if_true_false_(smalltalk.isObject_equalTo_(getattr(self,"@origin",nil),smalltalk.String("S8")),smalltalk.blk(__blk3__,0),nil) 
	smalltalk.basic_at_put(self,"@objectHandlers",self.triggerEvent_ifNotHandled_(smalltalk.String("needsObjectHandlers"),smalltalk.blk(__blk1__,0))) 
	self.triggerEvent_ifNotHandled_(smalltalk.String("objectHandlersContents"),smalltalk.blk(__blk2__,0)) 
	return self 
""","Stringifier_initializeObjectHandlers")
,"configuration","""initializeObjectHandlers
	" Private - Initialize the handlers to map objects. "

	objectHandlers := self
		triggerEvent: #needsObjectHandlers
		ifNotHandled: [ PoolDictionary new ].
	self triggerEvent: #objectHandlersContents ifNotHandled: [
		self origin = #VSE ifTrue: [ self initializeVSEObjectHandlers ].
		origin = #S8 ifTrue: [ self initializeS8ObjectHandlers ].
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"cantHandleBlock",0
,smalltalk.__f__("""(self):
	#Stringifier>>#cantHandleBlock
	def __blk1__(object,my):
		return my.error_(smalltalk.object_comma_(smalltalk.String("Can't handle instances of "),(object).__class__.name())) 
	return smalltalk.blk(__blk1__,2) 
""","Stringifier_cantHandleBlock")
,"handlers","""cantHandleBlock
	" Private - Returns the block to use when the receiver do NOT handle an object. "

	^[:object :my| my error: 'Can''t handle instances of ' ,object class name ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"defaultHandleBlock",0
,smalltalk.__f__("""(self):
	#Stringifier>>#defaultHandleBlock
	def __blk1__(anObject,my):
		return my.basicMapForObject_(anObject) 
	return smalltalk.blk(__blk1__,2) 
""","Stringifier_defaultHandleBlock")
,"handlers","""defaultHandleBlock
	" Private - Returns the block to handle objects. "

	^[:anObject :my| my basicMapForObject: anObject ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"dictionaryHandleBlock",0
,smalltalk.__f__("""(self):
	#Stringifier>>#dictionaryHandleBlock
	def __blk1__(anObject,my):
		__1__=smalltalk.newContext()
		__1__.result=nil
		__1__.ref=nil
		__1__.result=my.newMapForObject_(anObject) 
		__1__.ref=self.mapForArray_(self.associationsIn_(anObject)) 
		__1__.result.at_put_(smalltalk.String("associations"),__1__.ref) 
		return __1__.result 
	return smalltalk.blk(__blk1__,2) 
""","Stringifier_dictionaryHandleBlock")
,"handlers","""dictionaryHandleBlock
	" Private - Returns the block to handle dictionaries. "

	^[:anObject :my| | result ref |
		result := my newMapForObject: anObject.
		ref := self mapForArray: (self associationsIn: anObject).
		result at: #associations put: ref.
		result
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"asArrayHandleBlock",0
,smalltalk.__f__("""(self):
	#Stringifier>>#asArrayHandleBlock
	def __blk1__(anObject,my):
		__1__=smalltalk.newContext()
		__1__.result=nil
		__1__.ref=nil
		__1__.result=my.newMapForObject_(anObject) 
		__1__.ref=self.mapForArray_(anObject.asArray()) 
		__1__.result.at_put_(smalltalk.String("contents"),__1__.ref) 
		return __1__.result 
	return smalltalk.blk(__blk1__,2) 
""","Stringifier_asArrayHandleBlock")
,"handlers","""asArrayHandleBlock
	" Private - Returns the block to handle arrayable collections. "

	^[:anObject :my| | result ref |
		result := my newMapForObject: anObject.
		ref := self mapForArray: anObject asArray.
		result at: #contents put: ref.
		result
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"bytesHandleBlock",0
,smalltalk.__f__("""(self):
	#Stringifier>>#bytesHandleBlock
	def __blk1__(anObject,my):
		__1__=smalltalk.newContext()
		__1__.result=nil
		__1__.ref=nil
		__1__.result=my.newMapForObject_(anObject) 
		__1__.ref=self.mapForArray_(anObject.notImplementedYet_(smalltalk.String("bytesHandleBlock"))) 
		__1__.result.at_put_(smalltalk.String("contents"),__1__.ref) 
		return __1__.result 
	return smalltalk.blk(__blk1__,2) 
""","Stringifier_bytesHandleBlock")
,"handlers","""bytesHandleBlock
	" Private - Returns the block to handle objects. "

	^[:anObject :my| | result ref |
		result := my newMapForObject: anObject.
		ref := self mapForArray: (anObject notImplementedYet: #bytesHandleBlock).
		result at: #contents put: ref.
		result
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"timeStampHandleBlock",0
,smalltalk.__f__("""(self):
	#Stringifier>>#timeStampHandleBlock
	def __blk1__(timeStamp,my):
		__1__=smalltalk.newContext()
		__1__.result=nil
		__1__.ref=nil
		__1__.time=nil
		__1__.result=my.newMapForObject_(timeStamp) 
		__1__.time=timeStamp.time() 
		__1__.ref=smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(timeStamp.date().printInFormat_twoDigitYear_(smalltalk.String("YYYY/mm/dd"),smalltalk.false),smalltalk.String(" ")),smalltalk.asString_(__1__.time.hours())),smalltalk.String(":")),smalltalk.asString_(__1__.time.minutes())),smalltalk.String(":")),smalltalk.asString_(__1__.time.seconds())) 
		__1__.result.at_put_(smalltalk.String("contents"),__1__.ref) 
		return __1__.result 
	return smalltalk.blk(__blk1__,2) 
""","Stringifier_timeStampHandleBlock")
,"handlers","""timeStampHandleBlock
	" Private - Returns the block to handle instances of TimeStamp. "

	^[:timeStamp :my| | result ref time | "we save literal representation"
		result := my newMapForObject: timeStamp.
		time := timeStamp time.
		ref := (timeStamp date printInFormat: 'YYYY/mm/dd' twoDigitYear: false)
			,' ' ,time hours asString
			,':' ,time minutes asString
			,':' ,time seconds asString.
		result at: #contents put: ref.
		result
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"dateTimeHandleBlock",0
,smalltalk.__f__("""(self):
	#Stringifier>>#dateTimeHandleBlock
	def __blk1__(dateTime,my):
		__1__=smalltalk.newContext()
		__1__.result=nil
		__1__.ref=nil
		__1__.date=nil
		__1__.result=my.newMapForObject_(dateTime) 
		__1__.date=smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.String(""),dateTime.year()),smalltalk.String("/")),dateTime.month()),smalltalk.String("/")),dateTime.dayOfMonth()) 
		__1__.ref=smalltalk.object_comma_(smalltalk.object_comma_(__1__.date,smalltalk.String(" ")),dateTime.asTimeString().upTo_(smalltalk.String(" "))) 
		__1__.result.at_put_(smalltalk.String("contents"),__1__.ref) 
		return __1__.result 
	return smalltalk.blk(__blk1__,2) 
""","Stringifier_dateTimeHandleBlock")
,"handlers","""dateTimeHandleBlock
	" Private - Returns the block to handle instances of DateTime. "

	^[:dateTime :my| | result ref date | "we save literal representation"
		result := my newMapForObject: dateTime.
		date := '' ,dateTime year ,$/ ,dateTime month ,$/ ,dateTime dayOfMonth.
		ref := date ,' ' ,(dateTime asTimeString upTo: $ ).
		result at: #contents put: ref.
		result
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"classNamed:",0
,smalltalk.__f__("""(self,aName):
	#Stringifier>>#classNamed:
	def __blk1__():
		nil 
	return smalltalk.Smalltalk.at_ifAbsent_(aName,smalltalk.blk(__blk1__,0)) 
""","Stringifier_classNamed_")
,"private","""classNamed: aName
	" Private - Returns the class named aName (or nil). "

	^Smalltalk at: aName ifAbsent: [ ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"handleMembersOf:with:",0
,smalltalk.__f__("""(self,aClass,aBlock):
	#Stringifier>>#handleMembersOf:with:
	def __blk1__():
		return getattr(self,"@objectHandlers",nil).at_put_(aClass.name(),aBlock) 
	if smalltalk.b(aClass.isString()):
		return self.handleMembersOf_with_(self.classNamed_(aClass),aBlock) 
	 
	return smalltalk.if_true_false_(smalltalk.notNil_(aClass),smalltalk.blk(__blk1__,0),nil) 
""","Stringifier_handleMembersOf_with_")
,"configuration","""handleMembersOf: aClass with: aBlock
	" Private - Set the receiver to handle instances of aClass. "

	aClass isString ifTrue: [ ^self handleMembersOf: (self classNamed: aClass) with: aBlock ].
	^aClass notNil ifTrue: [ objectHandlers at: aClass name put: aBlock ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"handleInstancesOf:with:",0
,smalltalk.__f__("""(self,aClass,aBlock):
	#Stringifier>>#handleInstancesOf:with:
	def __blk1__():
		def __blk2__(cls):
			return getattr(self,"@objectHandlers",nil).at_put_(cls.name(),aBlock) 
		return aClass.withAllSubclasses().do_(smalltalk.blk(__blk2__,1)) 
	if smalltalk.b(aClass.isString()):
		return self.handleInstancesOf_with_(self.classNamed_(aClass),aBlock) 
	 
	return smalltalk.if_true_false_(smalltalk.notNil_(aClass),smalltalk.blk(__blk1__,0),nil) 
""","Stringifier_handleInstancesOf_with_")
,"configuration","""handleInstancesOf: aClass with: aBlock
	" Private - Set the receiver to handle instances of aClass and subclasses. "

	aClass isString ifTrue: [ ^self handleInstancesOf: (self classNamed: aClass) with: aBlock ].
	^aClass notNil ifTrue: [
		aClass withAllSubclasses do: [:cls| objectHandlers at: cls name put: aBlock ]
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"cantHandleInstancesOf:",0
,smalltalk.__f__("""(self,aClass):
	#Stringifier>>#cantHandleInstancesOf:
	def __blk1__():
		return self.handleInstancesOf_with_(aClass,self.cantHandleBlock()) 
	if smalltalk.b(aClass.isArray()):
		def __blk2__(each):
			return self.cantHandleInstancesOf_(each) 
		return aClass.do_(smalltalk.blk(__blk2__,1)) 
	 
	if smalltalk.b(aClass.isString()):
		return self.cantHandleInstancesOf_(self.classNamed_(aClass)) 
	 
	return smalltalk.if_true_false_(smalltalk.notNil_(aClass),smalltalk.blk(__blk1__,0),nil) 
""","Stringifier_cantHandleInstancesOf_")
,"configuration","""cantHandleInstancesOf: aClass
	" Private - Set the receiver to do NOT handle instances of aClass and subclasses.
	Note that aClass can be a class, a name of a class or an array of classes/classNames "

	aClass isArray ifTrue: [ ^aClass do: [:each| self cantHandleInstancesOf: each ] ].
	aClass isString ifTrue: [ ^self cantHandleInstancesOf: (self classNamed: aClass) ].
	^aClass notNil ifTrue: [ self handleInstancesOf: aClass with: self cantHandleBlock ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"initializeVSEObjectHandlers",0
,smalltalk.__f__("""(self):
	#Stringifier>>#initializeVSEObjectHandlers
	def __blk1__(_s8_rec):
		_s8_rec.cantHandleInstancesOf_(smalltalk.newArray(["BlockClosure","CallBack","NotificationManager","Context","ExternalBuffer","ExternalHandle","FileSystemEntity","Font","Menu","FileStream","ViewManager","Window","WinLogicalObject"])) 
		_s8_rec.cantHandleInstancesOf_(smalltalk.String("Collection")) 
		_s8_rec.handleMembersOf_with_(smalltalk.String("Dictionary"),self.dictionaryHandleBlock()) 
		_s8_rec.handleMembersOf_with_(smalltalk.String("PoolDictionary"),self.dictionaryHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("Set"),self.asArrayHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("ActionSequence"),self.defaultHandleBlock()) 
		_s8_rec.cantHandleInstancesOf_(smalltalk.String("ByteArray")) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("Interval"),self.defaultHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("OrderedCollection"),self.asArrayHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("Array"),self.asArrayHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("TimeStamp"),self.timeStampHandleBlock()) 
		return _s8_rec.yourself() 
	__blk1__(self) 
	return self 
""","Stringifier_initializeVSEObjectHandlers")
,"configuration","""initializeVSEObjectHandlers
	" Private - Initialize the handlers to map VSE objects. "

	self	cantHandleInstancesOf: #(
			#BlockClosure #CallBack
			#NotificationManager
			#Context #ExternalBuffer
			#ExternalHandle #FileSystemEntity
			#Font #Menu #FileStream
			#ViewManager #Window
			#WinLogicalObject
		);
		cantHandleInstancesOf: #Collection; "abstract"
		handleMembersOf: #Dictionary with: self dictionaryHandleBlock;
		handleMembersOf: #PoolDictionary with: self dictionaryHandleBlock;
		handleInstancesOf: #Set with: self asArrayHandleBlock;
		handleInstancesOf: #ActionSequence with: self defaultHandleBlock;
		cantHandleInstancesOf: #ByteArray; "handleInstancesOf: #ByteArray with: self bytesHandleBlock;"
		handleInstancesOf: #Interval with: self defaultHandleBlock;
		handleInstancesOf: #OrderedCollection with: self asArrayHandleBlock;
		handleInstancesOf: #Array with: self asArrayHandleBlock;
		handleInstancesOf: #TimeStamp with: self timeStampHandleBlock;
		yourself""",nil)

smalltalk.bind(smalltalk.Stringifier,"initializeS8ObjectHandlers",0
,smalltalk.__f__("""(self):
	#Stringifier>>#initializeS8ObjectHandlers
	def __blk1__(_s8_rec):
		_s8_rec.cantHandleInstancesOf_(smalltalk.newArray(["BlockClosure","Context","CompiledMethod","CompilerNode","NativeObject","PPParser"])) 
		_s8_rec.cantHandleInstancesOf_(smalltalk.String("Collection")) 
		_s8_rec.handleMembersOf_with_(smalltalk.String("Dictionary"),self.dictionaryHandleBlock()) 
		_s8_rec.handleMembersOf_with_(smalltalk.String("PoolDictionary"),self.dictionaryHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("Set"),self.asArrayHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("ActionSequence"),self.defaultHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("Array"),self.asArrayHandleBlock()) 
		_s8_rec.handleInstancesOf_with_(smalltalk.String("DateTime"),self.dateTimeHandleBlock()) 
		return _s8_rec.yourself() 
	__blk1__(self) 
	return self 
""","Stringifier_initializeS8ObjectHandlers")
,"configuration","""initializeS8ObjectHandlers
	" Private - Initialize the handlers to map S8 objects. "

	self	cantHandleInstancesOf: #(
			#BlockClosure #Context
			#CompiledMethod #CompilerNode
			#NativeObject #PPParser
		);
		cantHandleInstancesOf: #Collection; "abstract"
		handleMembersOf: #Dictionary with: self dictionaryHandleBlock;
		handleMembersOf: #PoolDictionary with: self dictionaryHandleBlock;
		handleInstancesOf: #Set with: self asArrayHandleBlock;
		handleInstancesOf: #ActionSequence with: self defaultHandleBlock;
		handleInstancesOf: #Array with: self asArrayHandleBlock;
		handleInstancesOf: #DateTime with: self dateTimeHandleBlock;
		yourself""",nil)

smalltalk.bind(smalltalk.Stringifier,"prepareFor:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#prepareFor:
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@rememberedSet",nil))):
		self.initializeRememberedSet() 
	 
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@id",nil))):
		smalltalk.basic_at_put(self,"@id",getattr(self,"@rememberedSet",nil).size()._plus(smalltalk.Number(1))) 
	 
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@objectHandlers",nil))):
		self.initializeObjectHandlers() 
	 
	self.triggerEvent_with_(smalltalk.String("prepare:"),anObject) 
	return self 
""","Stringifier_prepareFor_")
,"configuration","""prepareFor: anObject
	" Private - Prepare the receiver to work on anObject. "

	rememberedSet isNil ifTrue: [ self initializeRememberedSet ].
	id isNil ifTrue: [ id := rememberedSet size + 1 ].
	objectHandlers isNil ifTrue: [ self initializeObjectHandlers ].
	self triggerEvent: #prepare: with: anObject""",nil)

smalltalk.bind(smalltalk.Stringifier,"@","_at"
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#@
	return self.literalForOne_(anObject) 
""","Stringifier__at")
,"accessing","""@ anObject
	" Returns the literal to send to target to obtain a copy of anObject.
	Close the receiver after encoding anObject. "

	^self literalForOne: anObject""",nil)

smalltalk.bind(smalltalk.Stringifier,"literalForOne:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#literalForOne:
	__0__=smalltalk.newContext()
	__0__.result=nil
	__0__.result=self.literalFor_(anObject) 
	self.close() 
	return __0__.result 
""","Stringifier_literalForOne_")
,"accessing","""literalForOne: anObject
	" Returns the literal to send to target to obtain a copy of anObject.
	Close the receiver after encoding anObject. "

	| result |
	result := self literalFor: anObject.
	self close.
	^result""",nil)

smalltalk.bind(smalltalk.Stringifier,"literalFor:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#literalFor:
	self.prepareFor_(anObject) 
	return self.stringify_object_(self.mapFor_(anObject),anObject) 
""","Stringifier_literalFor_")
,"accessing","""literalFor: anObject
	" Returns the literal to send to target to obtain a copy of anObject. "

	self prepareFor: anObject.
	^self stringify: (self mapFor: anObject) object: anObject""",nil)

smalltalk.bind(smalltalk.Stringifier,"stringifierFor:",0
,smalltalk.__f__("""(self,structure):
	_s8Ret_=smalltalk.newContext()
	try:
		#Stringifier>>#stringifierFor:
		if smalltalk.b(smalltalk.responds_to_(structure,(smalltalk.String("asJSON")))):
			__1__=smalltalk.newContext()
			def __blk1__():
				nil 
			def __blk2__():
				return smalltalk.raise_result_(_s8Ret_,smalltalk.String("asJSON")) 
			__1__.j=nil
			__1__.j=smalltalk.Smalltalk.nativeObjectAt_ifAbsent_(smalltalk.String("JSON"),smalltalk.blk(__blk1__,0)) 
			smalltalk.if_true_false_(smalltalk.notNil_(__1__.j),smalltalk.blk(__blk2__,0),nil) 
		 
		smalltalk.raise_result_(_s8Ret_,self) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Stringifier_stringifierFor_")
,"constants","""stringifierFor: structure
	" Returns the default stringifier to emmit structure.
	Note that on S8 we will use native JSON if present.
	If structure do not respondsTo #asJSON the receiver will format the output
	"

	(structure respondsTo: #asJSON) ifTrue: [ | j |
		j := Smalltalk nativeObjectAt: #JSON ifAbsent: [].
		j notNil ifTrue: [ ^#asJSON ]
	].
	^self""",nil)

smalltalk.bind(smalltalk.Stringifier,"stringify:object:",0
,smalltalk.__f__("""(self,aMap,anObject):
	#Stringifier>>#stringify:object:
	__0__=smalltalk.newContext()
	def __blk1__():
		return self.stringifierFor_(__0__.package) 
	__0__.package=nil
	__0__.stringifier=nil
	__0__.package=self.packageWith_(aMap) 
	__0__.stringifier=self.triggerEvent_ifNotHandled_(smalltalk.String("needsStringifier"),smalltalk.blk(__blk1__,0)) 
	if smalltalk.b(__0__.stringifier.isString()):
		return __0__.package.perform_(__0__.stringifier) 
	 
	return __0__.stringifier.stringify_(__0__.package) 
""","Stringifier_stringify_object_")
,"stringify","""stringify: aMap object: anObject
	" Private - Returns a string literal from aMap. "

	| package stringifier |
	package := self packageWith: aMap.
	stringifier := self
		triggerEvent: #needsStringifier
		ifNotHandled: [ self stringifierFor: package ].
	stringifier isString ifTrue: [ ^package perform: stringifier ].
	^stringifier stringify: package""",nil)

smalltalk.bind(smalltalk.Stringifier,"mapFor:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#mapFor:
	__0__=smalltalk.newContext()
	__0__.selector=nil
	__0__.selector=self.selectorFor_(anObject) 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.selector,smalltalk.String("literal"))):
		return self.mapForLiteral_(anObject) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.selector,smalltalk.String("array"))):
		return self.mapForArray_(anObject) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.selector,smalltalk.String("class"))):
		return self.referenceToClass_(anObject) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.selector,smalltalk.String("object"))):
		return self.mapForObject_(anObject) 
	 
	return self.error_(smalltalk.String("Invalid selector")) 
""","Stringifier_mapFor_")
,"mapping","""mapFor: anObject
	" Private - Returns the map to export anObject. "

	| selector |
	selector := self selectorFor: anObject.
	selector = #literal ifTrue: [ ^self mapForLiteral: anObject ].
	selector = #array ifTrue: [ ^self mapForArray: anObject ].
	selector = #class ifTrue: [ ^self referenceToClass: anObject ].
	selector = #object ifTrue: [ ^self mapForObject: anObject ].
	^self error: 'Invalid selector'""",nil)

smalltalk.bind(smalltalk.Stringifier,"selectorFor:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#selectorFor:
	def __blk1__():
		def __blk2__():
			def __blk3__():
				return smalltalk.b_(anObject is smalltalk.false) 
			return smalltalk.boolean_or_(smalltalk.b_(anObject is smalltalk.true),smalltalk.blk(__blk3__,0)) 
		return smalltalk.boolean_or_(anObject.isNumber(),smalltalk.blk(__blk2__,0)) 
	if smalltalk.b(smalltalk.isNil_(anObject)):
		return smalltalk.String("literal") 
	 
	if smalltalk.b(smalltalk.boolean_or_(anObject.isString(),smalltalk.blk(__blk1__,0))):
		return smalltalk.String("literal") 
	 
	if smalltalk.b(smalltalk.is_kindOf_(anObject,(smalltalk.Behavior))):
		return smalltalk.String("class") 
	 
	return smalltalk.String("object") 
""","Stringifier_selectorFor_")
,"mapping","""selectorFor: anObject
	" Private - Returns the keyword to represent anObject as a literal or well known object. "

	anObject isNil ifTrue: [ ^#literal ].
	(anObject isString
		or: [ anObject isNumber
		or: [ anObject == true
		or: [anObject == false]]]) ifTrue: [ ^#literal ].
	(anObject isKindOf: Behavior) ifTrue: [ ^#class ].
	^#object""",nil)

smalltalk.bind(smalltalk.Stringifier,"associationsIn:",0
,smalltalk.__f__("""(self,aDictionary):
	#Stringifier>>#associationsIn:
	__0__=smalltalk.newContext()
	def __blk1__(each):
		return aDictionary.associationAt_(each) 
	__0__.keys=nil
	__0__.keys=aDictionary.keys().asArray() 
	return __0__.keys.collect_(smalltalk.blk(__blk1__,1)) 
""","Stringifier_associationsIn_")
,"mapping","""associationsIn: aDictionary
	" Private - Returns the associations contained in aDictionary. "

	| keys |
	keys :=  aDictionary keys asArray.
	^keys collect: [:each| aDictionary associationAt: each ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"newMap",0
,smalltalk.__f__("""(self):
	#Stringifier>>#newMap
	def __blk1__(_s8_rec):
		_s8_rec.at_put_(smalltalk.String("id"),getattr(self,"@id",nil)) 
		return _s8_rec.yourself() 
	return __blk1__(smalltalk.PoolDictionary.new()) 
""","Stringifier_newMap")
,"mapping","""newMap
	" Private - Returns a new map to host current object id. "

	^PoolDictionary new
		at: #id put: id;
		yourself""",nil)

smalltalk.bind(smalltalk.Stringifier,"mapForLiteral:",0
,smalltalk.__f__("""(self,literal):
	#Stringifier>>#mapForLiteral:
	if smalltalk.b(literal.isNumber()):
		if smalltalk.b(smalltalk.b_((literal).__class__ is smalltalk.Number)):
			return literal 
		 
		if smalltalk.b(literal.isInteger()):
			return literal 
		 
		if smalltalk.b(literal.isFloat()):
			return self.mapForFloat_(literal) 
		 
		return self.mapForObject_(literal) 
	 
	if smalltalk.b(literal.isString()):
		return self.mapForString_(literal) 
	 
	return literal 
""","Stringifier_mapForLiteral_")
,"mapping","""mapForLiteral: literal
	" Private - Returns the map to export a literal. "

	literal isNumber ifTrue: [
		literal class == Number ifTrue: [ ^literal ].
		literal isInteger ifTrue: [ ^literal ].
		literal isFloat ifTrue: [ ^self mapForFloat: literal ].
		^self mapForObject: literal
	].
	literal isString ifTrue: [
		^self mapForString: literal
	].
	^literal""",nil)

smalltalk.bind(smalltalk.Stringifier,"mapForString:",0
,smalltalk.__f__("""(self,literal):
	#Stringifier>>#mapForString:
	def __blk1__():
		return smalltalk.object_comma_(self.tagStart(),literal) 
	def __blk2__():
		return literal 
	return smalltalk.if_true_false_(self.hasTag_(literal),smalltalk.blk(__blk1__,0),smalltalk.blk(__blk2__,0)) 
""","Stringifier_mapForString_")
,"mapping","""mapForString: literal
	" Private - Returns the map to export string literal. "

	^(self hasTag: literal) ifTrue: [self tagStart ,literal] ifFalse: [literal]""",nil)

smalltalk.bind(smalltalk.Stringifier,"mapForFloat:",0
,smalltalk.__f__("""(self,aFloat):
	#Stringifier>>#mapForFloat:
	return aFloat 
""","Stringifier_mapForFloat_")
,"mapping","""mapForFloat: aFloat
	" Private - Returns the map to export aFloat. "

	^aFloat""",nil)

smalltalk.bind(smalltalk.Stringifier,"mapForArray:",0
,smalltalk.__f__("""(self,anArray):
	#Stringifier>>#mapForArray:
	def __blk1__(each):
		return self.mapFor_(each) 
	return anArray.collect_(smalltalk.blk(__blk1__,1)) 
""","Stringifier_mapForArray_")
,"mapping","""mapForArray: anArray
	" Private - Returns the map to export anArray. "

	^anArray collect: [:each| self mapFor: each ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"referenceToClass:",0
,smalltalk.__f__("""(self,aClass):
	#Stringifier>>#referenceToClass:
	def __blk1__():
		__1__=smalltalk.newContext()
		__1__.ref=nil
		__1__.ivn=nil
		__1__.ref=self.newMap() 
		__1__.ref.at_put_(smalltalk.String("global"),self.nameOfClass_(aClass)) 
		__1__.ivn=aClass.allInstVarNames() 
		if smalltalk.b(__1__.ivn.notEmpty()):
			__1__.ref.at_put_(smalltalk.String("allInstVarNames"),__1__.ivn) 
		 
		return __1__.ref 
	return self.referenceTo_ifAbsent_(aClass,smalltalk.blk(__blk1__,0)) 
""","Stringifier_referenceToClass_")
,"mapping","""referenceToClass: aClass
	" Private - Returns the map to reference aClass in target system. "

	^self referenceTo: aClass ifAbsent: [ | ref ivn |
		ref := self newMap.
		ref at: #global put: (self nameOfClass: aClass).
		ivn := aClass allInstVarNames.
		ivn notEmpty ifTrue: [ ref at: #allInstVarNames put: ivn ].
		ref
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"nameOfClass:",0
,smalltalk.__f__("""(self,aClass):
	#Stringifier>>#nameOfClass:
	if smalltalk.b(aClass.isClass()):
		return aClass.name() 
	 
	return smalltalk.Array.with_with_(aClass.instanceClass().name(),smalltalk.String("class")) 
""","Stringifier_nameOfClass_")
,"mapping","""nameOfClass: aClass
	" Private - Returns a literal to reference aClass by name. "

	aClass isClass ifTrue: [ ^aClass name ].
	^Array with: aClass instanceClass name with: #class""",nil)

smalltalk.bind(smalltalk.Stringifier,"newMapForObject:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#newMapForObject:
	def __blk1__(_s8_rec):
		_s8_rec.at_put_(smalltalk.String("class"),self.referenceToClass_((anObject).__class__)) 
		return _s8_rec.yourself() 
	return __blk1__(self.newMap()) 
""","Stringifier_newMapForObject_")
,"mapping","""newMapForObject: anObject
	" Private - Returns a new/clean map literal to anObject structure. "

	^self newMap
		at: #class put: (self referenceToClass: anObject class);
		yourself""",nil)

smalltalk.bind(smalltalk.Stringifier,"basicMapForObject:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#basicMapForObject:
	__0__=smalltalk.newContext()
	__0__.map=nil
	__0__.map=self.newMapForObject_(anObject) 
	self.storeFieldsOf_into_(anObject,__0__.map) 
	return __0__.map 
""","Stringifier_basicMapForObject_")
,"mapping","""basicMapForObject: anObject
	" Private - Returns a new map literal to anObject structure. "

	| map |
	map := self newMapForObject: anObject.
	self storeFieldsOf: anObject into: map.
	^map""",nil)

smalltalk.bind(smalltalk.Stringifier,"mapForObject:",0
,smalltalk.__f__("""(self,anObject):
	#Stringifier>>#mapForObject:
	def __blk1__():
		__1__=smalltalk.newContext()
		def __blk2__():
			def __blk3__():
				return __1__.none 
			return self.triggerEvent_withArguments_ifNotHandled_(smalltalk.String("needsHandlerFor:"),smalltalk.Array.with_((anObject).__class__),smalltalk.blk(__blk3__,0)) 
		def __blk4__():
			return self.basicMapForObject_(anObject) 
		def __blk5__():
			return __1__.mapper.value_value_(anObject,self) 
		__1__.none=nil
		__1__.mapper=nil
		__1__.none=smalltalk.String("none") 
		__1__.mapper=getattr(self,"@objectHandlers",nil).at_ifAbsentPut_((anObject).__class__.name(),smalltalk.blk(__blk2__,0)) 
		return smalltalk.if_true_false_(smalltalk.isObject_equalTo_(__1__.mapper,__1__.none),smalltalk.blk(__blk4__,0),smalltalk.blk(__blk5__,0)) 
	return self.referenceTo_ifAbsent_(anObject,smalltalk.blk(__blk1__,0)) 
""","Stringifier_mapForObject_")
,"mapping","""mapForObject: anObject
	" Private - Returns the map to export anObject. "

	^self referenceTo: anObject ifAbsent: [ | none mapper |
		none := #none.
		mapper := objectHandlers at: anObject class name ifAbsentPut: [
			self	triggerEvent: #needsHandlerFor:
				withArguments: (Array with: anObject class)
				ifNotHandled: [none]
		].
		mapper = none
			ifTrue: [ self basicMapForObject: anObject ]
			ifFalse: [ mapper value: anObject value: self ]
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"storeFieldsOf:into:",0
,smalltalk.__f__("""(self,anObject,map):
	#Stringifier>>#storeFieldsOf:into:
	if smalltalk.b(smalltalk.isObject_equalTo_(self.origin(),smalltalk.String("VSE"))):
		return self.storeVSEFieldsOf_into_(anObject,map) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(getattr(self,"@origin",nil),smalltalk.String("S8"))):
		return self.storeS8FieldsOf_into_(anObject,map) 
	 
	return self.error_(smalltalk.String("Unsupported origin")) 
""","Stringifier_storeFieldsOf_into_")
,"mapping","""storeFieldsOf: anObject into: map
	" Private - Store the contents of anObject into map. "

	self origin = #VSE ifTrue: [ ^self storeVSEFieldsOf: anObject into: map ].
	origin = #S8 ifTrue: [ ^self storeS8FieldsOf: anObject into: map ].
	^self error: 'Unsupported origin' """,nil)

smalltalk.bind(smalltalk.Stringifier,"storeVSEFieldsOf:into:",0
,smalltalk.__f__("""(self,anObject,map):
	#Stringifier>>#storeVSEFieldsOf:into:
	def __blk1__(i):
		return map.at_put_(i,self.mapFor_(anObject.instVarAt_(i))) 
	smalltalk.Number(1).to_do_((anObject).__class__.instSize(),smalltalk.blk(__blk1__,1)) 
	return self 
""","Stringifier_storeVSEFieldsOf_into_")
,"mapping","""storeVSEFieldsOf: anObject into: map
	" Private - Store the contents of anObject into map. "

	1 to: anObject class instSize do: [:i|
		map at: i put: (self mapFor: (anObject instVarAt: i))
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"storeS8FieldsOf:into:",0
,smalltalk.__f__("""(self,anObject,map):
	#Stringifier>>#storeS8FieldsOf:into:
	def __blk1__(each,i):
		return map.at_put_(i,self.mapFor_(anObject.instVarAt_(each))) 
	(anObject).__class__.allInstVarNames().withIndexDo_(smalltalk.blk(__blk1__,2)) 
	return self 
""","Stringifier_storeS8FieldsOf_into_")
,"mapping","""storeS8FieldsOf: anObject into: map
	" Private - Store the contents of anObject into map. "

	anObject class allInstVarNames withIndexDo: [:each :i|
		map at: i put: (self mapFor: (anObject instVarAt: each))
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"forgetObjects",0
,smalltalk.__f__("""(self):
	#Stringifier>>#forgetObjects
	if smalltalk.b(smalltalk.notNil_(getattr(self,"@markedObjects",nil))):
		__1__=smalltalk.newContext()
		def __blk1__(each):
			return each.basicDelete_(__1__.markID) 
		__1__.markID=nil
		__1__.markID=self.markID() 
		getattr(self,"@markedObjects",nil).do_(smalltalk.blk(__blk1__,1)) 
	 
	smalltalk.basic_at_put(self,"@markedObjects",nil) 
	return self 
""","Stringifier_forgetObjects")
,"cache","""forgetObjects
	" Private - Forget/unmark the rememebered objects. "

	markedObjects notNil ifTrue: [ | markID |
		markID := self markID.
		markedObjects do: [:each| each basicDelete: markID ]
	].
	markedObjects := nil""",nil)

smalltalk.bind(smalltalk.Stringifier,"referenceTo:ifAbsent:",0
,smalltalk.__f__("""(self,anObject,aBlock):
	#Stringifier>>#referenceTo:ifAbsent:
	def __blk1__():
		getattr(self,"@rememberedSet",nil).at_put_(anObject,self.newReference()) 
		return aBlock.value() 
	return getattr(self,"@rememberedSet",nil).at_ifAbsent_(anObject,smalltalk.blk(__blk1__,0)) 
""","Stringifier_referenceTo_ifAbsent_")
,"cache","""referenceTo: anObject ifAbsent: aBlock
	" Private - Save a new reference ID for anObject. "

	^rememberedSet at: anObject ifAbsent: [
		rememberedSet at: anObject put: self newReference.
		aBlock value
	]""",nil)

smalltalk.bind(smalltalk.Stringifier,"newReference",0
,smalltalk.__f__("""(self):
	#Stringifier>>#newReference
	smalltalk.basic_at_put(self,"@id",getattr(self,"@id",nil)._plus(smalltalk.Number(1))) 
	return smalltalk.object_comma_(self.tagStart(),smalltalk.asString_(getattr(self,"@id",nil))) 
""","Stringifier_newReference")
,"cache","""newReference
	" Private - Returns a new reference literal. "

	id := id + 1.
	^self tagStart ,id asString""",nil)

smalltalk.bind(smalltalk.Stringifier,"at:ifAbsent:",0
,smalltalk.__f__("""(self,anObject,aBlock):
	#Stringifier>>#at:ifAbsent:
	return smalltalk.basic_at_ifAbsent_(anObject,self.markID(),aBlock) 
""","Stringifier_at_ifAbsent_")
,"cache","""at: anObject ifAbsent: aBlock
	" Private - Returns the value catched for anObject or the result of evaluating aBlock.
	This implementation is a default implementation for marking objects while walking when there is no support for IdentityDictionary.
	"

	^anObject basicAt: self markID ifAbsent: aBlock""",nil)

smalltalk.bind(smalltalk.Stringifier,"at:put:",0
,smalltalk.__f__("""(self,anObject,aValue):
	#Stringifier>>#at:put:
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@markedObjects",nil))):
		smalltalk.basic_at_put(self,"@markedObjects",smalltalk.newArray([])) 
	 
	getattr(self,"@markedObjects",nil).add_(anObject) 
	smalltalk.basic_at_put_(anObject,self.markID(),aValue) 
	return aValue 
""","Stringifier_at_put_")
,"cache","""at: anObject put: aValue
	" Private - Set the value catched for anObject.
	This implementation is a default implementation for marking objects while walking when there is no support for IdentityDictionary.
	"

	markedObjects isNil ifTrue: [ markedObjects := #() ].
	markedObjects add: anObject.
	anObject basicAt: self markID put: aValue.
	^aValue""",nil)

smalltalk.bind(smalltalk.Stringifier,"writeStream",0
,smalltalk.__f__("""(self):
	#Stringifier>>#writeStream
	if smalltalk.b(smalltalk.isObject_equalTo_(getattr(self,"@origin",nil),smalltalk.String("VSE"))):
		return smalltalk.String("").asStream() 
	 
	return smalltalk.String("").stream() 
""","Stringifier_writeStream")
,"private","""writeStream
	" Private - Returns new write stream. "

	origin = #VSE ifTrue: [ ^'' asStream ].
	^'' stream""",nil)

smalltalk.bind(smalltalk.Stringifier,"stringify:",0
,smalltalk.__f__("""(self,aMap):
	#Stringifier>>#stringify:
	__0__=smalltalk.newContext()
	__0__.stream=nil
	__0__.stream=self.writeStream() 
	self.stringify_into_(aMap,__0__.stream) 
	return __0__.stream.contents() 
""","Stringifier_stringify_")
,"stringify","""stringify: aMap
	" Private - Returns a string literal from map. "

	| stream |
	stream := self writeStream.
	self stringify: aMap into: stream.
	^stream contents""",nil)

smalltalk.bind(smalltalk.Stringifier,"packageWith:",0
,smalltalk.__f__("""(self,aMap):
	#Stringifier>>#packageWith:
	def __blk1__(_s8_rec):
		_s8_rec.at_put_(smalltalk.String("origin"),self.origin()) 
		_s8_rec.at_put_(smalltalk.String("id"),getattr(self,"@id",nil)) 
		_s8_rec.at_put_(smalltalk.String("contents"),aMap) 
		return _s8_rec.yourself() 
	return __blk1__(smalltalk.PoolDictionary.new()) 
""","Stringifier_packageWith_")
,"stringify","""packageWith: aMap
	" Private - Returns aMap wrapped with information of the receiver. "

	^PoolDictionary new
		at: #origin put: self origin;
		at: #id put: id;
		at: #contents put: aMap;
		yourself""",nil)

smalltalk.bind(smalltalk.Stringifier,"printFloat:into:",0
,smalltalk.__f__("""(self,literal,stream):
	#Stringifier>>#printFloat:into:
	literal.printOn_decimalSeparator_(stream,smalltalk.String(".")) 
	return self 
""","Stringifier_printFloat_into_")
,"formating","""printFloat: literal into: stream
	" Private - Dump literal formated as JSON. "

	literal printOn: stream decimalSeparator: '.'""",nil)

smalltalk.bind(smalltalk.Stringifier,"hasTag:",0
,smalltalk.__f__("""(self,literal):
	_s8Ret_=smalltalk.newContext()
	try:
		#Stringifier>>#hasTag:
		__0__=smalltalk.newContext()
		def __blk1__(i):
			def __blk2__():
				return smalltalk.raise_result_(_s8Ret_,smalltalk.false) 
			return smalltalk.if_true_false_(smalltalk.isObject_equalTo_(__0__.tag.at_(i),literal.at_(i)),nil,smalltalk.blk(__blk2__,0)) 
		__0__.tag=nil
		__0__.tag=self.tagStart() 
		if smalltalk.b(smalltalk.isObject_equalTo_(self.origin(),smalltalk.String("S8"))):
			smalltalk.raise_result_(_s8Ret_,literal.startsWith_(__0__.tag)) 
		 
		if smalltalk.b(__0__.tag.size()._gt(literal.size())):
			smalltalk.raise_result_(_s8Ret_,smalltalk.false) 
		 
		smalltalk.Number(1).to_do_(__0__.tag.size(),smalltalk.blk(__blk1__,1)) 
		smalltalk.raise_result_(_s8Ret_,smalltalk.true) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Stringifier_hasTag_")
,"formating","""hasTag: literal
	" Private - Returns true if the literal starts with tagStart. "

	| tag |
	tag := self tagStart.
	self origin = #S8 ifTrue: [ ^literal startsWith: tag ].
	tag size > literal size ifTrue: [ ^false ].
	1 to: tag size do: [:i|
		(tag at: i) = (literal at: i) ifFalse: [ ^false ]
	].
	^true""",nil)

smalltalk.bind(smalltalk.Stringifier,"jsonEscapeUnicode:",0
,smalltalk.__f__("""(self,ascii):
	#Stringifier>>#jsonEscapeUnicode:
	return smalltalk.object_comma_(smalltalk.String("u"),ascii.printPaddedWith_to_base_(smalltalk.String("0"),smalltalk.Number(4),smalltalk.Number(16))) 
""","Stringifier_jsonEscapeUnicode_")
,"formating","""jsonEscapeUnicode: ascii
	" Private - Returns the escape sequence for unicode value. "

	^'u' ,(ascii printPaddedWith: $0 to: 4 base: 16)""",nil)

smalltalk.bind(smalltalk.Stringifier,"jsonEscape:char:",0
,smalltalk.__f__("""(self,ascii,c):
	_s8Ret_=smalltalk.newContext()
	try:
		#Stringifier>>#jsonEscape:char:
		def __blk1__(tuple):
			def __blk2__():
				return smalltalk.raise_result_(_s8Ret_,tuple.last()) 
			return smalltalk.if_true_false_(smalltalk.isObject_equalTo_(tuple.first(),ascii),smalltalk.blk(__blk2__,0),nil) 
		smalltalk.newArray([[10,"n"],[13,"r"],[9,"t"],[12,"f"],[8,"b"]]).do_(smalltalk.blk(__blk1__,1)) 
		if not smalltalk.b(ascii.between_and_(smalltalk.Number(32),smalltalk.Number(126))):
			smalltalk.raise_result_(_s8Ret_,self.jsonEscapeUnicode_(ascii)) 
		 
		smalltalk.raise_result_(_s8Ret_,smalltalk.String.with_(c)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","Stringifier_jsonEscape_char_")
,"formating","""jsonEscape: ascii char: c
	" Private - Returns the escape sequence for ascii code. "

	#( #(10 n) #(13 r) #(9 t) #(12 f) #(8 b) ) do: [:tuple|
		tuple first = ascii ifTrue: [ ^tuple last ]
	].
	(ascii between: 32 and: 126) ifFalse: [
		^self jsonEscapeUnicode: ascii
	].
	^String with: c""",nil)

smalltalk.bind(smalltalk.Stringifier,"jsonEncodeChar:into:",0
,smalltalk.__f__("""(self,c,stream):
	#Stringifier>>#jsonEncodeChar:into:
	__0__=smalltalk.newContext()
	def __blk1__():
		def __blk2__():
			return smalltalk.newArray([34,92,47]).includes_(__0__.ascii) 
		return smalltalk.boolean_or_(__0__.ascii._gt(smalltalk.Number(126)),smalltalk.blk(__blk2__,0)) 
	__0__.ascii=nil
	__0__.ascii=c.asciiValue() 
	if smalltalk.b(smalltalk.boolean_or_(__0__.ascii._lt(smalltalk.Number(32)),smalltalk.blk(__blk1__,0))):
		def __blk3__(_s8_rec):
			_s8_rec.nextPut_(smalltalk.String("\\\\")) 
			return _s8_rec.nextPutAll_(self.jsonEscape_char_(__0__.ascii,c)) 
		__blk3__(stream) 
	else:
		stream.nextPut_(c) 
	 
	return self 
""","Stringifier_jsonEncodeChar_into_")
,"formating","""jsonEncodeChar: c into: stream
	" Private - Encode character c into stream.
	See https://www.json.org/
	"

	| ascii |
	ascii := c asciiValue.
	(ascii < 32 or: [ascii > 126 or: [ #(34 92 47) includes: ascii ]])
	ifTrue: [ stream nextPut: $\\; nextPutAll: (self jsonEscape: ascii char: c) ]
	ifFalse: [ stream nextPut: c ]""",nil)

smalltalk.bind(smalltalk.Stringifier,"printString:into:",0
,smalltalk.__f__("""(self,literal,stream):
	#Stringifier>>#printString:into:
	def __blk1__(c):
		return self.jsonEncodeChar_into_(c,stream) 
	stream.nextPut_(smalltalk.String('"')) 
	smalltalk.asString_(literal).do_(smalltalk.blk(__blk1__,1)) 
	stream.nextPut_(smalltalk.String('"')) 
	return self 
""","Stringifier_printString_into_")
,"formating","""printString: literal into: stream
	" Private - Dump literal formated as JSON. "

	stream nextPut: $".
	literal asString do: [:c| self jsonEncodeChar: c into: stream ].
	stream nextPut: $\"""",nil)

smalltalk.bind(smalltalk.Stringifier,"stringify:into:",0
,smalltalk.__f__("""(self,literal,stream):
	#Stringifier>>#stringify:into:
	def __blk1__():
		return smalltalk.isObject_equalTo_((literal).__class__.name(),smalltalk.String("Float")) 
	if smalltalk.b(smalltalk.isNil_(literal)):
		return stream.nextPutAll_(smalltalk.String("null")) 
	 
	if smalltalk.b(literal.isArray()):
		def __blk2__(each):
			return self.stringify_into_(each,stream) 
		def __blk3__():
			return stream.nextPut_(smalltalk.String(",")) 
		stream.nextPut_(smalltalk.String("[")) 
		literal.do_andBetweenDo_(smalltalk.blk(__blk2__,1),smalltalk.blk(__blk3__,0)) 
		stream.nextPut_(smalltalk.String("]")) 
		return self 
	 
	if smalltalk.b(literal.isMemberOf_(smalltalk.PoolDictionary)):
		def __blk4__(key):
			self.printString_into_(key,stream) 
			stream.nextPut_(smalltalk.String(":")) 
			return self.stringify_into_(literal.at_(key),stream) 
		def __blk5__():
			return stream.nextPut_(smalltalk.String(",")) 
		stream.nextPut_(smalltalk.String("{")) 
		literal.keys().do_andBetweenDo_(smalltalk.blk(__blk4__,1),smalltalk.blk(__blk5__,0)) 
		stream.nextPut_(smalltalk.String("}")) 
		return self 
	 
	if smalltalk.b(literal.isString()):
		return self.printString_into_(literal,stream) 
	 
	if smalltalk.b(smalltalk.boolean_and_(literal.isNumber(),smalltalk.blk(__blk1__,0))):
		return self.printFloat_into_(literal,stream) 
	 
	stream.nextPutAll_(smalltalk.printString_(literal)) 
	return self 
""","Stringifier_stringify_into_")
,"stringify","""stringify: literal into: stream
	" Private - Dump literal onto stream. "

	literal isNil ifTrue: [ ^stream nextPutAll: #null ].
	literal isArray ifTrue: [
		stream nextPut: $[.
		literal	do: [:each| self stringify: each into: stream ]
			andBetweenDo: [ stream nextPut: $, ].
		stream nextPut: $].
		^self
	].
	(literal isMemberOf: PoolDictionary) ifTrue: [
		stream nextPut: ${.
		literal keys do: [:key|
			self printString: key into: stream.
			stream nextPut: $:.
			self stringify: (literal at: key) into: stream ]
			andBetweenDo: [ stream nextPut: $, ].
		stream nextPut: $}.
		^self
	].
	literal isString ifTrue: [
		^self printString: literal into: stream
	].
	(literal isNumber and: [literal class name = 'Float']) ifTrue: [
		^self printFloat: literal into: stream
	].
	stream nextPutAll: literal printString""",nil)
