Class AssemblyResolution
- java.lang.Object
-
- ghidra.app.plugin.assembler.sleigh.sem.AssemblyResolution
-
- All Implemented Interfaces:
java.lang.Comparable<AssemblyResolution>
- Direct Known Subclasses:
AssemblyResolvedBackfill
,AssemblyResolvedConstructor
,AssemblyResolvedError
public abstract class AssemblyResolution extends java.lang.Object implements java.lang.Comparable<AssemblyResolution>
The (often intermediate) result of assembly These may represent a successful construction (AssemblyResolvedConstructor
, a future field (AssemblyResolvedBackfill
), or an error (AssemblyResolvedError
). This class also provides the static factory methods for constructing any of its subclasses.
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.common.collect.ImmutableList<? extends AssemblyResolution>
children
protected java.lang.String
description
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static AssemblyResolvedBackfill
backfill(PatternExpression exp, MaskedLong goal, java.util.Map<java.lang.Integer,java.lang.Object> res, int inslen, java.lang.String description)
Build a backfill record to attach to a successful resolution resultprotected java.lang.String
childrenToString(java.lang.String indent)
Get the child portion oftoString()
If a subclass has another, possible additional, notion of children that it would like to include intoString()
, it must override this method.int
compareTo(AssemblyResolution that)
protected abstract int
computeHash()
static AssemblyResolvedConstructor
contextOnly(AssemblyPatternBlock ctx, java.lang.String description, com.google.common.collect.ImmutableList<AssemblyResolution> children)
Build a context-only successful resolution resultstatic AssemblyResolution
error(java.lang.String error, AssemblyResolvedConstructor res)
Build an error resolution record, based on an intermediate SLEIGH constructor recordstatic AssemblyResolvedError
error(java.lang.String error, java.lang.String description, com.google.common.collect.ImmutableList<? extends AssemblyResolution> children)
Build an error resolution recordstatic AssemblyResolvedConstructor
fromPattern(DisjointPattern pat, int minLen, java.lang.String description)
Build a successful resolution result from a SLEIGH constructor's patternsboolean
hasChildren()
Check if this record has children If a subclass has another, possibly additional, notion of children that it would like to include intoString()
, it must override this method to return true when such children are present.int
hashCode()
static AssemblyResolvedConstructor
instrOnly(AssemblyPatternBlock ins, java.lang.String description, com.google.common.collect.ImmutableList<AssemblyResolution> children)
Build an instruction-only successful resolution resultabstract boolean
isBackfill()
Check if this record describes a backfillabstract boolean
isError()
Check if this record describes an errorprotected abstract java.lang.String
lineToString()
Display the resolution result in one line (omitting child details)static AssemblyResolvedConstructor
nop(java.lang.String description, com.google.common.collect.ImmutableList<? extends AssemblyResolution> sel)
Obtain a new "blank" resolved SLEIGH constructor recordstatic AssemblyResolvedConstructor
resolved(AssemblyPatternBlock ins, AssemblyPatternBlock ctx, java.lang.String description, com.google.common.collect.ImmutableList<? extends AssemblyResolution> sel)
Build the result of successfully resolving a SLEIGH constructorjava.lang.String
toString()
Describe this record including indented children, grandchildren, etc., each on its own linejava.lang.String
toString(java.lang.String indent)
Used only by parents: get a multi-line description of this record, indented
-
-
-
Field Detail
-
description
protected final java.lang.String description
-
children
protected final com.google.common.collect.ImmutableList<? extends AssemblyResolution> children
-
-
Method Detail
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
computeHash
protected abstract int computeHash()
-
resolved
public static AssemblyResolvedConstructor resolved(AssemblyPatternBlock ins, AssemblyPatternBlock ctx, java.lang.String description, com.google.common.collect.ImmutableList<? extends AssemblyResolution> sel)
Build the result of successfully resolving a SLEIGH constructor- Parameters:
ins
- the instruction pattern blockctx
- the context pattern blockdescription
- a description of the resolutionsel
- the children selected to resolve this constructor, or null- Returns:
- the new resolution
-
instrOnly
public static AssemblyResolvedConstructor instrOnly(AssemblyPatternBlock ins, java.lang.String description, com.google.common.collect.ImmutableList<AssemblyResolution> children)
Build an instruction-only successful resolution result- Parameters:
ins
- the instruction pattern blockdescription
- a description of the resolutionchildren
- the children selected to resolve this constructor, or null- Returns:
- the new resolution
- See Also:
#resolved(AssemblyPatternBlock, AssemblyPatternBlock, String, List)
-
contextOnly
public static AssemblyResolvedConstructor contextOnly(AssemblyPatternBlock ctx, java.lang.String description, com.google.common.collect.ImmutableList<AssemblyResolution> children)
Build a context-only successful resolution result- Parameters:
ctx
- the context pattern blockdescription
- a description of the resolutionchildren
- the children selected to resolve this constructor, or null- Returns:
- the new resolution
- See Also:
#resolved(AssemblyPatternBlock, AssemblyPatternBlock, String, List)
-
fromPattern
public static AssemblyResolvedConstructor fromPattern(DisjointPattern pat, int minLen, java.lang.String description)
Build a successful resolution result from a SLEIGH constructor's patterns- Parameters:
pat
- the constructor's patterndescription
- a description of the resolution- Returns:
- the new resolution
-
backfill
public static AssemblyResolvedBackfill backfill(PatternExpression exp, MaskedLong goal, java.util.Map<java.lang.Integer,java.lang.Object> res, int inslen, java.lang.String description)
Build a backfill record to attach to a successful resolution result- Parameters:
exp
- the expression depending on a missing symbolgoal
- the desired value of the expressionres
- the resolution result for child constructorsinslen
- the length of instruction portion expected in the future solutiondescription
- a description of the backfill record- Returns:
- the new record
-
nop
public static AssemblyResolvedConstructor nop(java.lang.String description, com.google.common.collect.ImmutableList<? extends AssemblyResolution> sel)
Obtain a new "blank" resolved SLEIGH constructor record- Parameters:
description
- a description of the resolutionsel
- any children that will be involved in populating this record- Returns:
- the new resolution
-
error
public static AssemblyResolvedError error(java.lang.String error, java.lang.String description, com.google.common.collect.ImmutableList<? extends AssemblyResolution> children)
Build an error resolution record- Parameters:
error
- a description of the errordescription
- a description of what the resolver was doing when the error ocurredchildren
- any children involved in generating the error- Returns:
- the new resolution
-
error
public static AssemblyResolution error(java.lang.String error, AssemblyResolvedConstructor res)
Build an error resolution record, based on an intermediate SLEIGH constructor record- Parameters:
error
- a description of the errorres
- the constructor record that was being populated when the error ocurred- Returns:
- the new error resolution
-
isError
public abstract boolean isError()
Check if this record describes an error- Returns:
- true if the record is an error
-
isBackfill
public abstract boolean isBackfill()
Check if this record describes a backfill- Returns:
- true if the record is a backfill
-
lineToString
protected abstract java.lang.String lineToString()
Display the resolution result in one line (omitting child details)- Returns:
- the display description
-
childrenToString
protected java.lang.String childrenToString(java.lang.String indent)
Get the child portion oftoString()
If a subclass has another, possible additional, notion of children that it would like to include intoString()
, it must override this method.- Parameters:
indent
- the current indentation- Returns:
- the indented description for each child on its own line
- See Also:
hasChildren()
-
toString
public java.lang.String toString(java.lang.String indent)
Used only by parents: get a multi-line description of this record, indented- Parameters:
indent
- the current indentation- Returns:
- the indented description
-
toString
public java.lang.String toString()
Describe this record including indented children, grandchildren, etc., each on its own line- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(AssemblyResolution that)
- Specified by:
compareTo
in interfacejava.lang.Comparable<AssemblyResolution>
-
hasChildren
public boolean hasChildren()
Check if this record has children If a subclass has another, possibly additional, notion of children that it would like to include intoString()
, it must override this method to return true when such children are present.- Returns:
- true if this record has children
- See Also:
childrenToString(String)
-
-