Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_value_compiler_listing.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Value Compiler Listing
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 
18 #define AFW_IMPLEMENTATION_ID "afw_value_compiler_listing_writer"
20 
21 static const afw_utf8_octet_t
22 impl_empty_prefix[] =
23 " + ";
24 
25 static const afw_utf8_t
26 impl_default_tab = AFW_UTF8_LITERAL(" ");
27 
28 static afw_size_t
29 impl_digits_needed(afw_size_t i)
30 {
31  afw_size_t result;
32 
33  for (result = 1; i > 9; i /= 10) {
34  result++;
35  }
36 
37  return result;
38 }
39 
40 
41 
42 /*
43  * Implementation of method write_eol for interface afw_writer.
44  */
45 static afw_size_t
46 impl_afw_writer_write_raw_cb(
47  void *context,
48  const void *buffer,
49  afw_size_t size,
50  const afw_pool_t *p,
51  afw_xctx_t *xctx)
52 {
55  afw_size_t i;
56 
57  for (i = 0; i < size; i++) {
58  APR_ARRAY_PUSH(self->ary, char) =
59  ((const afw_octet_t *)buffer)[i];
60  }
61  return size;
62 }
63 
64 
65 
66 /*
67  * Implementation of method release for interface afw_writer.
68  */
69 void
70 impl_afw_writer_release(
71  const afw_writer_t *instance,
72  afw_xctx_t *xctx)
73 {
74  /* Don't do anything. */
75 }
76 
77 
78 
79 /*
80  * Implementation of method flush for interface afw_writer.
81  */
82 void
83 impl_afw_writer_flush(
84  const afw_writer_t *instance,
85  afw_xctx_t *xctx)
86 {
87  /* Ignore flush. */
88 }
89 
90 
91 
92 static afw_boolean_t
93 impl_write_source_line(
95  afw_boolean_t line_written,
96  afw_xctx_t *xctx)
97 {
98  const afw_utf8_t *src;
99  const afw_utf8_octet_t *s;
100  const afw_utf8_octet_t *end;
101  char buffer[sizeof(impl_empty_prefix)];
102  int len, i;
103 
104  src = self->compiled_value->full_source;
105 
106  if (self->source_eof || src->len < self->cursor_written) {
107  return false;
108  }
109  self->last_line_written++;
110 
111  if (!line_written && self->empty_line_between_switch) {
112  APR_ARRAY_PUSH(self->ary, char) = '\n';
113  }
114 
115  /* Write prefix */
116  len = snprintf(buffer, sizeof(buffer),
117  "%" AFW_SIZE_T_FMT,
118  self->last_line_written);
119  len = (int)self->prefix_size - len - 3;
120  len = snprintf(buffer, sizeof(buffer),
121  "%.*s%" AFW_SIZE_T_FMT " | ",
122  len,
123  &impl_empty_prefix[0],
124  self->last_line_written);
125  for (i = 0; i < len; i++) {
126  APR_ARRAY_PUSH(self->ary, char) = buffer[i];
127  }
128 
129  /* Write a line. */
130  for (
131  s = src->s + self->cursor_written,
132  end = src->s + src->len;
133  ;
134  s++)
135  {
136  /* If not at end, push char. If it's a new line, break. */
137  if (s < end) {
138  APR_ARRAY_PUSH(self->ary, char) = *s;
139  if (*s == '\n') {
140  s++;
141  if (s == end) {
142  self->source_eof = true;
143  }
144  break;
145  }
146  }
147 
148  /* If no trailing new line, add one and break. */
149  else {
150  APR_ARRAY_PUSH(self->ary, char) = '\n';
151  self->source_eof = true;
152  break;
153  }
154 
155  }
156 
157  /* Set cursor written. */
158  self->cursor_written = s - src->s;
159  return !self->source_eof;
160 }
161 
162 
163 /*
164  * Implementation of method write for interface afw_writer.
165  */
166 void
168  const afw_writer_t *instance,
169  const void *buffer,
170  afw_size_t size,
171  afw_xctx_t *xctx)
172 {
174  (afw_value_compiler_listing_t *)instance;
175  afw_size_t count, i;
176  const afw_octet_t *c;
177  afw_boolean_t line_written;
178 
179  if (size == 0) {
180  return;
181  }
182 
183  /*
184  * In this is a new line and the line does not starts with '#' or '---' or
185  * is an empty line, deal with prefix and tabs.
186  */
187  if (self->is_new_line &&
188  !(
189  (size >= 1 && *(char *)buffer == '#') ||
190  (size >= 1 && *(char *)buffer == '\n') ||
191  (size >= 3 && (memcmp(buffer, "---", 3) == 0))
192  ))
193  {
194  if (self->include_source) {
195  for (line_written = false;
196  self->max_value_cursor >= self->cursor_written;
197  )
198  {
199  if (!impl_write_source_line(self, line_written, xctx)) {
200  break;
201  }
202  line_written = true;
203  }
204  if (self->empty_line_between_switch && line_written) {
205  APR_ARRAY_PUSH(self->ary, char) = '\n';
206  }
207  }
208  if (!self->current_prefix) {
209  self->current_prefix = &self->empty_prefix;
210  }
211  for (i = 0; i < self->current_prefix->len; i++) {
212  APR_ARRAY_PUSH(self->ary, char) = self->current_prefix->s[i];
213  }
214  self->current_prefix = NULL;
215  for (count = 0; count < self->writer.indent; count++) {
216  for (i = 0; i < self->writer.tab->len; i++) {
217  APR_ARRAY_PUSH(self->ary, char) = self->writer.tab->s[i];
218  }
219  }
220  }
221 
222  /*
223  * In the case that current prefix is supplied but no newline, just set to
224  * NULL.
225  */
226  self->current_prefix = NULL;
227 
228  /* Always reset is_new_line and push buffer on to stack. */
229  self->is_new_line = false;
230  c = (const afw_octet_t *)buffer;
231  for (count = 0; count < size; count++) {
232  APR_ARRAY_PUSH(self->ary, char) = *c++;
233  }
234 }
235 
236 
237 /*
238  * Implementation of method write_eol for interface afw_writer.
239  */
240 void
242  const afw_writer_t *instance,
243  afw_xctx_t *xctx)
244 {
246  (afw_value_compiler_listing_t *)instance;
247 
248  if (self->writer.tab) {
249  APR_ARRAY_PUSH(self->ary, char) = '\n';
250  self->is_new_line = true;
251  }
252 }
253 
254 /*
255  * Implementation of method increment_indent for interface afw_writer.
256  */
257 void
258 impl_afw_writer_increment_indent(
259  const afw_writer_t *instance,
260  afw_xctx_t *xctx)
261 {
263  (afw_value_compiler_listing_t *)instance;
264 
265  self->writer.indent++;
266 }
267 
268 /*
269  * Implementation of method decrement_indent for interface afw_writer.
270  */
271 void
272 impl_afw_writer_decrement_indent(
273  const afw_writer_t *instance,
274  afw_xctx_t *xctx)
275 {
277  (afw_value_compiler_listing_t *)instance;
278 
279  if (self->writer.indent == 0) {
280  AFW_THROW_ERROR_Z(general,
281  "decrement indent when indent already 0",
282  xctx);
283  }
284 
285  self->writer.indent--;
286 }
287 
288 
289 
291 afw_value_compiler_listing_for_child(
292  const afw_value_t *instance,
293  const afw_writer_t *writer,
294  afw_xctx_t *xctx)
295 {
298 
299  if (writer->inf != &impl_afw_writer_inf) {
300  AFW_THROW_ERROR_Z(general,
301  "afw_value_compiler_listing_for_child() can only be called by"
302  "afw_value_compiler_listing implementation of writer",
303  xctx);
304  }
305  parent = (afw_value_compiler_listing_t *)writer;
306 
308  instance, parent, parent->writer.tab, parent->p, xctx);
309 
310  return self->reference_id;
311 }
312 
313 
314 
315 static void
316 impl_symbol_listing(
317  const afw_writer_t *writer,
318  afw_value_block_t *block,
319  afw_xctx_t *xctx)
320 {
322  afw_value_block_t *child;
323 
324  if (!block) {
325  afw_writer_write_z(writer, "\nblock=NULL", xctx);
326  return;
327  }
328 
329  afw_writer_write_z(writer, "\nblock=", xctx);
330  afw_writer_write_size(writer, block->number, xctx);
331  afw_writer_write_z(writer, " depth=", xctx);
332  afw_writer_write_size(writer, block->depth, xctx);
333  afw_writer_write_z(writer, " entries=", xctx);
334  afw_writer_write_size(writer, block->entry_count, xctx);
335  afw_writer_write_z(writer, " : [", xctx);
336  afw_writer_write_eol(writer, xctx);
337 
338  for (e = block->first_entry; e; e = e->next_entry) {
339  afw_writer_write_z(writer, " [", xctx);
340  afw_writer_write_size(writer, e->index, xctx);
341  afw_writer_write_z(writer, "] name=", xctx);
342  afw_writer_write_utf8(writer, e->name, xctx);
343  afw_writer_write_z(writer, " declared=", xctx);
344  afw_writer_write_z(writer, "*fixme*", xctx);
345  afw_writer_write_z(writer, " dataType=", xctx);
346  if (e->type.data_type) {
347  afw_writer_write_utf8(writer, &e->type.data_type->data_type_id,
348  xctx);
349  }
350  else {
351  afw_writer_write_z(writer, "any", xctx);
352  }
353  if (e->type.data_type_parameter_contextual) {
354  afw_writer_write_z(writer, " dataTypeParameter=", xctx);
355  afw_writer_write(writer,
359  xctx);
360  }
361  if (e->type.value_meta_object) {
362  afw_writer_write_z(writer, " valueMeta= present", xctx);
363  }
364 
365  afw_writer_write_eol(writer, xctx);
366  }
367  afw_writer_write_z(writer, "]", xctx);
368  afw_writer_write_eol(writer, xctx);
369 
370  for (child = block->first_child_block;
371  child;
372  child = child->next_sibling_block)
373  {
374  impl_symbol_listing(writer, child, xctx);
375  }
376 }
377 
378 
379 
380 /* Decompile a value to a compiler listing string. */
383  const afw_value_t *value,
385  const afw_utf8_t *tab,
386  const afw_pool_t *p,
387  afw_xctx_t *xctx)
388 {
390  const afw_writer_t *writer;
391  afw_value_info_t info;
392 
393  /* Create self and ary. */
394  self = afw_pool_calloc_type(p,
396  xctx);
397  writer = &self->writer;
398  self->writer.inf = &impl_afw_writer_inf;
399  self->writer.p = p;
400  self->p = p;
401  self->writer.write_raw_cb = impl_afw_writer_write_raw_cb;
402  self->ary = apr_array_make(afw_pool_get_apr_pool(p), 4000, 1);
403  self->writer.tab = tab;
404  if (tab->len == 1 && *(tab->s) == '\t') {
405  self->writer.tab = &impl_default_tab;
406  }
407  self->tab_size = (int)tab->len;
408 
409  /* Chain in self to parent and siblings. */
410  if (parent) {
411  self->parent = parent;
412  if (parent->final_child) {
413  parent->final_child->next_sibling = self;
414  parent->final_child = self;
415  }
416  else {
417  parent->first_child = self;
418  parent->final_child = self;
419  }
420  }
421 
422  /* Write header section. */
423  afw_writer_write_z(writer, "\n", xctx);
424  afw_writer_write_z(writer, "\n", xctx);
425  afw_writer_write_z(writer, "#", xctx);
426  afw_writer_write_eol(writer, xctx);
427 
428  /* If value is not a compiled value, just produce decompile. */
430  afw_writer_write_z(writer,
431  "# Adaptive Value is fully evaluated at compile time", xctx);
432  afw_writer_write_eol(writer, xctx);
433  afw_writer_write_z(writer, "#", xctx);
434  afw_writer_write_eol(writer, xctx);
435  if (afw_value_is_undefined(value)) {
436  afw_writer_write_utf8(writer, &afw_s_undefined, xctx);
437  }
438  else {
439  afw_value_decompile(value, writer, xctx);
440  }
441  afw_writer_write_eol(writer, xctx);
442  return self;
443  }
444 
445  /* Set self->compiled_value */
446  AFW_VALUE_ASSERT_IS(value, compiled_value, xctx);
447  self->compiled_value = (const afw_value_compiled_value_t *)value;
448  self->reference_id = self->compiled_value->reference_id;
449 
451  self->include_source = true;
452  self->empty_line_between_switch = true;
453 
454  afw_writer_write_z(writer, "# Compiled Adaptive Value Listing", xctx);
455  afw_writer_write_eol(writer, xctx);
456  afw_writer_write_z(writer, "#", xctx);
457  afw_writer_write_eol(writer, xctx);
458  if (self->compiled_value->source_location) {
459  afw_writer_write_z(writer, "# Source location: ", xctx);
460  afw_writer_write_utf8(writer,
461  self->compiled_value->source_location, xctx);
462  afw_writer_write_eol(writer, xctx);
463  afw_writer_write_z(writer, "#", xctx);
464  afw_writer_write_eol(writer, xctx);
465  }
466 
467  /* Set up prefix for --CompiledValue. */
468  self->is_new_line = true;
469  if (self->compiled_value->line_count == 0) {
470  self->offset_only = true;
471  self->prefix_format = "%" AFW_SIZE_T_FMT "-%" AFW_SIZE_T_FMT;
472  self->prefix_size =
473  impl_digits_needed(self->compiled_value->full_source->len) * 2 +
474  4 /* '-' + space + '> '*/;
475  }
476  else {
477  self->prefix_format = "%" AFW_SIZE_T_FMT ":%" AFW_SIZE_T_FMT
478  "-%" AFW_SIZE_T_FMT ":%" AFW_SIZE_T_FMT;
479  self->prefix_size =
480  impl_digits_needed(self->compiled_value->line_count) * 2 +
481  impl_digits_needed(self->compiled_value->longest_line) * 2 +
482  6 /* 2*':' + '-' + space + '> '*/;
483  }
484 
485  /* Make prefix size a multiple of tab size. */
486  if (self->tab_size != 0) {
487  self->prefix_size =
488  (self->prefix_size + self->tab_size - 1) /
489  self->tab_size * self->tab_size;
490  }
491 
492  /* Make sure this does not exceed limitation. */
493  if (self->prefix_size > sizeof(impl_empty_prefix)) {
494  AFW_THROW_ERROR_Z(general, "Limitation", xctx);
495  }
496 
497  /* Make empty prefix. */
498  self->empty_prefix.s = &impl_empty_prefix[
499  sizeof(impl_empty_prefix) - self->prefix_size - 1];
500  self->empty_prefix.len = self->prefix_size;
501 
502  /* Write --CompiledValue */
503  afw_value_get_info(value, &info, writer->p, xctx);
504  afw_writer_write_z(writer, "---CompiledValue ", xctx);
505  afw_writer_write_utf8(writer, self->reference_id, xctx);
506  afw_writer_write_eol(writer, xctx);
507  afw_value_compiler_listing_begin_value(writer, value, NULL, xctx);
508  afw_writer_write_z(writer, ": [", xctx);
509  afw_writer_write_eol(writer, xctx);
510 
511  /* Adaptive Value Decompile. */
512  afw_writer_increment_indent(writer, xctx);
513  afw_value_produce_compiler_listing(self->compiled_value->root_value,
514  writer, xctx);
515  afw_writer_decrement_indent(writer, xctx);
516  afw_writer_write_z(writer, "]", xctx);
517  afw_writer_write_eol(writer, xctx);
518 
519  /* Write residual source. */
520  if (self->include_source && !self->source_eof) {
521  afw_writer_write_eol(writer, xctx);
522  while (impl_write_source_line(self, true, xctx));
523  }
524 
525  /* Reset to empty prefix and no indent. */
526  self->current_prefix = NULL;
527  self->empty_prefix.len = 0;
528  self->empty_prefix.s = NULL;
529 
530  /* Symbol table. */
531  afw_writer_write_z(writer, "\n", xctx);
532  afw_writer_write_z(writer, "\n", xctx);
533  afw_writer_write_z(writer, "---Symbols ", xctx);
534  afw_writer_write_utf8(writer, self->reference_id, xctx);
535  afw_writer_write_eol(writer, xctx);
536  impl_symbol_listing(writer, self->compiled_value->top_block, xctx);
537  afw_writer_write_eol(writer, xctx);
538 
539  /* Literals. */
540  afw_writer_write_z(writer, "\n", xctx);
541  afw_writer_write_z(writer, "\n", xctx);
542  afw_writer_write_z(writer, "---Literals ", xctx);
543  afw_writer_write_utf8(writer, self->reference_id, xctx);
544  afw_writer_write_eol(writer, xctx);
545  afw_writer_write_z(writer, "Literals coming soon", xctx);
546  afw_writer_write_eol(writer, xctx);
547 
548  /* Write --- for end. */
549  afw_writer_write_z(writer, "\n", xctx);
550  afw_writer_write_z(writer, "\n", xctx);
551  afw_writer_write_z(writer, "---", xctx);
552  afw_writer_write_eol(writer, xctx);
553 
554  /* Release writer and return. */
555  afw_writer_release(&self->writer, xctx);
556  return self;
557 }
558 
559 
560 
561 static afw_size_t
562 impl_total_buffer_needed(const afw_value_compiler_listing_t *self)
563 {
564  afw_size_t result;
565  const afw_value_compiler_listing_t *child;
566 
567  result = self->ary->nelts;
568  for (child = self->first_child; child; child = child->next_sibling) {
569  result += impl_total_buffer_needed(child);
570  }
571 
572  return result;
573 }
574 
575 
576 
577 static void
578 impl_move_to_buffer(const afw_value_compiler_listing_t *self,
579  char **buffer)
580 {
581  const afw_value_compiler_listing_t *child;
582 
583  memcpy(*buffer, self->ary->elts, self->ary->nelts);
584  *buffer = *buffer + self->ary->nelts;
585  for (child = self->first_child; child; child = child->next_sibling) {
586  impl_move_to_buffer(child, buffer);
587  }
588 }
589 
590 
591 
592 /* Decompile a value to a compiler listing string. */
593 AFW_DEFINE(const afw_utf8_t *)
595  const afw_value_t *value,
596  const afw_utf8_t *tab,
597  const afw_pool_t *p,
598  afw_xctx_t *xctx)
599 {
601  char *buffer;
602  afw_utf8_t *result;
603  const afw_pool_t *temp_pool;
604  afw_size_t len;
605 
606  /* Create self and ary in its own pool. */
607  temp_pool = afw_pool_create(p, xctx);
608 
610  value, NULL, tab, temp_pool, xctx);
611 
612  len = impl_total_buffer_needed(self);
613  buffer = afw_pool_malloc(p, len, xctx);
614  result = afw_pool_malloc_type(p, afw_utf8_t, xctx);
615  result->len = len;
616  result->s = buffer;
617  impl_move_to_buffer(self, &buffer);
618 
619  afw_writer_release(&self->writer, xctx);
620  afw_pool_release(temp_pool, xctx);
621 
622  return result;
623 }
624 
625 
626 /* Decompile a value to a compiler listing string. */
628 afw_value_compiler_listing_begin_value(
629  const afw_writer_t *writer,
630  const afw_value_t *value,
631  const afw_compile_value_contextual_t *contextual,
632  afw_xctx_t *xctx)
633 {
636  afw_size_t line_number;
637  afw_size_t column_number;
638  afw_size_t end_line_number;
639  afw_size_t end_column_number;
640  afw_utf8_t prefix;
641  afw_size_t len;
642  char buffer[sizeof(impl_empty_prefix)];
643 
644  if (contextual) {
645  if (contextual->value_offset > self->max_value_cursor) {
646  self->max_value_cursor = contextual->value_offset;
647  }
648  if (self->offset_only) {
649  len = snprintf(buffer, sizeof(buffer),
650  self->prefix_format,
651  contextual->value_offset,
652  contextual->value_offset + contextual->value_size);
653  }
654  else {
655  afw_utf8_line_column_of_offset(&line_number, &column_number,
656  contextual->compiled_value->full_source, contextual->value_offset,
657  self->tab_size, xctx);
658  afw_utf8_line_column_of_offset(&end_line_number, &end_column_number,
659  contextual->compiled_value->full_source,
660  contextual->value_offset + contextual->value_size,
661  self->tab_size, xctx);
662  len = snprintf(buffer, sizeof(buffer),
663  self->prefix_format,
664  line_number, column_number,
665  end_line_number, end_column_number);
666  }
667  prefix.s = &buffer[0];
668  prefix.len = self->empty_prefix.len;
669  memcpy(&buffer[len],
670  &impl_empty_prefix[len + (sizeof(impl_empty_prefix) - prefix.len) - 1],
671  prefix.len - len);
672  self->current_prefix = &prefix;
673  }
674  else {
675  self->current_prefix = &self->empty_prefix;
676  }
677 
678  if (value) {
679  afw_writer_write_utf8(&self->writer,
680  &value->inf->rti.implementation_id,
681  xctx);
682  }
683 }
684 
685 
686 /* Decompile a value to a compiler listing string. */
688 afw_value_compiler_listing_end_value(
689  const afw_writer_t *writer,
690  const afw_value_t *value,
691  afw_xctx_t *xctx)
692 {
693  afw_writer_write_eol(writer, xctx);
694 }
695 
696 
697 /* Decompile call args. */
699 afw_value_compiler_listing_call_args(
700  const afw_writer_t *writer,
701  const afw_value_call_args_t *args,
702  afw_xctx_t *xctx)
703 {
704  afw_size_t i;
705 
706  AFW_VALUE_COMPILER_LISTING_IF_NOT_LIMIT_EXCEEDED
707  for (i = 0; i <= args->argc; i++) {
708  afw_value_compiler_listing_value(args->argv[i], writer, xctx);
709  }
710 }
711 
712 
713 
714 /* Decompile Value::. */
716 afw_value_compiler_listing_value(
717  const afw_value_t *instance,
718  const afw_writer_t *writer,
719  afw_xctx_t *xctx)
720 {
721  if (!instance) {
722  afw_writer_write_utf8(writer, &afw_s_undefined, xctx);
723  afw_writer_write_eol(writer, xctx);
724  }
725  else {
726  afw_value_produce_compiler_listing(instance, writer, xctx);
727  }
728 }
AFW_DEFINE(const afw_object_t *)
#define AFW_DEFINE_INTERNAL(type)
Define an internal function for /src/afw/ source*.c files.
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
#define AFW_UTF8_LITERAL(A_STRING)
String literal initializer.
Definition: afw_common.h:582
_Bool afw_boolean_t
Definition: afw_common.h:373
char afw_utf8_octet_t
8 bits of utf-8 codepoint.
Definition: afw_common.h:236
apr_size_t afw_size_t
size_t.
Definition: afw_common.h:151
unsigned char afw_octet_t
8 bits (unsigned).
Definition: afw_common.h:211
#define AFW_SIZE_T_FMT
Format string specifier used for afw_size_t.
Definition: afw_common.h:341
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
#define afw_pool_malloc(instance, size, xctx)
Call method malloc of interface afw_pool.
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
#define afw_pool_release(instance, xctx)
Call method release of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
Definition: afw_pool.h:167
const afw_pool_t * afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new pool.
#define afw_pool_malloc_type(instance, type, xctx)
Macro to allocate uncleared memory to hold type in pool.
Definition: afw_pool.h:182
afw_utf8_line_column_of_offset(afw_size_t *line_number, afw_size_t *column_number, const afw_utf8_t *s, afw_size_t offset, int tab_size, afw_xctx_t *xctx)
Determine the line and column of an offset in a string.
Definition: afw_utf8.c:1058
#define afw_value_produce_compiler_listing(instance, writer, xctx)
Call method produce_compiler_listing of interface afw_value.
#define afw_value_decompile(instance, writer, xctx)
Call method decompile of interface afw_value.
#define afw_value_get_info(instance, info, p, xctx)
Call method get_info of interface afw_value.
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)
afw_value_compiler_listing_to_string(const afw_value_t *value, const afw_utf8_t *tab, const afw_pool_t *p, afw_xctx_t *xctx)
Decompile a value to a compiler listing string.
#define afw_value_is_undefined_or_evaluated(A_VALUE)
Macro to determine if value is undefined or evaluated.
Definition: afw_value.h:494
#define AFW_VALUE_ASSERT_IS(A_VALUE, A_TYPE_ID, A_SCOPE)
Throw and error if A_VALUE is not value inf id.
Definition: afw_value.h:726
#define afw_value_is_undefined(A_VALUE)
Determine if value is undefined.
Definition: afw_value.h:438
impl_afw_writer_write(const afw_writer_t *instance, const void *buffer, afw_size_t size, afw_xctx_t *xctx)
impl_afw_writer_write_eol(const afw_writer_t *instance, afw_xctx_t *xctx)
#define afw_writer_increment_indent(instance, xctx)
Call method increment_indent of interface afw_writer.
#define afw_writer_write(instance, buffer, size, xctx)
Call method write of interface afw_writer.
#define afw_writer_release(instance, xctx)
Call method release 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
afw_writer_write_size(const afw_writer_t *writer, afw_size_t size, afw_xctx_t *xctx)
Call afw_writer_write() with an size.
Definition: afw_writer.c:162
#define afw_writer_write_utf8(writer, S, xctx)
Call afw_writer_write() with a afw_utf8_t string.
Definition: afw_writer.h:45
Contextual information provided in some values.
afw_size_t value_size
Size in full_source of value source.
const afw_utf8_t * source_location
Source location.
const afw_value_compiled_value_t * compiled_value
Compiled value this value is part of.
afw_size_t value_offset
Offset in full source of compiled value to this value.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
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
Filled in by afw_value get_info method.
Definition: afw_value.h:49
Struct for compiled value value.
const afw_utf8_t * full_source
The full source that was compiled.
Interface afw_value public struct.
const afw_object_t * value_meta_object
AdaptiveValueMeta object or NULL.
const afw_data_type_t * data_type
data type or NULL.
const afw_compile_value_contextual_t * data_type_parameter_contextual
contextual for data type parameter or NULL.
Interface afw_writer public struct.
Interface afw_xctx public struct.