Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_value_list_expression.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 List Expression
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 #define impl_afw_value_optional_release NULL
18 #define impl_afw_value_get_reference NULL
19 
20 
21 
22 #define impl_afw_value_get_evaluated_meta \
23  afw_value_internal_get_evaluated_meta_for_list
24 
25 #define impl_afw_value_get_evaluated_metas \
26  afw_value_internal_get_evaluated_metas_for_list
27 
28 /* Declares and rti/inf defines for interface afw_value */
29 #define AFW_IMPLEMENTATION_ID "list_expression"
30 #define AFW_IMPLEMENTATION_INF_SPECIFIER AFW_DEFINE_CONST_DATA
31 #define AFW_IMPLEMENTATION_INF_LABEL afw_value_list_expression_inf
33 
36 /* Create function for list expression value. */
37 AFW_DEFINE(const afw_value_t *)
39  const afw_compile_value_contextual_t *contextual,
40  const afw_value_t * internal,
41  const afw_pool_t *p, afw_xctx_t *xctx)
42 {
44 
45  self = afw_pool_calloc(p, sizeof(afw_value_list_expression_t), xctx);
46  self->inf = &afw_value_list_expression_inf;
47  self->contextual = contextual;
48  self->internal = internal;
49  return (const afw_value_t *)self;
50 }
51 
52 /*
53  * Implementation of method optional_evaluate for interface afw_value.
54  */
55 const afw_value_t *
57  const afw_value_t * instance,
58  const afw_pool_t * p,
59  afw_xctx_t *xctx)
60 {
61  const afw_value_list_expression_t *self =
62  (const afw_value_list_expression_t *)instance;
63  const afw_value_t *result;
64 
65  result = afw_value_evaluate(self->internal, p, xctx);
66 
67  return result;
68 }
69 
70 /*
71  * Implementation of method get_data_type for interface afw_value.
72  */
73 const afw_data_type_t *
74 impl_afw_value_get_data_type(
75  const afw_value_t *instance,
76  afw_xctx_t *xctx)
77 {
78  return afw_data_type_list;
79 }
80 
81 /*
82  * Implementation of method get_evaluated_data_type for interface afw_value.
83  */
84 const afw_data_type_t *
85 impl_afw_value_get_evaluated_data_type(
86  const afw_value_t *instance,
87  afw_xctx_t *xctx)
88 {
89  return afw_data_type_list;
90 }
91 
92 /*
93  * Implementation of method get_evaluated_data_type_parameter for interface
94  * afw_value.
95  */
96 const afw_utf8_t *
97 impl_afw_value_get_evaluated_data_type_parameter(
98  const afw_value_t *instance,
99  afw_xctx_t *xctx)
100 {
101  return NULL;
102 }
103 
104 /*
105  * Implementation of method compiler_listing for interface afw_value.
106  */
107 void
108 impl_afw_value_produce_compiler_listing(
109  const afw_value_t *instance,
110  const afw_writer_t *writer,
111  afw_xctx_t *xctx)
112 {
113  const afw_value_list_expression_t *self =
114  (const afw_value_list_expression_t *)instance;
115 
116  afw_value_compiler_listing_begin_value(writer, instance,
117  self->contextual, xctx);
118  afw_writer_write_z(writer, ": [", xctx);
119  afw_writer_write_eol(writer, xctx);
120  afw_writer_increment_indent(writer, xctx);
121 
122  afw_value_compiler_listing_value(self->internal, writer, xctx);
123 
124  afw_writer_decrement_indent(writer, xctx);
125  afw_writer_write_z(writer, "]", xctx);
126  afw_writer_write_eol(writer, xctx);
127 }
128 
129 /*
130  * Implementation of method decompile for interface afw_value.
131  */
132 void
133 impl_afw_value_decompile(
134  const afw_value_t *instance,
135  const afw_writer_t *writer,
136  afw_xctx_t *xctx)
137 {
138  const afw_value_list_expression_t *self =
139  (const afw_value_list_expression_t *)instance;
140 
141  afw_writer_write_z(writer, "list_expression(", xctx);
142  afw_value_decompile_value(self->internal, writer, xctx);
143  afw_writer_write_z(writer, ")", xctx);
144 }
145 
146 /*
147  * Implementation of method get_info for interface afw_value.
148  */
149 void
150 impl_afw_value_get_info(
151  const afw_value_t *instance,
152  afw_value_info_t *info,
153  const afw_pool_t *p,
154  afw_xctx_t *xctx)
155 {
156  const afw_value_list_expression_t *self =
157  (const afw_value_list_expression_t *)instance;
158 
159  afw_memory_clear(info);
160  info->value_inf_id = &instance->inf->rti.implementation_id;
161  info->contextual = self->contextual;
162 }
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
afw_data_type_list
Data type struct for list.
#define afw_memory_clear(to)
Clear preallocated memory for sizeof(*(to)).
Definition: afw_memory.h:47
#define afw_pool_calloc(instance, size, xctx)
Call method calloc of interface afw_pool.
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_evaluate(value, p, xctx)
Evaluate value if needed using specific pool.
Definition: afw_value.h:841
afw_value_create_list_expression(const afw_compile_value_contextual_t *contextual, const afw_value_t *internal, const afw_pool_t *p, afw_xctx_t *xctx)
Create function for list expression value.
afw_value_decompile_value(const afw_value_t *instance, const afw_writer_t *writer, afw_xctx_t *xctx)
Decompile Value::.
afw_value_list_expression_inf
Value list expression inf.
Definition: afw_value.h:279
#define afw_writer_increment_indent(instance, xctx)
Call method increment_indent of interface afw_writer.
#define afw_writer_write_eol(instance, xctx)
Call method write_eol of interface afw_writer.
#define afw_writer_decrement_indent(instance, xctx)
Call method decrement_indent 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
Contextual information provided in some values.
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 list expression value.
Interface afw_value public struct.
Interface afw_writer public struct.
Interface afw_xctx public struct.