X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast.h;h=a221ec21eabb9b8e8947e05233de8c76bf7292ac;hb=b8f4fc13774d296a361e9e80e813a7eb906fc54b;hp=adb7e89f0fbcaf7b64bf45ac250b614c7767c9b4;hpb=26aba71a371f0bbcc8afd213b4398d4e4e52a6f2;p=cparser diff --git a/ast.h b/ast.h index adb7e89..a221ec2 100644 --- a/ast.h +++ b/ast.h @@ -72,6 +72,7 @@ typedef struct if_statement_t if_statement_t; typedef struct switch_statement_t switch_statement_t; typedef struct declaration_statement_t declaration_statement_t; typedef struct expression_statement_t expression_statement_t; +typedef struct computed_goto_statement_t computed_goto_statement_t; typedef struct goto_statement_t goto_statement_t; typedef struct label_statement_t label_statement_t; typedef struct case_label_statement_t case_label_statement_t; @@ -87,17 +88,23 @@ typedef union statement_t statement_t; typedef struct translation_unit_t translation_unit_t; -void init_ast(void); -void exit_ast(void); +/** + * Initialize the AST construction. + */ +void init_ast(void); + +/** + * Free the AST. + */ +void exit_ast(void); -void print_expression(const expression_t *expression); -void print_initializer(const initializer_t *initializer); -void print_ast(const translation_unit_t *unit); -void print_indent(void); -void print_declaration(const entity_t *entity); -void print_entity(const entity_t *entity); -void change_indent(int delta); -void *allocate_ast(size_t size); +void print_expression(const expression_t *expression); +void print_initializer(const initializer_t *initializer); +void print_ast(const translation_unit_t *unit); +void print_indent(void); +void print_declaration(const entity_t *entity); +void print_entity(const entity_t *entity); +void change_indent(int delta); typedef enum expression_classification_t { EXPR_CLASS_VARIABLE, @@ -106,10 +113,8 @@ typedef enum expression_classification_t { } expression_classification_t; /** - * Returns true if a given expression is a compile time - * constant. §6.6 - * - * @param expression the expression to check + * Returns true when an initializer contains only constants/linker_constant + * values. */ expression_classification_t is_constant_initializer(const initializer_t *initializer); @@ -122,13 +127,17 @@ expression_classification_t is_constant_initializer(const initializer_t *initial expression_classification_t is_constant_expression(const expression_t *expression); /** - * An object with a fixed but at compiletime unknown adress which will be known - * at link/load time. + * Checks if an expression is a constant/known value to the linker. Examples: + * - all constant/linker constant expression casted to a pointer type + * - "&x", with x being a global variable. + * - "array" or "a.array" in case array is an array and array and a, + * respectively is an object with link time constant address */ -expression_classification_t is_address_constant(const expression_t *expression); +expression_classification_t is_linker_constant(const expression_t *expression); long fold_constant_to_int(const expression_t *expression); bool fold_constant_to_bool(const expression_t *expression); +bool constant_is_negative(const expression_t *constant); /** * the type of a literal is usually the biggest type that can hold the value.