53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
#include "iterate.h"
|
|
#include "node.h"
|
|
|
|
#include <fx/ds/string.h>
|
|
#include <ivy/lang/lex.h>
|
|
#include <stdio.h>
|
|
|
|
#define PROPERTY_TYPE(flags) (flags & (PROPERTY_FULL | PROPERTY_AUTO))
|
|
|
|
static void collect_children(
|
|
struct ivy_ast_node *node, struct ivy_ast_node_iterator *iterator)
|
|
{
|
|
struct ivy_ast_property_node *prop = (struct ivy_ast_property_node *)node;
|
|
|
|
if (prop->n_get) {
|
|
ast_node_iterator_enqueue_node(iterator, node, prop->n_get);
|
|
}
|
|
|
|
if (prop->n_set) {
|
|
ast_node_iterator_enqueue_node(iterator, node, prop->n_set);
|
|
}
|
|
}
|
|
|
|
static void to_string(struct ivy_ast_node *node, fx_string *str)
|
|
{
|
|
struct ivy_ast_property_node *prop = (struct ivy_ast_property_node *)node;
|
|
|
|
fx_string_append_cstrf(
|
|
str, "%s (%s) [", ivy_ast_node_type_to_string(node->n_type),
|
|
prop->n_ident->t_str);
|
|
|
|
if (prop->n_flags & IVY_AST_PROPERTY_GET) {
|
|
fx_string_append_cstr(str, "get");
|
|
}
|
|
|
|
if ((prop->n_flags & IVY_AST_PROPERTY_GET)
|
|
&& prop->n_flags & IVY_AST_PROPERTY_SET) {
|
|
fx_string_append_cstr(str, ", ");
|
|
}
|
|
|
|
if (prop->n_flags & IVY_AST_PROPERTY_SET) {
|
|
fx_string_append_cstr(str, "set");
|
|
}
|
|
|
|
fx_string_append_cstr(str, "]");
|
|
}
|
|
|
|
struct ast_node_type property_node_ops = {
|
|
.n_to_string = to_string,
|
|
.n_collect_children = collect_children,
|
|
.n_node_size = sizeof(struct ivy_ast_property_node),
|
|
};
|