Function and GlobalVariable declaration toString()

How are function and global variable declarations represented in AST tree?

Is it the same with normal declarations Declaration_FunctionName[FunctionType[TypeVoid, TypeInt]] and vars Declaration_var[int]?

How you represent them is up to your implementation of the AST.
Important is just that you keep them in memory whenever they are created using the corresponding methods.

The title refers to toString.
Therefore, I assume that you also wanted to ask how they are printed.
For that keep in mind that a test can not obtain a handle to the function from the ASTFactory.

1 Like