]> pd.if.org Git - lice/blob - ast.h
autocommit for files dated 2014-11-17 20:15:26
[lice] / ast.h
1 #ifndef LICE_AST_HDR
2 #define LICE_AST_HDR
3 #include "util.h"
4
5 /*
6  * File: ast.h
7  *  Implements the interface to LICE's abstract syntax tree
8  */
9 typedef struct ast_s ast_t;
10
11 /*
12  * Type: ast_type_t
13  *  The type of ast node
14  *
15  *  Constants:
16  *
17  *  AST_TYPE_LITERAL                 - Literal
18  *  AST_TYPE_STRING                  - String literal
19  *  AST_TYPE_VAR_LOCAL               - Local variable
20  *  AST_TYPE_VAR_GLOBAL              - Global variable
21  *  AST_TYPE_CALL                    - Direct function call
22  *  AST_TYPE_POINTERCALL             - Indirect function call
23  *  AST_TYPE_FUNCTION                - Function
24  *  AST_TYPE_PROTOTYPE               - Prototype
25  *  AST_TYPE_DECLARATION             - Declaration
26  *  AST_TYPE_INITIALIZER             - Initializer
27  *  AST_TYPE_STRUCT                  - Structure
28  *  AST_TYPE_ADDRESS                 - Address of operation
29  *  AST_TYPE_DEREFERENCE             - Pointer dereference
30  *  AST_TYPE_EXPRESSION_TERNARY      - Ternary expression
31  *  AST_TYPE_EXPRESSION_CAST         - Type cast expression
32  *  AST_TYPE_STATEMENT_IF            - If statement
33  *  AST_TYPE_STATEMENT_FOR           - For statement
34  *  AST_TYPE_STATEMENT_WHILE         - While statement
35  *  AST_TYPE_STATEMENT_DO            - Do statement
36  *  AST_TYPE_STATEMENT_SWITCH        - Switch statement
37  *  AST_TYPE_STATEMENT_CASE          - Switch statement case
38  *  AST_TYPE_STATEMENT_DEFAULT       - Switch statement default case
39  *  AST_TYPE_STATEMENT_RETURN        - Return statement
40  *  AST_TYPE_STATEMENT_BREAK         - Break statement
41  *  AST_TYPE_STATEMENT_CONTINUE      - Continue statement
42  *  AST_TYPE_STATEMENT_COMPOUND      - Compound statement
43  *  AST_TYPE_STATEMENT_GOTO          - Goto statement
44  *  AST_TYPE_STATEMENT_LABEL         - Goto statement label
45  *  AST_TYPE_POST_INCREMENT          - Post increment operation
46  *  AST_TYPE_POST_DECREMENT          - Post decrement operation
47  *  AST_TYPE_PRE_INCREMENT           - Pre increment operation
48  *  AST_TYPE_PRE_DECREMENT           - Pre decrement operation
49  *  AST_TYPE_LSHIFT                  - Left shift operation
50  *  AST_TYPE_RSHIFT                  - Right shift operation
51  *  AST_TYPE_LRSHIFT                 - Logical right shift operation
52  *  AST_TYPE_EQUAL                   - Equality condition
53  *  AST_TYPE_GEQUAL                  - Greater-or-equal condition
54  *  AST_TYPE_LEQUAL                  - Less-or-equal condition
55  *  AST_TYPE_NEQUAL                  - Not-equal condition
56  *  AST_TYPE_NEGATE                  - Negation
57  *  AST_TYPE_AND                     - Logical-and operation
58  *  AST_TYPE_OR                      - Logical-or operation
59  *  AST_TYPE_NEGATE                  - Unary minus
60  *  AST_TYPE_VA_START                - __builtin_va_start
61  *  AST_TYPE_VA_ARG                  - __builtin_va_arg
62  *  AST_TYPE_DESIGNATOR              - Designation on function types
63  *  AST_TYPE_CONVERT                 - Type conversion
64  */
65 typedef enum {
66     AST_TYPE_LITERAL = 0x100,
67     AST_TYPE_STRING,
68     AST_TYPE_VAR_LOCAL,
69     AST_TYPE_VAR_GLOBAL,
70     AST_TYPE_CALL,
71     AST_TYPE_POINTERCALL,
72     AST_TYPE_FUNCTION,
73     AST_TYPE_PROTOTYPE,
74     AST_TYPE_DECLARATION,
75     AST_TYPE_INITIALIZER,
76     AST_TYPE_STRUCT,
77     AST_TYPE_ADDRESS,
78     AST_TYPE_DEREFERENCE,
79     AST_TYPE_EXPRESSION_TERNARY,
80     AST_TYPE_EXPRESSION_CAST,
81     AST_TYPE_STATEMENT_IF,
82     AST_TYPE_STATEMENT_FOR,
83     AST_TYPE_STATEMENT_WHILE,
84     AST_TYPE_STATEMENT_DO,
85     AST_TYPE_STATEMENT_SWITCH,
86     AST_TYPE_STATEMENT_CASE,
87     AST_TYPE_STATEMENT_DEFAULT,
88     AST_TYPE_STATEMENT_RETURN,
89     AST_TYPE_STATEMENT_BREAK,
90     AST_TYPE_STATEMENT_CONTINUE,
91     AST_TYPE_STATEMENT_COMPOUND,
92     AST_TYPE_STATEMENT_GOTO,
93     AST_TYPE_STATEMENT_LABEL,
94     AST_TYPE_STATEMENT_GOTO_COMPUTED,
95     AST_TYPE_STATEMENT_LABEL_COMPUTED,
96     AST_TYPE_POST_INCREMENT,
97     AST_TYPE_POST_DECREMENT,
98     AST_TYPE_PRE_INCREMENT,
99     AST_TYPE_PRE_DECREMENT,
100     AST_TYPE_LSHIFT,
101     AST_TYPE_RSHIFT,
102     AST_TYPE_LRSHIFT,
103     AST_TYPE_EQUAL,
104     AST_TYPE_GEQUAL,
105     AST_TYPE_LEQUAL,
106     AST_TYPE_NEQUAL,
107     AST_TYPE_NEGATE,
108     AST_TYPE_AND,
109     AST_TYPE_OR,
110     AST_TYPE_VA_START,
111     AST_TYPE_VA_ARG,
112     AST_TYPE_DESIGNATOR,
113     AST_TYPE_CONVERT,
114 } ast_type_t;
115
116
117 /*
118  * Type: type_t
119  *  Type describing the ast type.
120  *
121  *  Constants:
122  *
123  *  TYPE_VOID       - void
124  *  TYPE_BOOL       - boolean
125  *  TYPE_CHAR       - char
126  *  TYPE_SHORT      - short
127  *  TYPE_INT        - int
128  *  TYPE_LONG       - long
129  *  TYPE_LLONG      - long long
130  *  TYPE_DOUBLE     - double
131  *  TYPE_LDOUBLE    - long double
132  *  TYPE_ARRAY      - array (also contains a type_t for base type)
133  *  TYPE_POINTER    - pointer (also contains a type_t for base type)
134  *  TYPE_STRUCTURE  - structure (user defined)
135  *  TYPE_FUNCTION   - function  (user defined)
136  *  TYPE_CDECL      - used by the parser for dealing with declarations
137  */
138 typedef enum {
139     TYPE_VOID,
140     TYPE_BOOL,
141     TYPE_CHAR,
142     TYPE_SHORT,
143     TYPE_INT,
144     TYPE_LONG,
145     TYPE_LLONG,
146     TYPE_FLOAT,
147     TYPE_DOUBLE,
148     TYPE_LDOUBLE,
149     TYPE_ARRAY,
150     TYPE_POINTER,
151     TYPE_STRUCTURE,
152     TYPE_FUNCTION,
153     TYPE_CDECL
154 } type_t;
155
156 /*
157  * Type: ast_data_type_t
158  *  Type describing the indice into `ast_data_table`
159  *
160  *  Constants:
161  *
162  *  AST_DATA_VOID       - void
163  *  AST_DATA_BOOL       - boolean
164  *  AST_DATA_LONG       - long
165  *  AST_DATA_LLONG      - long long
166  *  AST_DATA_INT        - int
167  *  AST_DATA_SHORT      - short
168  *  AST_DATA_CHAR       - char
169  *  AST_DATA_FLOAT      - float
170  *  AST_DATA_DOUBLE     - double
171  *  AST_DATA_LDOUBLE    - long double
172  *  AST_DATA_ULONG      - unsigned long
173  *  AST_DATA_ULLONG     - unsigned long long
174  *  AST_DATA_FUNCTION   - function (current)
175  */
176 typedef enum {
177     AST_DATA_VOID,
178     AST_DATA_BOOL,
179     AST_DATA_LONG,
180     AST_DATA_LLONG,
181     AST_DATA_INT,
182     AST_DATA_SHORT,
183     AST_DATA_CHAR,
184     AST_DATA_FLOAT,
185     AST_DATA_DOUBLE,
186     AST_DATA_LDOUBLE,
187     AST_DATA_ULONG,
188     AST_DATA_ULLONG,
189     AST_DATA_FUNCTION,
190     AST_DATA_COUNT
191 } ast_data_type_t;
192
193 /*
194  * Type: cdecl_t
195  *  Describes type of declarations
196  *
197  *  Constants:
198  *
199  *  CDECL_BODY          - function body
200  *  CDECL_PARAMETER     - parameters (with name)
201  *  CDECL_TYPEONLY      - parameters (without name)
202  *  CDECL_CAST          - cast
203  */
204 typedef enum {
205     CDECL_BODY = 1,
206     CDECL_PARAMETER,
207     CDECL_TYPEONLY,
208     CDECL_CAST
209 } cdecl_t;
210
211 /*
212  * Type: storage_t
213  *  Describes the storage class for a given variable
214  *
215  *  Constants:
216  *
217  *  STORAGE_TYPEDEF     - typedef to another type
218  *  STORAGE_EXTERN      - external linkage
219  *  STORAGE_STATIC      - static storage
220  *  STORAGE_AUTO        - automatic storage (implicit)
221  *  STORAGE_REGISTER    - make use of register for storage
222  */
223 typedef enum {
224     STORAGE_TYPEDEF = 1,
225     STORAGE_EXTERN,
226     STORAGE_STATIC,
227     STORAGE_AUTO,
228     STORAGE_REGISTER
229 } storage_t;
230
231 /*
232  * Struct: data_type_t
233  *  A structure that describes a data type.
234  */
235 typedef struct data_type_s data_type_t;
236 struct data_type_s {
237     /*
238      * Variable: type
239      *  The type of the data type.
240      *
241      *  See <type_t> Constants for a list of
242      *  valid constant values.
243      */
244     type_t type;
245
246     /*
247      * Variable: size
248      *  The size of the given data type, this is often the value
249      *  provided for the given type in arch_[target].h
250      */
251     int size;
252
253     /*
254      * Variable: sign
255      *  Describes if the type is signed or unsigned.
256      */
257     bool sign;
258
259     /*
260      * Variable: isstatic
261      *  Describes if the type is static.
262      */
263     bool isstatic;
264
265     /*
266      * Variable: length
267      *  Instances of the data type.
268      *
269      *  When used as a base-type, i.e not an array; this will be
270      *  1, otherwise it will be the length of the array, or -1
271      *  if the size of the array is unknown.
272      */
273     int length;
274
275     /*
276      * Variable: pointer
277      * When the variable is a pointer type, this will point to another
278      * data type that describes the base type of the pointer, NULL other-
279      * wise.
280      */
281     data_type_t *pointer;
282
283     /* structure */
284     struct {
285         /*
286          * Variable: fields
287          *  Pointer to a table of fields (if structure)
288          */
289         table_t *fields;
290
291         /*
292          * Variable: offset
293          *  Offset of the given field in a structure (if a structure base type)
294          */
295         int offset;
296
297         /*
298          * Variable: isstruct
299          *  If we're dealing with a structure this will be true, false
300          *  otherwise.
301          */
302         bool isstruct;
303
304         /* bitfields */
305         struct {
306             int offset;
307             int size;
308         } bitfield;
309
310     };
311
312     /* function */
313     struct {
314         /*
315          * Variable: returntype
316          *  Pointer to a data type which describes the return type
317          *  of the function (if a function)
318          */
319         data_type_t *returntype;
320
321         /*
322          * Variable: parameters
323          *  Pointer to a list of parameters for a function.
324          */
325         list_t *parameters;
326
327         /*
328          * Variable: hasdots
329          *  Describes if the given function is variable-argument.
330          *
331          *  Contains the value `true` when the function has
332          *  three dots `...` in it's prototype, otherwise `false`.
333          */
334         bool hasdots;
335     };
336 };
337
338 /*
339  * Struct: ast_string_t
340  *  The *AST_TYPE_STRING* ast node.
341  */
342 typedef struct {
343     /*
344      * Variable: data
345      *  String contents
346      */
347     char *data;
348
349     /*
350      * Variable: label
351      *  Name of the label associated with the string.
352      */
353     char *label;
354 } ast_string_t;
355
356 /*
357  * Struct: ast_variable_t
358  *  The *AST_TYPE_VAR_LOCAL* and *AST_TYPE_VAR_GLOBAL* ast node.
359  */
360 typedef struct {
361     /*
362      * Variable: name
363      *  Name of the variable
364      */
365     char *name;
366
367     /*
368      * Variable: off
369      *  Offset of the variable on the stack.
370      */
371     int off;
372
373     /*
374      * Variable: label
375      *  Name of the label associated with the variable.
376      */
377     char *label;
378
379     /*
380      * Variable: init
381      *  Compound literal list for initialization
382      */
383     list_t *init;
384 } ast_variable_t;
385
386 /*
387  * Struct ast_function_call_t
388  *  Function call
389  *
390  *  Remarks:
391  *      Not associated with any node. Instead describes the
392  *      data associated with a function call for *ast_function_t*
393  */
394 typedef struct {
395     /*
396      * Variable: args
397      *  Pointer to a list of arguments for a function call
398      */
399     list_t *args;
400
401     /*
402      * Variable: type
403      *  The basetype of the function that is being called. This type
404      *  is the 'function type', ie. accessing the returntype member of
405      *  this will return the FUNCTIONS return type.
406      */
407     data_type_t *type;
408
409     /*
410      * Variable: functionpointer
411      *  Pointer to function for function pointer call.
412      *
413      * Remarks:
414      *  This only associates with AST_TYPE_POINTERCALL, in which this
415      *  node is filled with the function in which to call by indirection
416      *  (address).
417      */
418      ast_t *functionpointer;
419 } ast_function_call_t;
420
421 /*
422  * Struct: ast_function_t
423  *  The *AST_TYPE_FUNCTION* ast node.
424  */
425 typedef struct {
426     /*
427      * Variable: name
428      *  The function name
429      */
430     char *name;
431
432     /*
433      * Variable: call
434      *  Data associated with a function call.
435      */
436     ast_function_call_t call;
437
438     /*
439      * Variable: params
440      *  Pointer to a list of parameters.
441      */
442     list_t *params;
443
444     /*
445      * Variable: locals
446      *  Pointer to a list of locals.
447      */
448     list_t *locals;
449
450     /*
451      * Variable: body
452      *  Pointer to an ast node which describes the body.
453      *
454      * Remarks:
455      *  A body is usually composed of a serise of ast nodes,
456      *  typically a compound expression, but could also contain
457      *  nested compound expressions. Think of this as a pointer
458      *  to the head of the beginning of a serise of basic-blocks
459      *  which are the forming of the function body.
460      */
461     ast_t  *body;
462 } ast_function_t;
463
464 /*
465  * Struct: ast_unary_t
466  *  Represents a unary operation in the AST tree
467  */
468 typedef struct {
469     /*
470      * Variable: operand
471      *  Pointer to the operand the unary operation is to
472      *  be performed on.
473      */
474     ast_t *operand;
475 } ast_unary_t;
476
477 /*
478  * Struct: ast_decl_t
479  *  Represents a declaration in the AST tree
480  */
481 typedef struct {
482     /*
483      * Variable: var
484      *  Pointer to the variable node associated with the
485      *  declaration.
486      */
487     ast_t *var;
488
489     /*
490      * Variable: init
491      *  When the declaration includes an initialization this points
492      *  to a initlization list.
493      */
494     list_t *init;
495 } ast_decl_t;
496
497 /*
498  * Struct: ast_ifthan_t
499  *  Represents a if-than node in the AST tree.
500  *
501  * Remarks:
502  *  Describes a two-branch gaurded by conditional test node in the AST
503  *  tree for implementing ternary expressions and if statements.
504  */
505 typedef struct {
506     /*
507      * Variable: cond
508      *  The condition node
509      */
510     ast_t  *cond;
511
512     /*
513      * Variable: then
514      *  Basic block for truth path in branch
515      */
516     ast_t  *then;
517
518     /*
519      * Variable: last
520      *  Basic block for false path in branch
521      */
522     ast_t  *last;
523 } ast_ifthan_t;
524
525 /*
526  * Struct: ast_for_t
527  *  Represents a for-loop node in the AST tree.
528  *
529  * Remarks:
530  *  Standard for loop with precondition / initilization expression,
531  *  conditionally testsed, and post step / expression, ergo
532  *  for(init; cond; step) body;
533  */
534 typedef struct {
535     /* Variable: init */
536     ast_t  *init;
537     /* Variable: cond */
538     ast_t  *cond;
539     /* Variable: step */
540     ast_t  *step;
541     /* Variable: body */
542     ast_t  *body;
543 } ast_for_t;
544
545
546 /*
547  * Struct: ast_init_t
548  *  Represents an initializer in the AST tree.
549  *
550  * Remarks:
551  *  Represents array initializer lists, as well as aggregate initializer
552  *  lists for structure, enum and union. Also represents a designated
553  *  initializer for a structure.
554  */
555 typedef struct {
556     /* Variable: value */
557     ast_t       *value;
558
559     /* Variable: offset */
560     int          offset;
561
562     /* Variable: type */
563     data_type_t *type;
564 } ast_init_t;
565
566 /*
567  * Struct: ast_switch_t
568  *  Represents a switch statement in the AST tree.
569  */
570 typedef struct {
571     /* Variable: expr */
572     ast_t       *expr;
573     /* Variable: body */
574     ast_t       *body;
575 } ast_switch_t;
576
577 /*
578  * Struct: ast_goto_t
579  *  Represents a goto statement (or label) in the AST tree.
580  */
581 typedef struct {
582     /*
583      * Variable: label
584      *  When not used as a goto statement, describes the name of a label
585      *  that may be 'gone to' with 'goto'
586      */
587     char *label;
588
589     /*
590      * Variable: where
591      *  Where to go (label wise) for a goto statement.
592      */
593     char *where;
594 } ast_goto_t;
595
596 /*
597  * Struct: ast_t
598  *  The monolthic ast tree and node at the same time.
599  *
600  * Remarks:
601  *  The ast tree is just a doubly-linked list of ast nodes which are
602  *  capable of being all the possible ast nodes at once. This is
603  *  acomplished with a rather large union of all ast nodes. The only
604  *  thing that declares what a node actually is, is the nodes type
605  *  member. This is beneficial to keeping the complexity of the AST
606  *  tree down, while also keeping memory footprint low. One more
607  *  interesting aspect of this is the ability to have the AST tree
608  *  nodes (next, prev), which make up the doubly-linked list part
609  *  of the same union, giving us a free way to terminate the tree
610  *  without using additional space to determine it.
611  */
612 struct ast_s {
613     int          type;
614     data_type_t *ctype;
615
616     union {
617         struct {
618             int         casebeg;
619             int         caseend;
620         };
621
622         long            integer;
623         char            character;
624         ast_string_t    string;
625         ast_variable_t  variable;
626         ast_function_t  function;
627         ast_unary_t     unary;
628         ast_decl_t      decl;
629         ast_ifthan_t    ifstmt;
630         ast_for_t       forstmt;
631         ast_switch_t    switchstmt;
632         ast_t          *returnstmt;
633         list_t         *compound;
634         ast_init_t      init;
635         ast_goto_t      gotostmt;
636         ast_t          *ap;
637
638         struct {
639             ast_t *left;
640             ast_t *right;
641         };
642
643         struct {
644             ast_t       *structure;
645             char        *field;
646             data_type_t *fieldtype;
647         };
648
649         struct {
650             double value;
651             char  *label;
652         } floating;
653     };
654 };
655
656 extern data_type_t *ast_data_table[AST_DATA_COUNT];
657
658 extern list_t      *ast_locals;
659 extern list_t      *ast_gotos;
660 extern table_t     *ast_globalenv;
661 extern table_t     *ast_localenv;
662 extern table_t     *ast_structures;
663 extern table_t     *ast_unions;
664 extern table_t     *ast_labels;
665
666 /*
667  * Function: ast_structure_reference
668  *  Creates an structure reference of a given type for a given field
669  *
670  * Parameters:
671  *  type      - The type of the field for reference
672  *  structure - The structure that contains said field to be referenced
673  *  name      - The name of the field in that structure to reference
674  *
675  * Returns:
676  *  An ast node referencing that field in that paticular structure on
677  *  success, otherwise NULL.
678  */
679 ast_t *ast_structure_reference(data_type_t *type, ast_t *structure, char *name);
680
681 /*
682  * Function: ast_structure_new
683  *  Creates a structure data type
684  *
685  * Parameters;
686  *  field    - A table of data_type_t fields for the structure
687  *  size     - The size of the structure
688  *  isstruct - true if structure, false if structure-like
689  *
690  * Returns:
691  *  A new structure data type with the specified fields and size on
692  *  success, NULL otherwise.
693  */
694 data_type_t *ast_structure_new(table_t *fields, int size, bool isstruct);
695
696
697 ast_t *ast_new_unary(int type, data_type_t *data, ast_t *operand);
698 ast_t *ast_new_binary(data_type_t *ctype, int type, ast_t *left, ast_t *right);
699 ast_t *ast_new_integer(data_type_t *type, int value);
700 ast_t *ast_new_floating(data_type_t *, double value);
701 ast_t *ast_new_char(char value);
702 ast_t *ast_new_string(char *value);
703 ast_t *ast_new_label(char *);
704
705 char *ast_label(void);
706
707 ast_t *ast_declaration(ast_t *var, list_t *init);
708 ast_t *ast_variable_local(data_type_t *type, char *name);
709 ast_t *ast_variable_global(data_type_t *type, char *name);
710 ast_t *ast_call(data_type_t *type, char *name, list_t *args);
711 ast_t *ast_pointercall(ast_t *ast, list_t *args);
712 ast_t *ast_function(data_type_t *type, char *name, list_t *params, ast_t *body, list_t *locals);
713 ast_t *ast_initializer(ast_t *, data_type_t *, int);
714 ast_t *ast_if(ast_t *cond, ast_t *then, ast_t *last);
715 ast_t *ast_for(ast_t *init, ast_t *cond, ast_t *step, ast_t *body);
716 ast_t *ast_while(ast_t *cond, ast_t *body);
717 ast_t *ast_do(ast_t *cond, ast_t *body);
718 ast_t *ast_return(ast_t *val);
719 ast_t *ast_compound(list_t *statements);
720 ast_t *ast_ternary(data_type_t *type, ast_t *cond, ast_t *then, ast_t *last);
721 ast_t *ast_switch(ast_t *expr, ast_t *body);
722 ast_t *ast_case(int begin, int end);
723 ast_t *ast_goto(char *);
724 ast_t *ast_goto_computed(ast_t *expression);
725 ast_t *ast_label_address(char *);
726 ast_t *ast_make(int type);
727
728 ast_t *ast_va_start(ast_t *);
729 ast_t *ast_va_arg(data_type_t *, ast_t*);
730
731 ast_t *ast_designator(char *name, ast_t *func);
732
733 data_type_t *ast_prototype(data_type_t *returntype, list_t *paramtypes, bool dots);
734 data_type_t *ast_pointer(data_type_t *type);
735 data_type_t *ast_array(data_type_t *type, int size);
736 data_type_t *ast_array_convert(data_type_t *ast);
737 data_type_t *ast_result_type(int operation, data_type_t *);
738
739 ast_t       *ast_designator_convert(ast_t *ast);
740
741 bool ast_struct_compare(data_type_t *a, data_type_t *b);
742
743 /*
744  * Function: ast_type_string
745  *  Get the type of a data_type_t as a string.
746  */
747 const char *ast_type_string(data_type_t *type);
748
749 /*
750  * Function: ast_type_isinteger
751  *  Check if a given data type is an integral type.
752  *
753  * Parameters:
754  *  type    - pointer to the data_type_t object to check
755  *
756  * Returns:
757  *  true if *type* is integral type, false otherwise.
758  *
759  * Remarks:
760  *  Integral includes any of the following data types:
761  *  - TYPE_CHAR
762  *  - TYPE_INT
763  *  - TYPE_SHORT
764  *  - TYPE_LONG
765  *  - TYPE_LLONG
766  */
767 bool ast_type_isinteger(data_type_t *type);
768
769 /*
770  * Function: ast_type_isfloating
771  *  Check if a given data type is a floating-point one.
772  *
773  * Parameters:
774  *  type    - pointer to the data_type_t object to check
775  *
776  * Returns:
777  *  true if *type* is floating point, false otherwise.
778  *
779  * Remarks:
780  *  Floating-point includes any of the following data types
781  *  - TYPE_FLOAT
782  *  - TYPE_DOUBLE
783  *  - TYPE_LDOUBLE
784  */
785 bool ast_type_isfloating(data_type_t *type);
786
787 /*
788  * Function: ast_type_isstring
789  *  Check if a given data type is string
790  *
791  * Parameters:
792  *  type    - pointer to the data_type object to check
793  *
794  * Returns:
795  *  trye if *type* is a string type, false otherwise.
796  *
797  * Remarks:
798  *  string type is determined if it's an array and the base
799  *  type of that array (when decayed to pointer type) is
800  *  TYPE_CHAR
801  */
802 bool ast_type_isstring(data_type_t *type);
803
804 data_type_t *ast_type_copy(data_type_t *type);
805 data_type_t *ast_type_copy_incomplete(data_type_t *type);
806 data_type_t *ast_type_create(type_t type, bool sign);
807 data_type_t *ast_type_stub(void);
808
809 ast_t *ast_type_convert(data_type_t *type, ast_t *ast);
810
811
812 char *ast_string(ast_t *ast);
813
814 #endif