Class AnOpcodeDictionary

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AnOpcodeDictionary = class(AStringTree)

Description

This class represents a dictionary of opcodes. It is used by AParsedLanguage to match token strings to their internal representations.

Hierarchy

Overview

Methods

Public function init: boolean; override;
Public function bind(const tokenString: string; const opcode: TOpcode): AnOpcodeDictionaryEntry; virtual;
Public function bindSeveral(const tokenStrings: array of string; const opcodes: array of TOpcode): longword; virtual;
Public function valueOf(const tokenString: string): TOpcode; virtual;

Description

Methods

Public function init: boolean; override;

Initializer

Public function bind(const tokenString: string; const opcode: TOpcode): AnOpcodeDictionaryEntry; virtual;

Bind the specified token string to the specified internal representation and insert the binding into the dictionary.

Returns

The new entry that has been inserted into the dictionary, if successful. As with other descendants of ABinaryTree, instances of AnOpcodeDictionary do not support duplicate entries. If a binding for tokenString already exists in the dictionary, then this routine does nothing and returns Nil.

Public function bindSeveral(const tokenStrings: array of string; const opcodes: array of TOpcode): longword; virtual;

Bind the specified token strings in the first array to the corresponding internal representations from the second array.

Both arrays must be of equal length for this method to succeed. The arrays should be filled such that tokenStrings[1] has its internal representation specified in opcodes[1], and so forth. This method is primarily designed to allow token strings and opcodes to be hard-coded as constants within the program itself.

Returns

The total number of bindings inserted into the dictionary. This number may be less than System.length reports for the arrays passed to this method if the arrays contain duplicate entries. This value will be zero (0) if the length of both arrays does not match.

Public function valueOf(const tokenString: string): TOpcode; virtual;

Retrieve the internal representation for the given tokenString.

This method searches through the entries in the dictionary for the instance of AnOpcodeDictionaryEntry that has the given tokenString; if found, AnOpcodeDictionaryEntry.code is called on that instance and the value provided is returned to the caller.

If the specified tokenString is not found, then this routine returns TOpcode(0).


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