Log files should have .txt extension.
[helenos.git] / uspace / app / sbi / src / tdata_t.h
blobdc341c88e4afba9ea29a17649838e4c2bb037346
1 /*
2 * Copyright (c) 2010 Jiri Svoboda
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 /** @file Static type system representation. */
31 #ifndef TDATA_T_H_
32 #define TDATA_T_H_
34 #include "intmap_t.h"
36 /** Class of primitive type. */
37 typedef enum {
38 /** Boolean type */
39 tpc_bool,
40 /** Character type */
41 tpc_char,
42 /** Integer type */
43 tpc_int,
44 /** Special type for nil reference */
45 tpc_nil,
46 /** String type */
47 tpc_string,
48 /** Resource type */
49 tpc_resource
50 } tprimitive_class_t;
52 /** Primitive type. */
53 typedef struct {
54 /** Class of primitive type */
55 tprimitive_class_t tpc;
56 } tdata_primitive_t;
58 /** Object type. */
59 typedef struct {
60 /** @c sn_static if expression is a static CSI reference */
61 statns_t static_ref;
63 /** CSI definition */
64 struct stree_csi *csi;
66 /** (Real) type arguments */
67 list_t targs; /* of tdata_item_t */
68 } tdata_object_t;
70 /** Array type. */
71 typedef struct {
72 /** Base type item */
73 struct tdata_item *base_ti;
75 /** Rank */
76 int rank;
78 /** Extents */
79 list_t extents; /* of stree_expr_t */
80 } tdata_array_t;
82 /** Function signature type.
84 * This is a part of functional type or delegate type.
86 typedef struct {
87 /** Types of fixed arguments. */
88 list_t arg_ti; /* of tdata_item_t */
90 /** Type of variadic argument */
91 struct tdata_item *varg_ti;
93 /** Return type */
94 struct tdata_item *rtype;
95 } tdata_fun_sig_t;
97 /** Delegate type. */
98 typedef struct {
99 /** Delegate definition or @c NULL if anonymous delegate */
100 struct stree_deleg *deleg;
102 /** Delegate signature type */
103 tdata_fun_sig_t *tsig;
104 } tdata_deleg_t;
106 /** Enum-base type.
108 * Type for expression which reference an enum declaration. In run time
109 * enum type reference is represented by @c rdata_deleg_t. (Which is used
110 * for any symbol references).
112 typedef struct {
113 /** Enum definition */
114 struct stree_enum *enum_d;
115 } tdata_ebase_t;
117 /** Enum type. */
118 typedef struct {
119 /** Enum definition */
120 struct stree_enum *enum_d;
121 } tdata_enum_t;
123 /** Functional type. */
124 typedef struct {
125 /** Delegate definition or @c NULL if anonymous delegate */
126 struct stree_deleg *deleg;
128 /** Function signature type */
129 tdata_fun_sig_t *tsig;
130 } tdata_fun_t;
132 /** Type variable reference. */
133 typedef struct {
134 /** Definition of type argument this variable is referencing. */
135 struct stree_targ *targ;
136 } tdata_vref_t;
138 typedef enum {
139 /** Primitive type item */
140 tic_tprimitive,
141 /** Object type item */
142 tic_tobject,
143 /** Array type item */
144 tic_tarray,
145 /** Delegate type item */
146 tic_tdeleg,
147 /** Enum-base type item */
148 tic_tebase,
149 /** Enum type item */
150 tic_tenum,
151 /** Function type item */
152 tic_tfun,
153 /** Type variable item */
154 tic_tvref,
155 /** Special error-recovery type item */
156 tic_ignore
157 } titem_class_t;
159 /** Type item, the result of evaluating a type expression. */
160 typedef struct tdata_item {
161 titem_class_t tic;
163 union {
164 tdata_primitive_t *tprimitive;
165 tdata_object_t *tobject;
166 tdata_array_t *tarray;
167 tdata_deleg_t *tdeleg;
168 tdata_ebase_t *tebase;
169 tdata_enum_t *tenum;
170 tdata_fun_t *tfun;
171 tdata_vref_t *tvref;
172 } u;
173 } tdata_item_t;
175 /** Type variable valuation (mapping of type argument names to values). */
176 typedef struct {
177 /** Maps name SID to type item */
178 intmap_t tvv; /* of tdata_item_t */
179 } tdata_tvv_t;
181 #endif