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 | /** Class of primitive type. */
|
---|
35 | typedef enum {
|
---|
36 | /** Integer type */
|
---|
37 | tpc_int,
|
---|
38 | /** Special type for nil reference */
|
---|
39 | tpc_nil,
|
---|
40 | /** String type */
|
---|
41 | tpc_string,
|
---|
42 | /** Resource type */
|
---|
43 | tpc_resource
|
---|
44 | } tprimitive_class_t;
|
---|
45 |
|
---|
46 | /** Primitive type. */
|
---|
47 | typedef struct {
|
---|
48 | /** Class of primitive type */
|
---|
49 | tprimitive_class_t tpc;
|
---|
50 | } tdata_primitive_t;
|
---|
51 |
|
---|
52 | /** Object type. */
|
---|
53 | typedef struct {
|
---|
54 | /** @c true if expression is a static CSI reference */
|
---|
55 | bool_t static_ref;
|
---|
56 |
|
---|
57 | /** CSI definition */
|
---|
58 | struct stree_csi *csi;
|
---|
59 | } tdata_object_t;
|
---|
60 |
|
---|
61 | /** Array type. */
|
---|
62 | typedef struct {
|
---|
63 | /** Base type item */
|
---|
64 | struct tdata_item *base_ti;
|
---|
65 |
|
---|
66 | /** Rank */
|
---|
67 | int rank;
|
---|
68 |
|
---|
69 | /** Extents */
|
---|
70 | list_t extents; /* of stree_expr_t */
|
---|
71 | } tdata_array_t;
|
---|
72 |
|
---|
73 | /** Generic type. */
|
---|
74 | typedef struct {
|
---|
75 | } tdata_generic_t;
|
---|
76 |
|
---|
77 | /** Functional type. */
|
---|
78 | typedef struct {
|
---|
79 | /**
|
---|
80 | * Function definition. We'll leave expansion to the call operation.
|
---|
81 | */
|
---|
82 | struct stree_fun *fun;
|
---|
83 | } tdata_fun_t;
|
---|
84 |
|
---|
85 | typedef enum {
|
---|
86 | tic_tprimitive,
|
---|
87 | tic_tobject,
|
---|
88 | tic_tarray,
|
---|
89 | tic_tgeneric,
|
---|
90 | tic_tfun
|
---|
91 | } titem_class_t;
|
---|
92 |
|
---|
93 | /** Type item, the result of evaluating a type expression. */
|
---|
94 | typedef struct tdata_item {
|
---|
95 | titem_class_t tic;
|
---|
96 |
|
---|
97 | union {
|
---|
98 | tdata_primitive_t *tprimitive;
|
---|
99 | tdata_object_t *tobject;
|
---|
100 | tdata_array_t *tarray;
|
---|
101 | tdata_generic_t *tgeneric;
|
---|
102 | tdata_fun_t *tfun;
|
---|
103 | } u;
|
---|
104 | } tdata_item_t;
|
---|
105 |
|
---|
106 | #endif
|
---|