Tai-e-assignments
Tai-e-assignments copied to clipboard
About the A1
How could I get the value from statement? The Lvalue
class and the Rvalue
class is not a Var
class
@Shmily8421
RValue
is not always Var
, you can check Exp.getUses()
.
'a + b'.getUses() -> [Var, Var]
.
Emmmm, Could u say that in more details?
@Shmily8421
2.1 Tai-e Classes You Need to Know
The RValue
may be a Var
, a BinaryExp
, or another type.
a + b
is a BinaryExp
(also AbstractBinaryExp
):
You can get this code from dependencies.jar
:
abstract class AbstractBinaryExp implements BinaryExp {
public List<RValue> getUses() {
return List.of(this.operand1, this.operand2);
}
}
Maybe we should assume that the AST is brought directly into the IR?
-
a = b
isVar = Var
-
a = b + c
isVar = BinaryExp
, this can be extended asVar = Var Op Var
btw, I don't know the design details of IR. because the
getUses
is a method of theExp
and I use recursion to handle this.
Read the code and comments in the project with patience and good luck. :)
Okay, I can understand the AST logic.
But as you said, the definition of these interface class is quite complex, so that I don't know how to get the Var
in this sentence through the Stmt
class.
Check the class pascal.taie.ir.stmt.AbstractStmt
. There are 7 overrides of its method getUses()
, and some of these override implementations reused Exp.getUses()
. In most cases the getUses()
actually returns a List of Var
...while i didn't statically check all the cases, i have no idea if possible that the return List of getUses()
contains objects of other subclasses of Rvalue
instead of Var
...maybe print the type during execution is a way to find it.
So, maybe you need to check if (rvalue instanceof Var)
, then force cast the rvalue
to Var
if true.
How could I get the value from statement? The
Lvalue
class and theRvalue
class is not aVar
class
boolean flag=(temp!=in) ,this statement must use the " equals()" to replace the " != "
How could I get the value from statement? The
Lvalue
class and theRvalue
class is not aVar
classboolean flag=(temp!=in) ,this statement must use the " equals()" to replace the " != "
you can also use the method "union" whose result type is boolean (true when the FactSet is changed).