Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_value_function_definition.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 Function Definition
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 /* Inf specific is always data type. */
23 #define AFW_IMPLEMENTATION_SPECIFIC (const void *)&afw_data_type_function_direct
24 
25 /* Define inf variables for data_type and fully_evaluated_data_type. */
26 #define AFW_IMPLEMENTATION_INF_VARIABLES \
27  (const void *)&afw_data_type_function_direct, \
28  NULL
29 
30 #define impl_afw_value_get_evaluated_meta \
31  afw_value_internal_get_evaluated_meta_default
32 
33 #define impl_afw_value_get_evaluated_metas \
34  afw_value_internal_get_evaluated_metas_default
35 
36 /* Declares and rti/inf defines for interface afw_value */
37 #define AFW_IMPLEMENTATION_ID "function_definition"
38 #define AFW_IMPLEMENTATION_INF_SPECIFIER AFW_DEFINE_CONST_DATA
39 #define AFW_IMPLEMENTATION_INF_LABEL afw_value_function_definition_inf
41 
42 
43 /*
44  * Implementation of method optional_evaluate for interface afw_value.
45  */
46 const afw_value_t *
48  const afw_value_t * instance,
49  const afw_pool_t * p,
50  afw_xctx_t *xctx)
51 {
52  return instance;
53 }
54 
55 /*
56  * Implementation of method get_data_type for interface afw_value.
57  */
58 const afw_data_type_t *
59 impl_afw_value_get_data_type(
60  const afw_value_t * instance,
61  afw_xctx_t *xctx)
62 {
63  return afw_data_type_object;
64 }
65 
66 /*
67  * Implementation of method get_evaluated_data_type for interface afw_value.
68  */
69 const afw_data_type_t *
70 impl_afw_value_get_evaluated_data_type(
71  const afw_value_t * instance,
72  afw_xctx_t *xctx)
73 {
75 }
76 
77 
78 /*
79  * Implementation of method get_evaluated_data_type_parameter for interface
80  * afw_value.
81  */
82 const afw_utf8_t *
83 impl_afw_value_get_evaluated_data_type_parameter(
84  const afw_value_t * instance,
85  afw_xctx_t *xctx)
86 {
87  return NULL;
88 }
89 
90 
91 /*
92  * Implementation of method compiler_listing for interface afw_value.
93  */
94 void
95 impl_afw_value_produce_compiler_listing(
96  const afw_value_t *instance,
97  const afw_writer_t *writer,
98  afw_xctx_t *xctx)
99 {
100  const afw_value_function_definition_t *self =
101  (const afw_value_function_definition_t *)instance;
102 
103  afw_value_compiler_listing_begin_value(writer, instance, NULL, xctx);
104  afw_writer_write_z(writer, " ", xctx);
105  afw_writer_write_utf8(writer, &self->functionId, xctx);
106  afw_writer_write_eol(writer, xctx);
107 }
108 
109 /*
110  * Implementation of method decompile for interface afw_value.
111  */
112 void
113 impl_afw_value_decompile(
114  const afw_value_t * instance,
115  const afw_writer_t * writer,
116  afw_xctx_t *xctx)
117 {
118  const afw_value_function_definition_t *self =
119  (const afw_value_function_definition_t *)instance;
120 
121  afw_writer_write_utf8(writer, &self->functionId, xctx);
122 }
123 
124 /*
125  * Implementation of method get_info for interface afw_value.
126  */
127 void
128 impl_afw_value_get_info(
129  const afw_value_t *instance,
130  afw_value_info_t *info,
131  const afw_pool_t *p,
132  afw_xctx_t *xctx)
133 {
134  const afw_value_function_definition_t *self =
135  (const afw_value_function_definition_t *)instance;
136 
137  afw_memory_clear(info);
138  info->value_inf_id = &instance->inf->rti.implementation_id;
139  info->detail = &self->functionId;
140 }
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
afw_data_type_function
Data type struct for function.
afw_data_type_object
Data type struct for object.
#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_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
Struct for function value.
Definition: afw_value.h:102
Filled in by afw_value get_info method.
Definition: afw_value.h:49
Interface afw_value public struct.
Interface afw_writer public struct.
Interface afw_xctx public struct.