ScummVM API documentation
Sci::Script Class Reference
Inheritance diagram for Sci::Script:
Sci::SegmentObj Common::Serializable

Public Member Functions

int getLocalsOffset () const
 
uint16 getLocalsCount () const
 
uint32 getScriptSize () const
 
uint32 getHeapSize () const
 
uint32 getBufSize () const
 
uint32 getHeapOffset () const
 
const byte * getBuf (uint offset=0) const
 
SciSpan< const byte > getSpan (uint offset) const
 
int getScriptNumber () const
 
SegmentId getLocalsSegment () const
 
reg_tgetLocalsBegin ()
 
void syncLocalsBlock (SegManager *segMan)
 
ObjMapgetObjectMap ()
 
const ObjMapgetObjectMap () const
 
bool offsetIsObject (uint32 offset) const
 
void freeScript (const bool keepLocalsSegment=false)
 
void load (int script_nr, ResourceManager *resMan, ScriptPatcher *scriptPatcher, bool applyScriptPatches=true)
 
bool isValidOffset (uint32 offset) const override
 
SegmentRef dereference (reg_t pointer) override
 
reg_t findCanonicAddress (SegManager *segMan, reg_t sub_addr) const override
 
void freeAtAddress (SegManager *segMan, reg_t sub_addr) override
 
Common::Array< reg_tlistAllDeallocatable (SegmentId segId) const override
 
Common::Array< reg_tlistAllOutgoingReferences (reg_t object) const override
 
Common::Array< reg_tlistObjectReferences () const
 
void saveLoadWithSerializer (Common::Serializer &ser) override
 
ObjectgetObject (uint32 offset)
 
const ObjectgetObject (uint32 offset) const
 
ObjectscriptObjInit (reg_t obj_pos, bool fullObjectInit=true)
 
void initializeLocals (SegManager *segMan)
 
void initializeClasses (SegManager *segMan)
 
void initializeObjects (SegManager *segMan, SegmentId segmentId, bool applyScriptPatches)
 
void incrementLockers ()
 
void decrementLockers ()
 
uint getLockers () const
 
void setLockers (uint lockers)
 
uint getExportsOffset () const
 
uint16 getExportsNr () const
 
const SciSpan< const byte > & getSynonyms () const
 
uint16 getSynonymsNr () const
 
uint32 validateExportFunc (int pubfunct, bool relocSci3)
 
void markDeleted ()
 
bool isMarkedAsDeleted () const
 
SciSpan< const byte > findBlockSCI0 (ScriptObjectTypes type, bool findLastBlock=false) const
 
void syncStringHeap (Common::Serializer &ser)
 
int getCodeBlockOffset ()
 
const offsetLookupArrayTypegetOffsetArray ()
 
uint16 getOffsetObjectCount ()
 
uint16 getOffsetStringCount ()
 
uint16 getOffsetSaidCount ()
 
uint32 getRelocationOffset (const uint32 offset) const
 
- Public Member Functions inherited from Sci::SegmentObj
 SegmentObj (SegmentType type)
 
SegmentType getType () const
 

Protected Attributes

offsetLookupArrayType _offsetLookupArray
 

Additional Inherited Members

- Static Public Member Functions inherited from Sci::SegmentObj
static SegmentObjcreateSegmentObj (SegmentType type)
 
- Public Attributes inherited from Sci::SegmentObj
SegmentType _type
 

Member Function Documentation

◆ isValidOffset()

bool Sci::Script::isValidOffset ( uint32  offset) const
overridevirtual

Check whether the given offset into this memory object is valid, i.e., suitable for passing to dereference.

Implements Sci::SegmentObj.

◆ dereference()

SegmentRef Sci::Script::dereference ( reg_t  pointer)
overridevirtual

Dereferences a raw memory pointer.

Parameters
regreference to dereference
Returns
the data block referenced

Reimplemented from Sci::SegmentObj.

◆ findCanonicAddress()

reg_t Sci::Script::findCanonicAddress ( SegManager segMan,
reg_t  sub_addr 
) const
overridevirtual

Finds the canonic address associated with sub_reg. Used by the garbage collector.

For each valid address a, there exists a canonic address c(a) such that c(a) = c(c(a)). This address "governs" a in the sense that deallocating c(a) will deallocate a.

Parameters
sub_addrbase address whose canonic address is to be found

Reimplemented from Sci::SegmentObj.

◆ freeAtAddress()

void Sci::Script::freeAtAddress ( SegManager segMan,
reg_t  sub_addr 
)
overridevirtual

Deallocates all memory associated with the specified address. Used by the garbage collector.

Parameters
sub_addraddress (within the given segment) to deallocate

Reimplemented from Sci::SegmentObj.

◆ listAllDeallocatable()

Common::Array<reg_t> Sci::Script::listAllDeallocatable ( SegmentId  segId) const
overridevirtual

Iterates over and reports all addresses within the segment. Used by the garbage collector.

Returns
a list of addresses within the segment

Reimplemented from Sci::SegmentObj.

◆ listAllOutgoingReferences()

Common::Array<reg_t> Sci::Script::listAllOutgoingReferences ( reg_t  object) const
overridevirtual

Iterates over all references reachable from the specified object. Used by the garbage collector.

Parameters
objectobject (within the current segment) to analyze
Returns
a list of outgoing references within the object
Note
This function may also choose to report numbers (segment 0) as adresses

Reimplemented from Sci::SegmentObj.

◆ listObjectReferences()

Common::Array<reg_t> Sci::Script::listObjectReferences ( ) const

Return a list of all references to objects in this script (and also to the locals segment, if any). Used by the garbage collector.

Returns
a list of outgoing references within the object

◆ scriptObjInit()

Object* Sci::Script::scriptObjInit ( reg_t  obj_pos,
bool  fullObjectInit = true 
)

Initializes an object within the segment manager

Parameters
obj_posLocation (segment, offset) of the object. It must point to the beginning of the script/class block (as opposed to what the VM considers to be the object location)
Returns
A newly created Object describing the object, stored within the relevant script

◆ initializeLocals()

void Sci::Script::initializeLocals ( SegManager segMan)

Initializes the script's local variables

Parameters
segManA reference to the segment manager

◆ initializeClasses()

void Sci::Script::initializeClasses ( SegManager segMan)

Adds the script's classes to the segment manager's class table

Parameters
segManA reference to the segment manager

◆ initializeObjects()

void Sci::Script::initializeObjects ( SegManager segMan,
SegmentId  segmentId,
bool  applyScriptPatches 
)

Initializes the script's objects (SCI0)

Parameters
segManA reference to the segment manager
segmentIdThe script's segment id
applyScriptPatchesApply patches for the script, if available

◆ incrementLockers()

void Sci::Script::incrementLockers ( )

Increments the number of lockers of this script by one.

◆ decrementLockers()

void Sci::Script::decrementLockers ( )

Decrements the number of lockers of this script by one.

◆ getLockers()

uint Sci::Script::getLockers ( ) const

Retrieves the number of locks held on this script.

Returns
the number of locks held on the previously identified script

◆ setLockers()

void Sci::Script::setLockers ( uint  lockers)

Sets the number of locks held on this script.

◆ getExportsOffset()

uint Sci::Script::getExportsOffset ( ) const
inline

Retrieves the offset of the export table in the script

Returns
the exports offset.

◆ getExportsNr()

uint16 Sci::Script::getExportsNr ( ) const
inline

Retrieves the number of exports of script.

Returns
the number of exports of this script

◆ getSynonyms()

const SciSpan<const byte>& Sci::Script::getSynonyms ( ) const
inline

Retrieves a pointer to the synonyms associated with this script

Returns
pointer to the synonyms, in non-parsed format.

◆ getSynonymsNr()

uint16 Sci::Script::getSynonymsNr ( ) const
inline

Retrieves the number of synonyms associated with this script.

Returns
the number of synonyms associated with this script

◆ validateExportFunc()

uint32 Sci::Script::validateExportFunc ( int  pubfunct,
bool  relocSci3 
)

Validate whether the specified public function is exported by the script in the specified segment.

Parameters
pubfunctIndex of the function to validate
relocSci3Decide whether to relocate this SCI3 public function or not
Returns
NULL if the public function is invalid, its offset into the script's segment otherwise

◆ markDeleted()

void Sci::Script::markDeleted ( )
inline

Marks the script as deleted. This will not actually delete the script. If references remain present on the heap or the stack, the script will stay in memory in a quasi-deleted state until either unreachable (resulting in its eventual deletion) or reloaded (resulting in its data being updated).

◆ isMarkedAsDeleted()

bool Sci::Script::isMarkedAsDeleted ( ) const
inline

Determines whether the script is marked as being deleted.

◆ findBlockSCI0()

SciSpan<const byte> Sci::Script::findBlockSCI0 ( ScriptObjectTypes  type,
bool  findLastBlock = false 
) const

Finds the pointer where a block of a specific type starts from, in SCI0 - SCI1 games

◆ syncStringHeap()

void Sci::Script::syncStringHeap ( Common::Serializer ser)

Syncs the string heap of a script. Used when saving/loading.

◆ getCodeBlockOffset()

int Sci::Script::getCodeBlockOffset ( )
inline

Gets an offset to the beginning of the code block in a SCI1.1 or later script

◆ getOffsetArray()

const offsetLookupArrayType* Sci::Script::getOffsetArray ( )
inline

Get the offset array

◆ getRelocationOffset()

uint32 Sci::Script::getRelocationOffset ( const uint32  offset) const
Returns
kNoRelocation if no relocation exists for the given offset, otherwise returns a delta for the offset to its relocated position.

The documentation for this class was generated from the following file: