Learning About Dests
Querying for Assigned Variables
When writing a Glider Query, we will often have to query for variables. More importantly, we'll want to query for variables assigned in Solidity. For example, let's take the following Solidity code:
In this example, a variable named recoveredAddress is created and is used later on used to validate who wrote the signature. With Glider, we can identify the recoveredAddress variable and follow the variable usage. Below we will walk through this.
What are Dests
When working with instructions, if an instruction creates or assigns a variable, Glider allows us to also query for the variables. Let's take the following Solidity example:
In this example, the dest is considered the variable named length.
Let's look at another Solidity example:
In this example, owner is a state variable. Inside of the setNewOwner() function the owner state variable is updated with a new owner. Here, owner = newOwner;
is the instruction we are looking at. The owner variable assigned here is the instruction's dest.
To summarize, the dest represents the left-most variable assigned in an instruction:
[INSERT SCREENSHOT OF CODE WITH HIGHLIGHT ON WHAT THE DEST IS]
How to retrieve variable instructions
If we want the query an instruction's dest, we can use the get_dest()
function.
The get_dest()
function is called against a single Instruction. To explain this further, let's take a look at the following Glider query:
In this query, we identify the first new variable instruction and assign it to an instruction variable. This instruction variable is an Instruction object. With instruction objects, we can query for parts of the instruction. In our case, we want to query for the variables in the instruction.
To do this, we call get_dest()
against the Instruction object. This is as simple as running
By calling get_dest(), Glider will return to us the variable assigned in the instruction.
If the instruction doesn't assign any variables, then get_dest() will return what's called a NoneObject.
Let's now update our Glider query to identify the variable assigned in the instruction with get_dest()
:
Now we print out the variable assigned in the instruction. The Glider IDE debugger panel returns:
This represents the assigned variable. From here we can do much more with the assigned variable like see where the assigned variable flows into, what the variable is named, etc.
Working with variable instructions
Once we've received the variable instruction, there is a lot we can do with the variable instruction
todos
this section is incomplete. skipping for now because i need to think a bit about how i want to structure this section. ideally it should be
what is dest
why we need dest
querying for dest
examples
Last updated