Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_value_internal.h
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Internal Header for afw_value*
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
9 #ifndef __AFW_VALUE_INTERNAL_H__
10 #define __AFW_VALUE_INTERNAL_H__
11 
12 #include "afw_interface.h"
13 #include "afw_object_internal.h"
14 
29 
30 /* AFW_VALUE_SCRIPT_SUPPORT_NUMBER_NONE must be 0. */
31 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_NONE 0
32 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_ASSIGN 1
33 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_BREAK 2
34 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_CONST 3
35 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_CONTINUE 4
36 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_DO_WHILE 5
37 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_FOR 6
38 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_FOREACH 7
39 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_IF 8
40 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_LOC 9
41 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_RETURN 10
42 #define AFW_VALUE_SCRIPT_SUPPORT_NUMBER_WHILE 11
43 
44 
45 #define AFW_VALUE_COMPILER_LISTING_IF_NOT_LIMIT_EXCEEDED \
46  if (writer->indent > xctx->env->evaluation_stack_maximum_count) { \
47  afw_writer_write_z(writer, ">>> Limit exceeded", xctx); \
48  afw_writer_write_eol(writer, xctx); \
49  } \
50  else
51 
52 typedef enum {
53  afw_value_block_statement_type_sequential,
54  afw_value_block_statement_type_break,
55  afw_value_block_statement_type_continue,
56  afw_value_block_statement_type_return
57 } afw_value_block_statement_type_t;
58 
59 
62  const afw_value_inf_t *inf;
63  const afw_compile_value_contextual_t *contextual;
64  const afw_object_t *annotation;
65  const afw_value_t *value;
66 };
67 
68 
69 
72  const afw_value_inf_t *inf;
73  const afw_compile_value_contextual_t *contextual;
74  const afw_compile_assignment_target_t *assignment_target;
75 };
76 
77 
78 
81  const afw_utf8_t * name;
82  const afw_value_t * value;
83 };
84 
85 
86 
93  const afw_value_inf_t *inf;
94  const afw_compile_value_contextual_t *contextual;
95 
96  afw_size_t argc;
97  const afw_value_t * const * argv;
98 
99  const afw_value_t *statements;
100 
101  afw_value_block_t *parent_block;
102  afw_value_block_t *first_child_block;
103  afw_value_block_t *final_child_block;
104  afw_value_block_t *next_sibling_block;
105  afw_value_block_symbol_t *first_entry;
106  afw_value_block_symbol_t *final_entry;
107  afw_size_t number;
108  afw_size_t depth;
109  afw_size_t entry_count;
110 };
111 
112 
113 
120  const afw_pool_t *p; // Pool for this block frame
121  const afw_value_block_t *block; // Associated block value.
122  const afw_value_block_frame_t *previous; // Previous block frame
123  const afw_object_t *variables; // Runtime variables for this block
124  afw_value_block_statement_type_t type;
125  afw_boolean_t allow_return;
126  afw_boolean_t is_loop;
127 };
128 
129 
130 
133 
136 
139 
141  union {
142 
145 
148 
151 
154 
157 
160  };
161 
164 };
165 
166 
167 
170 
173 
176 };
177 
178 
179 
186  afw_value_block_t *parent_block;
187  afw_value_block_symbol_t *next_entry;
188  const afw_utf8_t *name;
189  afw_value_type_t type;
190  afw_size_t index; /* Index in block entries. */
191 };
192 
193 
194 
197 
200 
203 
210  const afw_value_t * const * argv;
211 };
212 
213 
214 
223  const afw_value_inf_t *inf;
224  const afw_value_t *function_value;
226 };
227 
228 
229 
238  const afw_value_inf_t *inf;
239  const afw_value_function_definition_t *function;
241 };
242 
243 
244 
261  const afw_value_inf_t *inf;
262 
264  const afw_pool_t *p;
265 
268 
271 
274 
277 
280 
283 
286 
293 
300 
301  /* @brief Top symbol block. */
302  afw_value_block_t *top_block;
303 
304  /* @brief Current symbol block. */
305  afw_value_block_t *current_block;
306 
316 
323 };
324 
325 
326 
329  const afw_value_inf_t *inf;
330  const afw_value_t *internal;
331  const afw_compile_value_contextual_t *contextual;
332 };
333 
334 
335 
338  const afw_value_inf_t *inf;
339 
341  const afw_utf8_t *name;
342 
345 
348 
351 
353  void *ctx;
354 };
355 
356 
357 
360  const afw_value_inf_t *inf;
361  const afw_object_t *internal;
362  const afw_compile_value_contextual_t *contextual;
363 };
364 
365 
366 
369  const afw_value_inf_t *inf;
370  const afw_compile_value_contextual_t *contextual;
371  const afw_value_t *aggregate_value; /* Object or list */
372  const afw_value_t *key;
373  const afw_utf8_t *backtrace_detail;
374 };
375 
376 
379  const afw_value_inf_t *inf;
380  const afw_compile_value_contextual_t *contextual;
381  /* NULL terminated list of assignments or NULL. */
382  const afw_value_assignment_t * const *assignments;
383  const afw_value_t * value;
384 };
385 
386 
389  const afw_compile_value_contextual_t *contextual;
390  const afw_value_type_t *returns;
391  afw_size_t count;
392  const afw_value_script_function_parameter_t **parameters;
393 };
394 
395 
396 
399  const afw_utf8_t *name;
400  const afw_value_type_t *type;
401  const afw_value_t *default_value;
402  afw_boolean_t is_optional;
403  afw_boolean_t is_rest;
404 };
405 
406 
407 
410  const afw_value_inf_t *inf;
411  const afw_compile_value_contextual_t *contextual;
412  const afw_value_script_function_signature_t *signature;
413  const afw_value_type_t *returns;
414  afw_size_t count;
415  const afw_value_script_function_parameter_t **parameters;
416  const afw_value_t *body;
417 };
418 
419 
420 
423  const afw_value_inf_t *inf;
424  const afw_compile_value_contextual_t *contextual;
425  afw_utf8_t qualifier;
426  afw_utf8_t name;
427  const afw_utf8_t *optionally_qualified_name;
428  const afw_utf8_t *backtrace_detail;
429 };
430 
431 
432 
435  const afw_value_inf_t *inf;
436  const afw_compile_value_contextual_t *contextual;
437  afw_size_t count;
438  const afw_value_t * const * values;
439 };
440 
441 
442 
443 /* @brief struct for afw_value_variable_reference_t */
445  const afw_value_inf_t *inf;
446  const afw_compile_value_contextual_t *contextual;
447  const afw_value_block_symbol_t *symbol;
448 };
449 
450 
451 
453  afw_object_t pub;
454  afw_object_setter_t setter;
455  afw_value_object_t meta_object_value;
456  const afw_value_t *value;
457  const afw_value_t *evaluated_value;
458  const afw_utf8_t *key;
459  const afw_object_t *additional;
460  afw_boolean_t immutable;
462 
463 
464 
466  afw_list_t pub;
467  const afw_pool_t *p;
468  const afw_value_object_t *value;
470 
471 
472 
474  afw_list_t pub;
475  const afw_pool_t *p;
476  const afw_value_list_t *value;
478 
479 
480 
481 typedef const afw_value_t *(*afw_value_meta_special_get_t) (
483  const afw_utf8_t *property_name,
484  afw_xctx_t *xctx);
485 
486 typedef void (*afw_value_meta_special_set_t) (
488  const afw_utf8_t *property_name,
489  const afw_value_t *value,
490  afw_xctx_t *xctx);
491 
492 typedef struct {
493  const afw_utf8_t *property_name;
494  afw_value_meta_special_get_t get;
495  afw_value_meta_special_set_t set;
497 
499 afw_value_call_built_in_function(
500  const afw_compile_value_contextual_t *contextual,
501  const afw_value_function_definition_t *function,
502  afw_size_t argc,
503  const afw_value_t * const *argv,
504  const afw_pool_t *p,
505  afw_xctx_t *xctx);
506 
508 afw_value_internal_create_meta_object_self(
509  const afw_value_t *value,
510  const afw_pool_t *p,
511  afw_xctx_t *xctx);
512 
514 afw_value_internal_get_evaluated_meta_default(
515  const afw_value_t *value,
516  const afw_pool_t *p,
517  afw_xctx_t *xctx);
518 
520 afw_value_internal_get_evaluated_metas_default(
521  const afw_value_t *value,
522  const afw_pool_t *p,
523  afw_xctx_t *xctx);
524 
526 afw_value_internal_get_evaluated_meta_for_list(
527  const afw_value_t *value,
528  const afw_pool_t *p,
529  afw_xctx_t *xctx);
530 
532 afw_value_internal_get_evaluated_metas_for_list(
533  const afw_value_t *value,
534  const afw_pool_t *p,
535  afw_xctx_t *xctx);
536 
538 afw_value_internal_get_evaluated_meta_for_object(
539  const afw_value_t *value,
540  const afw_pool_t *p,
541  afw_xctx_t *xctx);
542 
544 afw_value_internal_get_evaluated_metas_for_object(
545  const afw_value_t *value,
546  const afw_pool_t *p,
547  afw_xctx_t *xctx);
548 
550 afw_value_meta_values_list_for_object_create(
551  const afw_value_t *value,
552  const afw_pool_t *p,
553  afw_xctx_t *xctx);
554 
555 
557 afw_value_meta_values_list_for_list_create(
558  const afw_value_t *value,
559  const afw_pool_t *p,
560  afw_xctx_t *xctx);
561 
564  const afw_value_t *value,
566  const afw_utf8_t *tab,
567  const afw_pool_t *p,
568  afw_xctx_t *xctx);
569 
570 
571 
573  afw_writer_t writer;
574  const afw_value_compiler_listing_t *parent;
575  afw_value_compiler_listing_t *first_child;
576  afw_value_compiler_listing_t *final_child;
577  afw_value_compiler_listing_t *next_sibling;
578  const afw_pool_t *p;
579  const afw_value_compiled_value_t *compiled_value;
580  const afw_utf8_t *reference_id;
581  apr_array_header_t *ary;
582  apr_array_header_t *child_compiler_listings;
583  const afw_utf8_t *last_full_source;
584  afw_size_t prefix_size;
585  afw_size_t max_value_cursor;
586  afw_size_t cursor_written;
587  afw_size_t last_line_written;
588  const char *prefix_format;
589  afw_utf8_t empty_prefix;
590  const afw_utf8_t *current_prefix;
591  afw_value_info_t first_info;
592  afw_boolean_t offset_only;
593  afw_boolean_t is_new_line;
594  afw_boolean_t include_source;
595  afw_boolean_t empty_line_between_switch;
596  afw_boolean_t source_eof;
597  int tab_size;
598 };
599 
600 
602 afw_value_compiler_listing_for_child(
603  const afw_value_t *instance,
604  const afw_writer_t *writer,
605  afw_xctx_t *xctx);
606 
608 afw_value_compiler_listing_begin_value(
609  const afw_writer_t *writer,
610  const afw_value_t *value,
611  const afw_compile_value_contextual_t *contextual,
612  afw_xctx_t *xctx);
613 
615 afw_value_compiler_listing_end_value(
616  const afw_writer_t *writer,
617  const afw_value_t *value,
618  afw_xctx_t *xctx);
619 
621 afw_value_compiler_listing_call_args(
622  const afw_writer_t *writer,
623  const afw_value_call_args_t *args,
624  afw_xctx_t *xctx);
625 
627 afw_value_compiler_listing_value(
628  const afw_value_t *instance,
629  const afw_writer_t *writer,
630  afw_xctx_t *xctx);
631 
635  afw_value_block_statement_type_t *type,
636  afw_boolean_t allow_return,
637  afw_boolean_t is_loop,
638  const afw_value_t *block,
639  const afw_pool_t *p,
640  afw_xctx_t *xctx);
641 
643 afw_value_block_evaluate_block(
645  afw_value_block_statement_type_t *type,
646  const afw_value_block_t *self,
647  afw_boolean_t is_loop,
648  const afw_pool_t *p,
649  afw_xctx_t *xctx);
650 
652 afw_value_block_evaluate_for(
654  afw_value_block_statement_type_t *type,
655  afw_size_t argc,
656  const afw_value_t * const * argv,
657  const afw_pool_t *p,
658  afw_xctx_t *xctx);
659 
661 afw_value_block_evaluate_foreach(
663  afw_value_block_statement_type_t *type,
664  afw_size_t argc,
665  const afw_value_t *const *argv,
666  const afw_pool_t *p,
667  afw_xctx_t *xctx);
668 
670 afw_value_block_evaluate_do_while(
672  afw_value_block_statement_type_t *type,
673  afw_size_t argc,
674  const afw_value_t *const *argv,
675  const afw_pool_t *p,
676  afw_xctx_t *xctx);
677 
679 afw_value_block_evaluate_if(
681  afw_value_block_statement_type_t *type,
682  afw_size_t argc,
683  const afw_value_t * const * argv,
684  afw_boolean_t is_loop,
685  const afw_pool_t *p,
686  afw_xctx_t *xctx);
687 
689 afw_value_block_evaluate_while(
691  afw_value_block_statement_type_t *type,
692  afw_size_t argc,
693  const afw_value_t * const * argv,
694  const afw_pool_t *p,
695  afw_xctx_t *xctx);
696 
697 
698 
699 AFW_END_DECLARES
700 
703 #endif /* __AFW_VALUE_INTERNAL_H__ */
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
#define AFW_BEGIN_DECLARES
#define AFW_DECLARE_INTERNAL(type)
Declare an internal function for /src/afw/ source*.h files.
Interfaceafw_interface header.
Internal header file for Adaptive Framework memory.
_Bool afw_boolean_t
Definition: afw_common.h:373
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
const afw_value_t *(* afw_function_thunk_execute_t)(const afw_value_function_thunk_t *function, afw_size_t argc, const afw_value_t *const *argv, const afw_pool_t *p, afw_xctx_t *xctx)
Typedef for function thunk execute functions.
Definition: afw_common.h:1266
afw_value_block_evaluate_statement(afw_function_execute_t *x, afw_value_block_statement_type_t *type, afw_boolean_t allow_return, afw_boolean_t is_loop, const afw_value_t *block, const afw_pool_t *p, afw_xctx_t *xctx)
afw_value_compiler_listing_to_string_instance(const afw_value_t *value, afw_value_compiler_listing_t *parent, const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
Contextual information provided in some values.
Interface afw_data_type public struct.
Function execute parameter.
Definition: afw_function.h:53
Interface afw_list public struct.
Interface afw_object public struct.
Interface afw_object_setter public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Struct for annotated value.
Struct for value assignment.
Struct for assignment target value.
struct for afw_value_block_frame_t
struct for afw_value_block_t
struct for afw_value_block_symbol_t
Struct for contextual and args for call values.
const afw_value_t *const * argv
const afw_compile_value_contextual_t * contextual
Struct for call value.
Struct for expression value.
Struct for function value.
Definition: afw_value.h:102
Struct for function thunk value.
void * ctx
ctx passed on create.
const afw_value_t * like_function_value
The thunk signature is like this function.
const afw_utf8_t * name
name.
afw_function_thunk_execute_t execute
Function called to execute this thunk.
const afw_utf8_t * detail
includes name and source location.
Interface afw_value_inf_s struct.
Filled in by afw_value get_info method.
Definition: afw_value.h:49
Struct for compiled value value.
afw_size_t line_count
The total number of lines in source.
const afw_object_t * strings
Shared strings.
const afw_value_compiled_value_t * parent
The parent compiled value or NULL.
const afw_utf8_t * full_source_type
The type of the full source.
const afw_pool_t * p
Pool containing value.
const afw_utf8_t * full_source
The full source that was compiled.
const afw_utf8_t * source_location
Source location provided to compiler.
const afw_compile_value_contextual_t * contextual
Contextual Info.
const afw_object_t * literals
Literal values.
afw_size_t longest_line
The longest line excluding .
const afw_value_t * root_value
The root value.
const afw_utf8_t * reference_id
A uuid for this compiled value.
struct for list expression value.
struct for data type list values.
struct for object expression value.
struct for data type object values.
Struct for qualified variable reference value.
Struct for reference_by_key value.
Interface afw_value public struct.
Struct for script function parameter.
Struct for template value.
afw_size_t dimension
Number of subscripts needed to access cell.
const afw_value_type_t * cell_type
Cell type. If NULL, cell is untyped.
Type meta (data type, data type parameters, and value meta object.
const afw_value_type_list_t * list_type
list type (If NULL, 1 dimension with untyped cells).
const afw_utf8_t * media_type
string, base64Binary, hexBinary.
const afw_utf8_t * object_type_id
object and objectId.
const afw_object_t * value_meta_object
AdaptiveValueMeta object or NULL.
const afw_value_type_t * type
unevaluated.
const afw_data_type_t * data_type
data type or NULL.
const afw_value_type_t * return_type
expression, hybrid, script and template.
const afw_compile_value_contextual_t * data_type_parameter_contextual
contextual for data type parameter or NULL.
const afw_value_script_function_signature_t * function_signature
function.
Interface afw_writer public struct.
Interface afw_xctx public struct.