Class AssemblyNumericTerminal
java.lang.Object
ghidra.app.plugin.assembler.sleigh.symbol.AssemblySymbol
ghidra.app.plugin.assembler.sleigh.symbol.AssemblyTerminal
ghidra.app.plugin.assembler.sleigh.symbol.AssemblyNumericTerminal
- All Implemented Interfaces:
Comparable<AssemblySymbol>
- Direct Known Subclasses:
AssemblyFixedNumericTerminal
,AssemblyNumericMapTerminal
A terminal that accepts any numeric value or program symbol (label, equate)
The literal may take any form accepted by UNIX strtol() with base=0. By default, the literal is interpreted in base 10, but it may be prefixed such that it's interpreted in an alternative base. With the prefix '0x', it is interpreted in hexadecimal. With the prefix '0', it is interpreted in octal.
It may also take the value of a label. If this operand is an address operand, the acceptable labels are restricted to those in the expected address space.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected static final int
The maximum number of labels to suggeststatic final String
static final String
protected final AddressSpace
protected static final Collection
<String> Some suggestions, other than labels, to provideFields inherited from class ghidra.app.plugin.assembler.sleigh.symbol.AssemblySymbol
name
-
Constructor Summary
ConstructorDescriptionAssemblyNumericTerminal
(String name, int bitsize, AddressSpace space) Construct a terminal with the given name, accepting any numeric value or program label -
Method Summary
Modifier and TypeMethodDescriptionint
getSpace()
getSuggestions
(String got, AssemblyNumericSymbols symbols) Provide a collection of strings that this terminal would have acceptedprotected Collection
<AssemblyParseNumericToken> makeToken
(String str, String num, int radix, boolean neg, AssemblyGrammar grammar) Construct a numeric tokenprotected Collection
<AssemblyParseNumericToken> match
(int s, String buffer, AssemblyGrammar grammar, AssemblyNumericSymbols symbols) Try to match a sign-less numeric literal, or a program labelThis is only a convenience for testingmatch
(String buffer, int pos, AssemblyGrammar grammar, AssemblyNumericSymbols symbols) Attempt to match a token from the input buffer starting at a given positionprotected Collection
<AssemblyParseNumericToken> matchDec
(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match a decimal literal, following the optional sign and optional prefixprotected Collection
<AssemblyParseNumericToken> matchHex
(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match a hexadecimal literal, following the optional sign and prefixprotected Collection
<AssemblyParseNumericToken> matchLiteral
(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match a numeric literal, after the optional sign, encoded in hex, decimal, or octalprotected Collection
<AssemblyParseNumericToken> matchOct
(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match an octal literal, following the optional sign and prefixtoString()
Methods inherited from class ghidra.app.plugin.assembler.sleigh.symbol.AssemblySymbol
compareTo, equals, getName, hashCode, takesOperandIndex
-
Field Details
-
PREFIX_HEX
- See Also:
-
PREFIX_OCT
- See Also:
-
SUGGESTIONS
Some suggestions, other than labels, to provide -
MAX_LABEL_SUGGESTIONS
protected static final int MAX_LABEL_SUGGESTIONSThe maximum number of labels to suggest- See Also:
-
bitsize
protected final int bitsize -
space
-
-
Constructor Details
-
AssemblyNumericTerminal
Construct a terminal with the given name, accepting any numeric value or program label- Parameters:
name
- the namebitsize
- the maximum size of the value in bitsspace
- the address space if this terminal represents an address operand
-
-
Method Details
-
toString
- Specified by:
toString
in classAssemblySymbol
-
match
This is only a convenience for testingPlease use
match(String, int, AssemblyGrammar, AssemblyNumericSymbols)
- Parameters:
buffer
- the input buffer- Returns:
- the parsed token
-
match
public Collection<AssemblyParseNumericToken> match(String buffer, int pos, AssemblyGrammar grammar, AssemblyNumericSymbols symbols) Description copied from class:AssemblyTerminal
Attempt to match a token from the input buffer starting at a given position- Specified by:
match
in classAssemblyTerminal
- Parameters:
buffer
- the input bufferpos
- the cursor position in the buffergrammar
- the grammar containing this terminalsymbols
- symbols from the program, suitable for use as numeric terminals- Returns:
- the matched token, or null
-
match
protected Collection<AssemblyParseNumericToken> match(int s, String buffer, AssemblyGrammar grammar, AssemblyNumericSymbols symbols) Try to match a sign-less numeric literal, or a program label- Parameters:
s
- the buffer cursor where the literal or label is expectedbuffer
- the input buffergrammar
- the grammar containing this terminalsymbols
- the program symbols- Returns:
- the parsed token, or null
-
matchLiteral
protected Collection<AssemblyParseNumericToken> matchLiteral(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match a numeric literal, after the optional sign, encoded in hex, decimal, or octal- Parameters:
s
- buffer cursor where the literal is expectedbuffer
- the input bufferpos
- the start offset of the token parsed so farneg
- true if the the optional-
is presentgrammar
- the grammar containing this terminal- Returns:
- the parsed token, or null
-
makeToken
protected Collection<AssemblyParseNumericToken> makeToken(String str, String num, int radix, boolean neg, AssemblyGrammar grammar) Construct a numeric token- Parameters:
str
- the string value of the token taken verbatim from the buffernum
- portion of the token following the optional sign and prefixradix
- the radix ofnum
neg
- true if the the optional-
is presentgrammar
- the grammar containing this terminal- Returns:
- the parsed token, or null
-
matchHex
protected Collection<AssemblyParseNumericToken> matchHex(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match a hexadecimal literal, following the optional sign and prefix- Parameters:
s
- the buffer cursor where the hex portion startsbuffer
- the input bufferpos
- the start offset of the token parsed so farneg
- true if the the optional-
is presentgrammar
- the grammar containing this terminal- Returns:
- the parsed token, or null
-
matchDec
protected Collection<AssemblyParseNumericToken> matchDec(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match a decimal literal, following the optional sign and optional prefix- Parameters:
s
- the buffer cursor where the hex portion startsbuffer
- the input bufferpos
- the start offset of the token parsed so farneg
- true if the the optional-
is presentgrammar
- the grammar containing this terminal- Returns:
- the parsed token, or null
-
matchOct
protected Collection<AssemblyParseNumericToken> matchOct(int s, String buffer, int pos, boolean neg, AssemblyGrammar grammar) Try to match an octal literal, following the optional sign and prefix- Parameters:
s
- the buffer cursor where the hex portion startsbuffer
- the input bufferpos
- the start offset of the token parsed so farneg
- true if the the optional-
is presentgrammar
- the grammar containing this terminal- Returns:
- the parsed token, or null
-
getSuggestions
Description copied from class:AssemblyTerminal
Provide a collection of strings that this terminal would have accepted- Specified by:
getSuggestions
in classAssemblyTerminal
- Parameters:
got
- the remaining contents of the input buffersymbols
- the program symbols, if applicable- Returns:
- a, possibly empty, collection of suggestions
-
getBitSize
public int getBitSize() -
getSpace
-