Allow single underscore as method / block argument and temporaries
This commit is a follow up for 38b221e.
"
COPYRIGHT (c) 1989 by Claus Gittinger / eXept Software AG
COPYRIGHT (c) 2016 Jan Vrany
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libcomp' }"
"{ NameSpace: Smalltalk }"
Object subclass:#DIEntry
instanceVariableNames:'size'
classVariableNames:''
poolDictionaries:''
category:'System-Compiler-Debug Info'
!
!DIEntry class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1989 by Claus Gittinger / eXept Software AG
COPYRIGHT (c) 2016 Jan Vrany
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
! !
!DIEntry class methodsFor:'reading & writing'!
decode: aStream
^ self new decode: aStream readStream; yourself.
"Created: / 10-07-2018 / 12:29:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 15-07-2018 / 12:10:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
decodeBoolean: aStream
^ aStream nextByte ~~ 0
"Created: / 10-07-2018 / 13:05:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
decodeString: aStream
| size value |
size := aStream nextUnsignedInt16MSB: UninterpretedBytes isBigEndian.
value := aStream next: size - 2"sizeof(size)".
^ CharacterArray decodeFromUTF8: value
"
DIEntry decodeString: (#[16r13 16r00] , 'aPackageStringArg' asByteArray) readStream
"
"Created: / 10-07-2018 / 13:05:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 10-07-2018 / 14:48:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
encodeBoolean: aBoolean on: aStream
aBoolean
ifTrue:[ aStream nextPutByte: 1 ]
ifFalse:[ aStream nextPutByte: 0 ].
"Created: / 15-07-2018 / 11:01:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
encodeString: aString on: aStream
| size bytes |
bytes := aString utf8Encoded asByteArray.
size := 2"sizeof(size)" + bytes size.
aStream nextPutInt16: size MSB: UninterpretedBytes isBigEndian.
aStream nextPutBytes: bytes.
"Created: / 15-07-2018 / 11:02:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 15-07-2018 / 12:08:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!DIEntry methodsFor:'reading & writing'!
decode: aStream
size := aStream nextUnsignedInt16MSB: UninterpretedBytes isBigEndian.
aStream skip: size - 16"sizeof(size)"
"Created: / 10-07-2018 / 12:29:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
encode: aStream
self subclassResponsibility
"Created: / 10-07-2018 / 12:29:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
encoding
^ ByteArray streamContents:[ :s | self encode: s ]
"Created: / 15-07-2018 / 11:06:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!DIEntry methodsFor:'reading & writing - private'!
encodeFinish: aStream
| pos |
pos := aStream position.
aStream position: size.
size := pos - size.
aStream nextPutInt16: size MSB: UninterpretedBytes isBigEndian.
aStream position: pos.
"Created: / 15-07-2018 / 10:49:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
encodePrepare: aStream
size := aStream position.
aStream nextPutByte: 0; nextPutByte: 0.
"Created: / 15-07-2018 / 10:48:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !