Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_value_compiled_value.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Interface afw_value Implementation for compiled_value
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 
15 #include "afw_internal.h"
16 
17 
18 #define impl_afw_value_optional_release NULL
19 #define impl_afw_value_get_reference NULL
20 
21 
22 
23 #define impl_afw_value_get_evaluated_meta \
24  afw_value_internal_get_evaluated_meta_default
25 
26 #define impl_afw_value_get_evaluated_metas \
27  afw_value_internal_get_evaluated_metas_default
28 
29 /* Declares and rti/inf defines for interface afw_value */
30 #define AFW_IMPLEMENTATION_ID "compiled_value"
31 #define AFW_IMPLEMENTATION_INF_SPECIFIER AFW_DEFINE_CONST_DATA
32 #define AFW_IMPLEMENTATION_INF_LABEL afw_value_compiled_value_inf
34 
35 
36 /*
37  * Implementation of method optional_evaluate for interface afw_value.
38  */
39 const afw_value_t *
41  const afw_value_t * instance,
42  const afw_pool_t * p,
43  afw_xctx_t *xctx)
44 {
45  const afw_value_compiled_value_t *self =
46  (const afw_value_compiled_value_t *)instance;
47 
48  /* Return the result of calling root value's evaluate(). */
49  return afw_value_evaluate(self->root_value, p, xctx);
50 }
51 
52 /*
53  * Implementation of method get_data_type for interface afw_value.
54  */
55 const afw_data_type_t *
56 impl_afw_value_get_data_type(
57  const afw_value_t * instance,
58  afw_xctx_t *xctx)
59 {
60  const afw_value_compiled_value_t *self =
61  (const afw_value_compiled_value_t *)instance;
62 
63  /* Return the result of calling root value's get_data_type(). */
64  return afw_value_get_data_type(self->root_value, xctx);
65 }
66 
67 /*
68  * Implementation of method get_evaluated_data_type for interface afw_value.
69  */
70 const afw_data_type_t *
71 impl_afw_value_get_evaluated_data_type(
72  const afw_value_t * instance,
73  afw_xctx_t *xctx)
74 {
75  const afw_value_compiled_value_t *self =
76  (const afw_value_compiled_value_t *)instance;
77 
78  /* Return the result of calling root value's get_evaluated_data_type(). */
79  return afw_value_get_evaluated_data_type(self->root_value, xctx);
80 }
81 
82 /*
83  * Implementation of method get_evaluated_data_type_parameter for interface
84  * afw_value.
85  */
86 const afw_utf8_t *
87 impl_afw_value_get_evaluated_data_type_parameter(
88  const afw_value_t * instance,
89  afw_xctx_t *xctx)
90 {
91  const afw_value_compiled_value_t *self =
92  (const afw_value_compiled_value_t *)instance;
93 
94  /*
95  * Return the result of calling root value's
96  * get_evaluated_data_type_parameter().
97  */
98  return afw_value_get_evaluated_data_type_parameter(self->root_value, xctx);
99 }
100 
101 /*
102  * Implementation of method compiler_listing for interface afw_value.
103  */
104 void
105 impl_afw_value_produce_compiler_listing(
106  const afw_value_t *instance,
107  const afw_writer_t *writer,
108  afw_xctx_t *xctx)
109 {
110  const afw_value_compiled_value_t *self =
111  (const afw_value_compiled_value_t *)instance;
112  const afw_utf8_t *reference_id;
113 
114  reference_id = afw_value_compiler_listing_for_child(
115  instance, writer, xctx);
116 
117  afw_value_compiler_listing_begin_value(writer, instance,
118  self->contextual, xctx);
119  afw_writer_write_z(writer, " See ---CompiledValue ", xctx);
120  afw_writer_write_utf8(writer, reference_id, xctx);
121  afw_writer_write_eol(writer, xctx);
122 }
123 
124 /*
125  * Implementation of method decompile for interface afw_value.
126  */
127 void
128 impl_afw_value_decompile(
129  const afw_value_t * instance,
130  const afw_writer_t * writer,
131  afw_xctx_t *xctx)
132 {
133  const afw_value_compiled_value_t *self =
134  (const afw_value_compiled_value_t *)instance;
135 
136  afw_value_decompile(self->root_value, writer, xctx);
137  /*FIXME Improve
138 
139  if (self->annotation) {
140  afw_writer_write_z(writer, "annotate(", xctx);
141  if (writer->tab) {
142  afw_writer_write_eol(writer, xctx);
143  afw_writer_increment_indent(writer, xctx);
144  }
145  annotation.inf = &afw_value_evaluated_object_inf;
146  annotation.internal = self->annotation;
147  afw_value_decompile((const afw_value_t *)&annotation, writer, xctx);
148  afw_writer_write_z(writer, ",", xctx);
149  if (writer->tab) {
150  afw_writer_write_eol(writer, xctx);
151  }
152  afw_value_decompile(self->value, writer, xctx);
153  if (writer->tab) {
154  afw_writer_write_eol(writer, xctx);
155  afw_writer_decrement_indent(writer, xctx);
156  }
157  afw_writer_write_z(writer, ")", xctx);
158  }
159  else {
160  afw_value_decompile(self->value, writer, xctx);
161  }
162  */
163 }
164 
165 
166 /*
167  * Implementation of method get_info for interface afw_value.
168  */
169 void
170 impl_afw_value_get_info(
171  const afw_value_t *instance,
172  afw_value_info_t *info,
173  const afw_pool_t *p,
174  afw_xctx_t *xctx)
175 {
176  afw_memory_clear(info);
177  info->value_inf_id = &instance->inf->rti.implementation_id;
178 }
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
Definition: afw_memory.h:47
const afw_value_t * impl_afw_value_optional_evaluate(const afw_value_t *instance, const afw_pool_t *p, afw_xctx_t *xctx)
#define afw_value_get_data_type(instance, xctx)
Call method get_data_type of interface afw_value.
#define afw_value_decompile(instance, writer, xctx)
Call method decompile of interface afw_value.
#define afw_value_get_evaluated_data_type(instance, xctx)
Call method get_evaluated_data_type of interface afw_value.
#define afw_value_get_evaluated_data_type_parameter(instance, xctx)
Call method get_evaluated_data_type_parameter of interface afw_value.
#define afw_value_evaluate(value, p, xctx)
Evaluate value if needed using specific pool.
Definition: afw_value.h:841
#define afw_writer_write_eol(instance, xctx)
Call method write_eol of interface afw_writer.
#define afw_writer_write_z(writer, s_z, xctx)
Call afw_writer_write() with zero terminated string.
Definition: afw_writer.h:35
#define afw_writer_write_utf8(writer, S, xctx)
Call afw_writer_write() with a afw_utf8_t string.
Definition: afw_writer.h:45
Interface afw_data_type public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Filled in by afw_value get_info method.
Definition: afw_value.h:49
Struct for compiled value value.
Interface afw_value public struct.
Interface afw_writer public struct.
Interface afw_xctx public struct.