DIVariable.st
author Jan Vrany <jan.vrany@labware.com>
Thu, 27 Oct 2022 14:53:59 +0100
branchjv
changeset 4735 3b11fb3ede98
parent 4654 f001d36a3229
permissions -rw-r--r--
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
 COPYRIGHT (c) 2020 LabWare
              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 }"

DIEntry subclass:#DIVariable
	instanceVariableNames:'phy_block_source_offset lex_block_source_offset frame_offset
		is_argument name'
	classVariableNames:''
	poolDictionaries:''
	category:'System-Compiler-Debug Info'
!

!DIVariable class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1989 by Claus Gittinger / eXept Software AG
 COPYRIGHT (c) 2016 Jan Vrany
 COPYRIGHT (c) 2020 LabWare
              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.
"
! !

!DIVariable methodsFor:'accessing'!

frameOffset
    ^ frame_offset

    "Created: / 14-07-2018 / 20:53:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

frameOffset: anInteger
    anInteger > 255 ifTrue:[ self halt ].
    frame_offset := anInteger

    "Created: / 14-07-2018 / 20:53:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 24-07-2018 / 16:18:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isArgument
    ^ is_argument

    "Created: / 14-07-2018 / 20:53:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

isArgument: aBoolean
    is_argument := aBoolean

    "Created: / 14-07-2018 / 20:54:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

lexicalBlockSourceOffset
    ^ lex_block_source_offset

    "Created: / 07-02-2019 / 21:52:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

lexicalBlockSourceOffset: anInteger
    lex_block_source_offset := anInteger

    "Created: / 07-02-2019 / 21:52:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

name
    ^ name
!

name:aString
    self assert: aString isString.
    name := aString.

    "Modified: / 15-07-2018 / 15:12:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

physicalBlockSourceOffset
    ^ phy_block_source_offset

    "Created: / 06-02-2019 / 22:13:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

physicalBlockSourceOffset: anInteger
    phy_block_source_offset := anInteger

    "Created: / 06-02-2019 / 22:19:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!DIVariable methodsFor:'comparing'!

= another
    ^ self class == another class
        and:[ self physicalBlockSourceOffset = another physicalBlockSourceOffset
        and:[ self lexicalBlockSourceOffset = another lexicalBlockSourceOffset
        and:[ self isArgument = another isArgument
        and:[ self frameOffset = another frameOffset
        and:[ self name = another name ]]]]]

    "Created: / 09-06-2020 / 13:12:43 / Jan Vrany <jan.vrany@labware.com>"
!

hash
    ^ ((((phy_block_source_offset hash 
        bitXor: lex_block_source_offset hash)
        bitXor: frame_offset hash)
        bitXor: is_argument hash)
        bitXor: name hash)

    "Created: / 09-06-2020 / 13:10:51 / Jan Vrany <jan.vrany@labware.com>"
! !

!DIVariable methodsFor:'printing & storing'!

printOn: aStream
    super printOn: aStream.
    aStream nextPut: $(.
    frame_offset printOn: aStream base: 10 size: 2 fill: Character space.
    aStream space.
    name printOn: aStream.
    is_argument ifTrue:[ 
        aStream nextPutAll: ' (arg)'
    ].
    aStream nextPut: $).

    "Created: / 15-07-2018 / 15:27:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!DIVariable methodsFor:'reading & writing'!

decode: aStream
    size := aStream nextUnsignedInt16MSB: UninterpretedBytes isBigEndian.
    phy_block_source_offset := aStream nextUnsignedInt32MSB: UninterpretedBytes isBigEndian.
    lex_block_source_offset := aStream nextUnsignedInt32MSB: UninterpretedBytes isBigEndian.
    frame_offset := aStream nextByte.
    is_argument := DIEntry decodeBoolean: aStream.
    name := DIEntry decodeString: aStream.

    "Created: / 10-07-2018 / 13:05:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 07-02-2019 / 21:53:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

encode: aStream
    self encodePrepare: aStream.
    aStream nextPutInt32: phy_block_source_offset MSB: UninterpretedBytes isBigEndian.      
    aStream nextPutInt32: lex_block_source_offset MSB: UninterpretedBytes isBigEndian.      
    aStream nextPutByte: frame_offset.
    DIEntry encodeBoolean: is_argument on: aStream.
    DIEntry encodeString: name on: aStream.
    self encodeFinish: aStream.

    "Created: / 15-07-2018 / 11:00:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 07-02-2019 / 21:53:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !