Added CodeObjectSection>>size. Polished tests a bit.
"
COPYRIGHT (c) 2006 by eXept Software AG
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: 'jv:dragonfly' }"
"{ NameSpace: Smalltalk }"
ExternalBytes subclass:#CompiledCodeObjectSection
instanceVariableNames:'object name format'
classVariableNames:''
poolDictionaries:'CompiledCodeObjectSectionFormat'
category:'System-Compiler-Interface'
!
!CompiledCodeObjectSection primitiveDefinitions!
%{
/*
* includes, defines, structure definitions
* and typedefs come here.
*/
#include "../librun/mcompiler.h"
%}
! !
!CompiledCodeObjectSection class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2006 by eXept Software AG
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.
"
! !
!CompiledCodeObjectSection methodsFor:'accessing'!
format
^ format
!
name
^ name
!
object
^ object
! !
!CompiledCodeObjectSection methodsFor:'initialization'!
setObject: obj name: nm size: sz format: t
self setSize: sz.
object := obj.
name := nm.
format := t
"Created: / 11-12-2015 / 10:04:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompiledCodeObjectSection methodsFor:'inspecting'!
inspector2TabAssembly
<inspector2Tab>
format ~~ SectionFormatText ifTrue:[ ^ nil ].
(Smalltalk at: #UDIS86) isNil ifTrue:[
"/ Try to load the package...
[ Smalltalk loadPackage: 'jv:dragonfly/udis86sx' ] on: Error do:[ ^ nil ].
].
(Smalltalk at: #UDIS86) isNil ifTrue:[ ^ nil ].
^ (self newInspector2Tab)
label:'Assembly';
priority:36;
text:[ String streamContents: [ :s | UDIS86 disassemble: self pc: self address on: s ] ];
yourself
"Created: / 11-12-2015 / 14:11:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-12-2015 / 21:32:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompiledCodeObjectSection methodsFor:'printing & storing'!
displayOn:aGCOrStream
"return a printed representation of the receiver for displaying"
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
"/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
(aGCOrStream isStream) ifFalse:[
^ super displayOn:aGCOrStream
].
self printOn: aGCOrStream
"Created: / 07-12-2015 / 21:54:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
printOn:aStream
| addr |
addr := self address.
aStream nextPutAll: name.
aStream space.
aStream nextPutAll: '0x'.
addr printOn: aStream base: 16 size: ExternalAddress pointerSize fill: $0.
aStream nextPutAll: ' - 0x'.
(addr + size) printOn: aStream base: 16 size: ExternalAddress pointerSize fill: $0.
aStream nextPutAll: ' (size='.
size printOn: aStream.
aStream nextPutAll: ' format='.
format printOn: aStream.
aStream nextPutAll: ')'.
"Modified: / 11-01-2016 / 21:42:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompiledCodeObjectSection methodsFor:'queries'!
size
"Return logical size. For size in bytes, use #sizeInBytes"
%{
if ( __isSmallInteger( __INST(size) ) && __isSmallInteger( __INST(format) ) ) {
INT sz = __intVal( __INST(size) );
switch ( __intVal(__INST(format) ) ) {
case SectionFormatOBJVector:
RETURN ( __MKSMALLINT( sz / sizeof(OBJ) ) );
case SectionFormatINTVector:
RETURN ( __MKSMALLINT( sz / sizeof(INT) ) );
case SectionFormatILCVector:
# ifdef __SUPPORT_DIRECT_ILC
RETURN ( __MKSMALLINT( sz / sizeof(struct inlineCacheForDirectCall) ) );
# else
RETURN ( __MKSMALLINT( sz / sizeof(struct inlineCache) ) );
# endif
default:
RETURN ( __MKSMALLINT( sz ) );
}
}
%}.
self primitiveFailed
"Created: / 19-01-2016 / 21:21:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompiledCodeObjectSection class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !