#ifndef ASTP_H
#define ASTP_H
#include <nidl.h>
#include <ast.h>
#define NDR_C_BOOLEAN_SIZE 1
#define NDR_C_BYTE_SIZE 1
#define NDR_C_CHARACTER_SIZE 1
#define NDR_C_SMALL_INT_SIZE 1
#define NDR_C_SHORT_INT_SIZE 2
#define NDR_C_LONG_INT_SIZE 4
#define NDR_C_HYPER_INT_SIZE 8
#define NDR_C_SHORT_FLOAT_SIZE 4
#define NDR_C_LONG_FLOAT_SIZE 8
#define NDR_C_POINTER_SIZE 4
#define ASTP_C_SMALL_MAX 127
#define ASTP_C_SMALL_MIN -128
#define ASTP_C_USMALL_MAX 255
#define ASTP_C_USMALL_MIN 0
#define ASTP_C_SHORT_MAX 32767
#define ASTP_C_SHORT_MIN -32768
#define ASTP_C_USHORT_MAX 65535
#define ASTP_C_USHORT_MIN 0
#define ASTP_C_LONG_MAX 2147483647
#define ASTP_C_LONG_MIN (-2147483647 - 1)
#define ASTP_C_ULONG_MAX 4294967295.0
#define ASTP_C_ULONG_MIN 0
#define ASTP_BROADCAST 0x00000001
#define ASTP_MAYBE 0x00000002
#define ASTP_IDEMPOTENT 0x00000004
#define ASTP_LOCAL 0x08000000
#define ASTP_REFLECT_DELETIONS 0x04000000
#define ASTP_IN 0x00000008
#define ASTP_OUT 0x00000010
#define ASTP_IN_SHAPE 0x00000020
#define ASTP_OUT_SHAPE 0x00000040
#define ASTP_PTR 0x00000080
#define ASTP_STRING0 0x00000100
#define ASTP_STRING 0x00000200
#define ASTP_IGNORE 0x00000400
#define ASTP_SMALL 0x00000800
#define ASTP_CONTEXT 0x00001000
#define ASTP_REF 0x00002000
#define ASTP_UNIQUE 0x00004000
#define ASTP_HANDLE 0x00008000
#define ASTP_UNALIGN 0x00010000
#define ASTP_TRANSMIT_AS 0x00020000
#define ASTP_ALIGN_SMALL 0x00040000
#define ASTP_ALIGN_SHORT 0x00080000
#define ASTP_ALIGN_LONG 0x00100000
#define ASTP_ALIGN_HYPER 0x00200000
#define ASTP_V1_ENUM 0x00400000
#define ASTP_SWITCH_TYPE 0x00800000
#define ASTP_CASE 0x01000000
#define ASTP_DEFAULT 0x02000000
#define ASTP_RANGE 0x10000000
#define ASTP_MAX_ATTRIBUTE 0x10000000
#define ASTP_OPERATION_FLAGS ASTP_BROADCAST | ASTP_MAYBE | ASTP_IDEMPOTENT | \
ASTP_REFLECT_DELETIONS | ASTP_LOCAL
#define ASTP_PARAMETER_FLAGS ASTP_STRING | ASTP_STRING0 | \
ASTP_SMALL | ASTP_CONTEXT | \
ASTP_IN | ASTP_OUT | ASTP_IN_SHAPE | \
ASTP_OUT_SHAPE | ASTP_UNIQUE | \
ASTP_REF | ASTP_PTR | ASTP_RANGE
#define ASTP_FIELD_FLAGS ASTP_STRING | ASTP_STRING0 | \
ASTP_IGNORE | ASTP_SMALL | ASTP_CONTEXT | ASTP_UNIQUE | \
ASTP_REF | ASTP_PTR | ASTP_RANGE
#define ASTP_TYPE_FLAGS ASTP_STRING | ASTP_STRING0 | ASTP_UNIQUE | \
ASTP_SWITCH_TYPE | \
ASTP_REF | ASTP_SMALL | ASTP_CONTEXT | \
ASTP_HANDLE | ASTP_TRANSMIT_AS | ASTP_UNALIGN | \
ASTP_ALIGN_SMALL | ASTP_ALIGN_SHORT | ASTP_ALIGN_LONG | \
ASTP_ALIGN_HYPER | ASTP_UNIQUE | ASTP_PTR | ASTP_V1_ENUM
#define ASTP_ARM_FLAGS ASTP_STRING | ASTP_STRING0 | \
ASTP_CASE | ASTP_DEFAULT | \
ASTP_SMALL | ASTP_CONTEXT | ASTP_UNIQUE | \
ASTP_REF | ASTP_PTR
#define ASTP_IF_PORT 0x00000040
#define ASTP_IF_UUID 0x00000080
#define ASTP_IF_VERSION 0x00000100
#define ASTP_IF_EXCEPTIONS 0x00000200
#define ASTP_CLR_IF_AF(if) \
(if)->fe_info->type_specific.if_flags = 0
#define ASTP_SET_IF_AF(if,attribute) \
(if)->fe_info->type_specific.if_flags |= (attribute)
#define ASTP_IF_AF_SET(if,attribute) \
(((if)->fe_info->type_specific.if_flags & (attribute)) != 0)
#define ASTP_TEST_ATTR(__attr_ptr,__flags) \
((((__attr_ptr)->attr_flags) & (__flags)) != 0)
#define ASTP_CLR_ATTR(__attr_ptr,__flags) \
(__attr_ptr)->attr_flags &= (~(__flags))
typedef unsigned long ASTP_attr_flag_t;
typedef struct ASTP_attributes_t
{
struct ASTP_type_attr_n_t *bounds;
ASTP_attr_flag_t attr_flags;
NAMETABLE_id_t iid_is_name;
} ASTP_attributes_t;
typedef struct ASTP_node_t
{
fe_info_t *fe_info;
be_info_t *be_info;
struct ASTP_node_t *next;
struct ASTP_node_t *last;
} ASTP_node_t, *ASTP_node_t_p;
typedef enum
{
ASTP_constant_bound,
ASTP_default_bound,
ASTP_open_bound
} ASTP_bound_t;
typedef struct ASTP_array_index_n_t
{
fe_info_t *fe_info;
be_info_t *be_info;
struct ASTP_array_index_n_t *next;
struct ASTP_array_index_n_t *last;
ASTP_bound_t lower_bound_type;
ASTP_bound_t upper_bound_type;
AST_constant_n_t *lower_bound;
AST_constant_n_t *upper_bound;
} ASTP_array_index_n_t;
typedef enum
{
last_is_k,
first_is_k,
max_is_k,
min_is_k,
length_is_k,
size_is_k,
switch_is_k,
iid_is_k,
range_k
} ASTP_attr_k_t;
typedef struct ASTP_type_attr_n_t
{
fe_info_t *fe_info;
be_info_t *be_info;
struct ASTP_type_attr_n_t *next;
struct ASTP_type_attr_n_t *last;
int source_line;
ASTP_attr_k_t kind;
boolean is_expr;
union {
struct {
NAMETABLE_id_t name;
boolean pointer;
} simple;
struct AST_exp_n_t * expr;
} b;
} ASTP_type_attr_n_t;
typedef struct ASTP_field_ref_ctx_t
{
fe_info_t *fe_info;
be_info_t *be_info;
struct ASTP_field_ref_ctx_t *next;
struct ASTP_field_ref_ctx_t *last;
NAMETABLE_id_t name;
AST_field_ref_n_t *field_ref_ptr;
} ASTP_field_ref_ctx_t;
typedef struct ASTP_declarator_n_t
{
fe_info_t *fe_info;
be_info_t *be_info;
struct ASTP_declarator_n_t *next;
struct ASTP_declarator_n_t *last;
NAMETABLE_id_t name;
struct ASTP_declarator_op_n_t *next_op;
struct ASTP_declarator_op_n_t *last_op;
} ASTP_declarator_n_t;
typedef struct ASTP_declarator_op_n_t
{
struct ASTP_declarator_op_n_t *next_op;
AST_type_k_t op_kind;
union
{
ASTP_node_t *node;
ASTP_array_index_n_t *indices;
AST_type_n_t *type_node_ptr;
AST_parameter_n_t *routine_params;
int pointer_count;
} op_info;
} ASTP_declarator_op_n_t;
typedef struct ASTP_tag_ref_n_t
{
fe_info_t *fe_info;
be_info_t *be_info;
struct ASTP_tag_ref_n_t *next;
struct ASTP_tag_ref_n_t *last;
NAMETABLE_id_t name;
AST_type_k_t ref_kind;
AST_type_n_t *type_node_ptr;
} ASTP_tag_ref_n_t;
typedef struct ASTP_parameter_count_t
{
int in_params;
int out_params;
} ASTP_parameter_count_t;
boolean ASTP_expr_is_simple(
parser_location_p location,
AST_exp_n_t * exp
);
AST_exp_n_t * AST_expression(
parser_location_p location,
unsigned long exp_type,
AST_exp_n_t * oper1,
AST_exp_n_t * oper2,
AST_exp_n_t * oper3
);
boolean ASTP_evaluate_expr(
parser_location_p location,
AST_exp_n_t * exp_node,
boolean constant_only
);
long ASTP_expr_integer_value(
parser_location_p location,
AST_exp_n_t * exp
);
AST_exp_n_t * AST_exp_boolean_constant(
parser_location_p location,
boolean value
);
AST_exp_n_t * AST_exp_null_constant(
parser_location_p location
);
AST_exp_n_t * AST_exp_string_constant(
parser_location_p location,
STRTAB_str_t string
);
AST_exp_n_t * AST_exp_identifier(
parser_location_p location,
NAMETABLE_id_t name
);
AST_exp_n_t * AST_exp_char_constant(
parser_location_p location,
char value
);
AST_exp_n_t * AST_exp_integer_constant(
parser_location_p location,
long value,
int int_signed
);
AST_constant_n_t * AST_constant_from_exp(
parser_location_p location,
AST_exp_n_t * exp
);
extern int interface_pointer_class;
extern AST_type_n_t *ASTP_transmit_as_type;
extern AST_type_n_t *ASTP_switch_type;
extern AST_case_label_n_t *ASTP_case;
extern AST_interface_n_t * the_interface;
extern AST_cpp_quote_n_t * global_cppquotes;
extern AST_cpp_quote_n_t * global_cppquotes_post;
extern AST_import_n_t * global_imports;
extern ASTP_field_ref_ctx_t *ASTP_field_ref_ctx_list;
extern ASTP_tag_ref_n_t *ASTP_tag_ref_list;
extern boolean ASTP_parsing_main_idl;
extern AST_constant_n_t *zero_constant_p;
extern AST_type_n_t *ASTP_char_ptr,
*ASTP_boolean_ptr,
*ASTP_byte_ptr,
*ASTP_void_ptr,
*ASTP_handle_ptr,
*ASTP_short_float_ptr,
*ASTP_long_float_ptr,
*ASTP_small_int_ptr,
*ASTP_short_int_ptr,
*ASTP_long_int_ptr,
*ASTP_hyper_int_ptr,
*ASTP_small_unsigned_ptr,
*ASTP_short_unsigned_ptr,
*ASTP_long_unsigned_ptr,
*ASTP_hyper_unsigned_ptr;
extern NAMETABLE_id_t ASTP_tagged_union_id;
ASTP_type_attr_n_t *AST_array_bound_info(
parser_location_p location,
NAMETABLE_id_t name,
ASTP_attr_k_t kind,
boolean is_pointer
);
ASTP_type_attr_n_t * AST_array_bound_from_expr(
parser_location_p location,
AST_exp_n_t * exp,
ASTP_attr_k_t kind
);
ASTP_type_attr_n_t * AST_range_from_expr(
parser_location_p location,
AST_exp_n_t * min_exp,
AST_exp_n_t * max_exp
);
void AST_capture_operation_attrs(
void
);
AST_constant_n_t *AST_clone_constant(
parser_location_p location,
AST_constant_n_t *constant_node_p
);
ASTP_node_t *AST_concat_element(
ASTP_node_t *list_head,
ASTP_node_t *element
);
AST_constant_n_t *AST_constant_node(
parser_location_p location,
AST_constant_k_t kind
);
ASTP_declarator_n_t *AST_declarator_node(
NAMETABLE_id_t name
);
void AST_declarator_operation(
ASTP_declarator_n_t *declarator,
AST_type_k_t op_kind,
ASTP_node_t *op_info,
int pointer_count
);
AST_parameter_n_t *AST_declarator_to_param(
parser_location_p location,
ASTP_attributes_t *attributes,
AST_type_n_t *type,
ASTP_declarator_n_t *declarator
);
AST_type_p_n_t *AST_declarators_to_types(
parser_location_p ploc,
AST_interface_n_t * ifp,
AST_type_n_t *type_ptr,
ASTP_declarator_n_t *declarators_ptr,
ASTP_attributes_t *attributes
);
AST_export_n_t *AST_export_node(
parser_location_p location,
ASTP_node_t *export_ptr,
AST_export_k_t kind
);
AST_cpp_quote_n_t *AST_cpp_quote_node(
parser_location_p location,
STRTAB_str_t text
);
AST_include_n_t *AST_include_node(
parser_location_p location,
STRTAB_str_t include_file,
STRTAB_str_t include_file_name
);
AST_import_n_t *AST_import_node(
parser_location_p location,
STRTAB_str_t imported_file
);
AST_exception_n_t *AST_exception_node(
parser_location_p location,
NAMETABLE_id_t excep_name
);
AST_name_n_t *AST_name_node(
NAMETABLE_id_t name
);
void AST_init(
parser_location_p location
);
AST_constant_n_t *AST_integer_constant(
parser_location_p location,
long int value
);
AST_interface_n_t *AST_interface_node(
parser_location_p location
);
void AST_finish_interface_node(
parser_location_p location,
AST_interface_n_t *interface_node
);
AST_operation_n_t *AST_operation_node(
parser_location_p location,
AST_type_n_t *result_type,
ASTP_declarator_n_t *declarator,
ASTP_attributes_t *attributes
);
AST_parameter_n_t * AST_parameter_node(
parser_location_p location,
NAMETABLE_id_t identifier
);
AST_rep_as_n_t *AST_represent_as_node(
parser_location_p location,
NAMETABLE_id_t name
);
AST_cs_char_n_t *AST_cs_char_node(
parser_location_p location,
NAMETABLE_id_t name
);
AST_type_n_t *AST_set_type_attrs(
parser_location_p location,
AST_type_n_t *type_node_ptr,
ASTP_attributes_t *attributes
);
void AST_set_ports(
AST_interface_n_t *interface_node_p
);
AST_type_n_t *AST_type_node(
parser_location_p location,
AST_type_k_t kind
);
AST_type_p_n_t *AST_type_ptr_node(
parser_location_p location
);
AST_export_n_t *AST_types_to_exports(
parser_location_p location,
AST_type_p_n_t *type_p_list
);
AST_array_n_t *AST_array_node(
parser_location_p location,
AST_type_n_t *element_type_ptr
);
AST_array_index_n_t *AST_array_index_node(
parser_location_p location,
unsigned short array_size
);
ASTP_array_index_n_t *ASTP_array_index_node(
parser_location_p location,
AST_constant_n_t *lower_bound,
ASTP_bound_t lower_bound_type,
AST_constant_n_t *upper_bound,
ASTP_bound_t upper_bound_type
);
AST_constant_n_t *AST_boolean_constant(
parser_location_p location,
boolean value
);
AST_case_label_n_t *AST_case_label_node(
parser_location_p location,
AST_constant_n_t *case_label
);
AST_constant_n_t *AST_char_constant(
parser_location_p location,
char value
);
AST_arm_n_t *AST_declarator_to_arm(
parser_location_p location,
AST_type_n_t *type_ptr,
ASTP_declarator_n_t *declarator,
ASTP_attributes_t *attributes
);
AST_field_n_t *AST_declarators_to_fields(
parser_location_p location,
ASTP_declarator_n_t *declarators_ptr,
AST_type_n_t *type_ptr,
ASTP_attributes_t *attributes
);
AST_case_label_n_t *AST_default_case_label_node(
parser_location_p location
);
AST_type_n_t *AST_disc_union_node(
parser_location_p location,
NAMETABLE_id_t tag_name,
NAMETABLE_id_t union_name,
NAMETABLE_id_t disc_name,
AST_type_n_t *disc_type,
AST_arm_n_t *arms_list
);
AST_type_n_t *AST_enumerator_node(
parser_location_p location,
AST_constant_n_t *constant_list,
AST_type_k_t size
);
AST_constant_n_t *AST_enum_constant(
parser_location_p location,
NAMETABLE_id_t identifier,
AST_exp_n_t * exp
);
AST_constant_n_t *AST_finish_constant_node(
parser_location_p location,
AST_constant_n_t *constant_ptr,
ASTP_declarator_n_t *declarator,
AST_type_n_t *type_ptr
);
AST_field_attr_n_t *AST_field_attr_node(
parser_location_p location
);
AST_field_ref_n_t *AST_field_ref_node(
parser_location_p location,
unsigned short dimension
);
AST_operation_n_t *AST_function_node(
parser_location_p location,
AST_type_n_t *result_type,
NAMETABLE_id_t op_name,
AST_parameter_n_t *parameters
);
AST_arm_n_t *AST_label_arm(
AST_arm_n_t *member,
AST_case_label_n_t *case_labels
);
AST_type_n_t *AST_lookup_integer_type_node(
AST_type_k_t int_size,
int int_signed
);
AST_type_n_t *AST_lookup_type_node(
AST_type_k_t kind
);
AST_type_n_t *AST_lookup_named_type(
parser_location_p location,
NAMETABLE_id_t type_name
);
AST_constant_n_t *AST_named_constant(
parser_location_p location,
NAMETABLE_id_t const_name
);
AST_constant_n_t *AST_null_constant(
parser_location_p location
);
AST_type_n_t *AST_pipe_node(
parser_location_p location,
AST_type_n_t *pipe_type
);
AST_pointer_n_t *AST_pointer_node(
parser_location_p location,
AST_type_n_t * pointee
);
AST_type_n_t *AST_set_union_arms(
AST_type_n_t *union_type_ptr,
AST_arm_n_t *member_list
);
AST_constant_n_t *AST_string_constant(
parser_location_p location,
STRTAB_str_t value
);
AST_type_n_t *AST_structure_node(
parser_location_p location,
AST_field_n_t *field_list,
NAMETABLE_id_t identifier
);
AST_field_n_t *AST_tag_declarators_to_fields(
ASTP_declarator_n_t *declarators,
NAMETABLE_id_t identifier,
ASTP_attributes_t *attributes,
AST_type_k_t kind
);
AST_type_n_t *AST_type_from_tag(
parser_location_p location,
AST_type_k_t kind,
NAMETABLE_id_t identifier
);
void AST_set_type_boolean_attrs(
AST_type_n_t *type_node
);
void AST_clear_type_attrs(
void
);
boolean AST_lookup_field_attr(
ASTP_attributes_t *attributes,
ASTP_attr_k_t field_attr
);
AST_field_attr_n_t *AST_set_field_attrs(
parser_location_p location,
ASTP_attributes_t *attributes,
ASTP_node_t *parent_node,
AST_type_n_t *type_node
);
void ASTP_free_declarators(
ASTP_declarator_n_t *declarators_ptr
);
void ASTP_free_simple_list(
ASTP_node_t *list_ptr
);
AST_type_n_t *AST_propagate_type(
parser_location_p location,
AST_type_n_t *type_node_ptr,
ASTP_declarator_n_t *declarator_ptr,
ASTP_attributes_t *attributes,
ASTP_node_t *parent_node
);
void ASTP_add_name_binding(
parser_location_p location,
NAMETABLE_id_t name,
void *AST_node
);
AST_type_n_t *ASTP_chase_ptr_to_kind(
AST_type_n_t *type_node,
AST_type_k_t kind
);
AST_type_n_t *ASTP_chase_ptr_to_type(
AST_type_n_t *type_node
);
ASTP_node_t *ASTP_lookup_binding(
parser_location_p location,
NAMETABLE_id_t name,
fe_node_k_t node_kind,
boolean noforward_ref
);
void ASTP_patch_tag_references(
parser_location_p location,
AST_interface_n_t *interface_node_ptr
);
void ASTP_patch_field_reference(
parser_location_p location
);
void ASTP_set_fe_info(
parser_location_p location,
fe_info_t **fe_info_ptr,
fe_node_k_t fe_node_kind
);
void ASTP_save_tag_ref(
NAMETABLE_id_t identifier,
AST_type_k_t kind,
AST_type_n_t *type_node_ptr
);
void ASTP_process_pa_type(
AST_type_n_t *type_node_ptr
);
void AST_set_flags(
parser_location_p location,
AST_flags_t *flags,
ASTP_node_t *node_ptr,
ASTP_attributes_t *attributes
);
long AST_attribute_to_token(
ASTP_attr_flag_t *attribute
);
AST_arm_n_t *AST_arm_node(
parser_location_p location,
NAMETABLE_id_t name,
AST_case_label_n_t *label,
AST_type_n_t *type
);
void ASTP_parse_port(
AST_interface_n_t *interface_p,
STRTAB_str_t port_string
);
void ASTP_validate_forward_ref(
parser_location_p location,
AST_type_n_t *type
);
NAMETABLE_id_t AST_generate_name(
AST_interface_n_t *int_p,
const char *suffix
);
void ASTP_validate_integer(
parser_location_p location,
AST_exp_n_t *expression
);
void KEYWORDS_init(
void
);
const char *KEYWORDS_lookup_text(
long token
);
int KEYWORDS_screen(
const char * identifier,
NAMETABLE_id_t * id
);
void ASTP_set_array_rep_type
(
parser_location_p location,
AST_type_n_t *type_node_ptr,
AST_type_n_t *array_base_type,
boolean is_varying
);
void ASTP_set_implicit_handle(
AST_interface_n_t *int_p,
NAMETABLE_id_t type_name,
NAMETABLE_id_t handle_name
);
#endif