source: mainline/uspace/app/sbi/src/tdata_t.h

Last change on this file was c5cb943d, checked in by Jiri Svoboda <jiri@…>, 15 years ago

Update SBI to rev. 291.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * Copyright (c) 2010 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
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.
16 *
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.
27 */
28
29/** @file Static type system representation. */
30
31#ifndef TDATA_T_H_
32#define TDATA_T_H_
33
34#include "intmap_t.h"
35
36/** Class of primitive type. */
37typedef 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;
51
52/** Primitive type. */
53typedef struct {
54 /** Class of primitive type */
55 tprimitive_class_t tpc;
56} tdata_primitive_t;
57
58/** Object type. */
59typedef struct {
60 /** @c sn_static if expression is a static CSI reference */
61 statns_t static_ref;
62
63 /** CSI definition */
64 struct stree_csi *csi;
65
66 /** (Real) type arguments */
67 list_t targs; /* of tdata_item_t */
68} tdata_object_t;
69
70/** Array type. */
71typedef struct {
72 /** Base type item */
73 struct tdata_item *base_ti;
74
75 /** Rank */
76 int rank;
77
78 /** Extents */
79 list_t extents; /* of stree_expr_t */
80} tdata_array_t;
81
82/** Function signature type.
83 *
84 * This is a part of functional type or delegate type.
85 */
86typedef struct {
87 /** Types of fixed arguments. */
88 list_t arg_ti; /* of tdata_item_t */
89
90 /** Type of variadic argument */
91 struct tdata_item *varg_ti;
92
93 /** Return type */
94 struct tdata_item *rtype;
95} tdata_fun_sig_t;
96
97/** Delegate type. */
98typedef struct {
99 /** Delegate definition or @c NULL if anonymous delegate */
100 struct stree_deleg *deleg;
101
102 /** Delegate signature type */
103 tdata_fun_sig_t *tsig;
104} tdata_deleg_t;
105
106/** Enum-base type.
107 *
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).
111 */
112typedef struct {
113 /** Enum definition */
114 struct stree_enum *enum_d;
115} tdata_ebase_t;
116
117/** Enum type. */
118typedef struct {
119 /** Enum definition */
120 struct stree_enum *enum_d;
121} tdata_enum_t;
122
123/** Functional type. */
124typedef struct {
125 /** Delegate definition or @c NULL if anonymous delegate */
126 struct stree_deleg *deleg;
127
128 /** Function signature type */
129 tdata_fun_sig_t *tsig;
130} tdata_fun_t;
131
132/** Type variable reference. */
133typedef struct {
134 /** Definition of type argument this variable is referencing. */
135 struct stree_targ *targ;
136} tdata_vref_t;
137
138typedef 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;
158
159/** Type item, the result of evaluating a type expression. */
160typedef struct tdata_item {
161 titem_class_t tic;
162
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;
174
175/** Type variable valuation (mapping of type argument names to values). */
176typedef struct {
177 /** Maps name SID to type item */
178 intmap_t tvv; /* of tdata_item_t */
179} tdata_tvv_t;
180
181#endif
Note: See TracBrowser for help on using the repository browser.