Added README, licenses and copyright notices.
"
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"
#ifdef __SUPPORT_DIRECT_ILC
# define ILC struct inlineCacheForDirectCall
#else
# define ILC struct inlineCache
#endif
%}
! !
!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'!
at: index
| failureReason |
%{
INT _index;
INT _size;
INT _format;
if ( ! __isSmallInteger( index ) ) {
failureReason = @symbol(BadArg1);
goto error;
}
_index = __intVal(index) - 1;
if ( ! __isSmallInteger( __INST(size) ) ) {
failureReason = @symbol(BadSize);
goto error;
}
_size = __intVal(__INST(size));
if ( ! __isSmallInteger( __INST(format) ) ) {
failureReason = @symbol(BadFormat);
goto error;
}
_format = __intVal(__INST(format));
switch ( __intVal( __INST(format) ) ) {
case SectionFormatOBJVector:
{
if ( (_index < 0) || ( _index >= (_size / sizeof(OBJ)) ) ) {
failureReason = @symbol(BadArg1OutOfBounds);
goto error;
}
OBJ *vector = (OBJ*)(__externalAddressVal(self));
RETURN ( vector[_index] );
}
break;
case SectionFormatINTVector:
{
if ( (_index < 0) || ( _index >= (_size / sizeof(INT)) ) ) {
failureReason = @symbol(BadArg1OutOfBounds);
goto error;
}
INT *vector = (INT*)(__externalAddressVal(self));
if (__ISVALIDINTEGER( vector[_index] ) ) {
RETURN ( __mkSmallInteger( vector[_index] ) );
} else {
RETURN ( __MKLARGEINT( vector[_index] ) );
}
}
break;
case SectionFormatILCVector:
{
if ( (_index < 0) || ( _index >= (_size / sizeof(ILC)) ) ) {
failureReason = @symbol(BadArg1OutOfBounds);
goto error;
}
ILC *vector = (ILC*)(__externalAddressVal(self));
failureReason = @symbol(NotYetSupported);
goto error;
}
break;
case SectionFormatBytes:
case SectionFormatText:
{
if ( (_index < 0) || ( _index >= _size ) ) {
failureReason = @symbol(BadArg1OutOfBounds);
goto error;
}
char *vector = (char*)(__externalAddressVal(self));
RETURN ( __mkSmallInteger( vector[_index] ) );
}
break;
}
error:;
%}.
^ self primitiveFailed: failureReason
!
at: index put: value
| failureReason |
%{
INT _index;
INT _size;
INT _format;
if ( ! __isSmallInteger( index ) ) {
failureReason = @symbol(BadArg1);
goto error;
}
_index = __intVal(index) - 1;
if ( ! __isSmallInteger( __INST(size) ) ) {
failureReason = @symbol(BadSize);
goto error;
}
_size = __intVal(__INST(size));
if ( ! __isSmallInteger( __INST(format) ) ) {
failureReason = @symbol(BadFormat);
goto error;
}
_format = __intVal(__INST(format));
switch ( _format ) {
case SectionFormatOBJVector:
{
if ( (_index < 0) || ( _index >= (_size / sizeof(OBJ)) ) ) {
failureReason = @symbol(BadArg1OutOfBounds);
goto error;
}
if ( ! __isExternalAddress(__INST(object)) ) {
failureReason = @symbol(BadObject);
goto error;
}
OBJ *vector = (OBJ*)(__externalAddressVal(self));
vector[_index] = value;
stxCompiledCodeObjectOBJVectorModified(__externalAddressVal(__INST(object)));
RETURN ( value );
}
break;
case SectionFormatINTVector:
{
if ( (_index < 0) || ( _index >= (_size / sizeof(INT)) ) ) {
failureReason = @symbol(BadArg1OutOfBounds);
goto error;
}
INT *vector = (INT*)(__externalAddressVal(self));
INT _value;
if (__isSmallInteger(value)) {
_value = __intVal(value);
vector[_index] = _value;
RETURN ( value );
} else {
_value = __signedLongIntVal(value);
if (_value != 0) {
vector[_index] = _value;
RETURN ( value );
}
}
failureReason = @symbol(BadArg2);
goto error;
}
break;
case SectionFormatILCVector:
{
failureReason = @symbol(NotSupported);
goto error;
}
break;
case SectionFormatBytes:
case SectionFormatText:
{
if ( (_index < 0) || ( _index >= _size ) ) {
failureReason = @symbol(BadArg1OutOfBounds);
goto error;
}
char *vector = (char*)(__externalAddressVal(self));
if (__isSmallInteger(value)) {
INT _value = __intVal(value);
if ( (_value >= 0) && (_value <= 255) ) {
vector[_index] = (char)(_value & 0xFF);
RETURN ( value );
}
}
failureReason = @symbol(BadArg2);
goto error;
}
break;
}
error:;
%}.
^ self primitiveFailed: failureReason
!
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 | (Smalltalk at: #UDIS86) disassemble: self pc: self address on: s ] ];
yourself
"Created: / 11-12-2015 / 14:11:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 20-04-2016 / 21:19:07 / 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:
RETURN ( __MKSMALLINT( sz / sizeof(ILC) ) );
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> $'
! !