Class AnOpcodeDictionaryEntry

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AnOpcodeDictionaryEntry = class(AStringLeaf)

Description

This class represents an opcode dictionary entry, which matches a single token string to its internal representation. The meaning and value of the internal representation will vary, depending on the needs of the language and the specification of its parser, but working with the internal representation is faster than working with the string representation itself.

Instance of AnOpcodeDictionaryEntry are immutable once they have been constructed.

Hierarchy

Overview

Fields

Protected myCode: TOpcode;

Methods

Public constructor binding(const tokenString: string; const opcode: TOpcode);
Public function init: boolean; override;
Public function shallowCopyFrom(const Other: AnObject): boolean; override;
Public function selfStreamingLength: TStreamIOSize; override;
Public function writeSelfTo(const Dest: AStream): TStreamIOSize; override;
Public function readFrom(const Source: AStream): TStreamIOSize; override;
Public function toString: AnsiString; override;
Public function code: TOpcode;

Description

Fields

Protected myCode: TOpcode;

Stores the internal representation of the opcode

Methods

Public constructor binding(const tokenString: string; const opcode: TOpcode);

Construct a new opcode entry that binds the specified token string to an internal representation.

Public function init: boolean; override;

Initializer

Public function shallowCopyFrom(const Other: AnObject): boolean; override;

Construct a shallow copy of the other object.

This method overrides the behavior inherited from AStringLeaf.shallowCopyFrom: it calls that routine, then checks to see whether Other is an instance of AnOpcodeDictionaryEntry. If so, it copies the value of AnOpcodeDictionaryEntry.code from Other to Self, overwriting the value in Self.

Note that this method does NOT copy any sibling or child nodes and so cannot be used to create a full copy of any descendant of ANode. Likewise, it does NOT copy the left or right subtrees and so cannot be used to create a full copy of any descendant of ABinaryLeaf. The copy will NOT be automatically placed in the binary tree to which Other belongs, if any, but the caller is free to do so, so long as the node's sort key does not match one that already exists in the tree.

Public function selfStreamingLength: TStreamIOSize; override;

Calculate the total number of bytes required to stream the opcode.

This method builds upon the behavior inherited from AStringLeaf.selfStreamingLength: it calls the inherited routine, then adds the number of bytes required to store the opcode value itself.

Public function writeSelfTo(const Dest: AStream): TStreamIOSize; override;

Write the opcode, and just the opcode, to the given stream.

This method extends the behavior inherited from AStringLeaf.writeSelfTo. It calls that routine, then writes the value of AnOpcodeDictionaryEntry.code to Dest.

See AStringLeaf.writeSelfTo for more information.

Public function readFrom(const Source: AStream): TStreamIOSize; override;

Read the item from the given stream.

This method extends the behavior inherited from AStringLeaf.readFrom. It calls that routine, then reads the value of AnOpcodeDictionaryEntry.code from Source.

See AStringLeaf.readFrom for more information.

Public function toString: AnsiString; override;

Construct and return a string representation of the opcode, suitable for printing to a text-based device, such as a console.

This method overrides the behavior inherited from AStringLeaf.toString; it simply returns the token string that is bound to the opcode's internal representation.

Public function code: TOpcode;

Retrieve the internal representation of the opcode.


Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18