-
Notifications
You must be signed in to change notification settings - Fork 0
AST2MIPS interface
Ben Shen edited this page Jun 19, 2019
·
20 revisions
-
C Statement should only use
mp()
without argument. -
C expression should only use
mp(Result& result)
. -
In expression, both
id
andfreeable
are always used -
When handling type, only
type
field is used -
Type is only passed in AST during delcartion, it should stay within the
Mp
class -
In general
result
field is used as return field from leaf nodes. -
mp(Result& result)
hint is used as output,mp(Result& para)
hint is used as intput
- whenever mention id, it also implies
id
ANDbool freeable
field are used.
class name | input | output | remark |
---|---|---|---|
declaration | type | not sure why return type (declaration_specifiers ';' ) |
|
init_declarator | type | ||
declarator | basic_type | type, identifier, (size vector if is array) | |
direct_declarator | basic_type | type, identifier, (size vector if is array) | return VOID to indicate is function declaration |
primary_expression | type | id, type, str | May receive TYPE_VOID , in such case return str for IDENTIFIER (func name), reutrn constant through id for conditional_expression
|
conditional_expression | use id field for compile time constant | passdown TYPE_VOID to conditional_expression to indicate it's run time expression |
parameter_type_list is treaded as statement, i.e. use mp()
Because of 1,2 statement like below will produce node in AST, but will not be evaluated nor produce any output (expect warnings). Because the statement
uses mp()
method, will not invoke mp(Result& result)
method.
{
1+5<<2;
}