| 1 | /** |
| 2 | * @file static_literals.h |
| 3 | * |
| 4 | * A set of static literal nodes that can be checked for duplicates. |
| 5 | */ |
| 6 | #ifndef PRISM_STATIC_LITERALS_H |
| 7 | #define PRISM_STATIC_LITERALS_Hcxx . . $ `include/prism/static_literals.h:7:9`! |
| 8 | |
| 9 | #include "prism/defines.h"cxx . . $ `<file>/include/prism/defines.h`/ |
| 10 | #include "prism/ast.h"cxx . . $ `<file>/include/prism/ast.h`/ |
| 11 | #include "prism/util/pm_newline_list.h"cxx . . $ `<file>/include/prism/util/pm_newline_list.h`/ |
| 12 | |
| 13 | #include <assert.h> |
| 14 | #include <stdbool.h> |
| 15 | |
| 16 | /** |
| 17 | * An internal hash table for a set of nodes. |
| 18 | */ |
| 19 | typedef structcxx . . $ $anonymous_type_3b2b0f0d2925e26f_0# { |
| 20 | /** The array of nodes in the hash table. */ |
| 21 | pm_node_tcxx . . $ pm_node_t# **nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#nodes.; |
| 22 | |
| 23 | /** The size of the hash table. */ |
| 24 | uint32_tcxx . . $ uint32_t# sizecxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#size.; |
| 25 | |
| 26 | /** The space that has been allocated in the hash table. */ |
| 27 | uint32_tcxx . . $ uint32_t# capacitycxx . . $ $anonymous_type_3b2b0f0d2925e26f_0#capacity.; |
| 28 | } pm_node_hash_tcxx . . $ pm_node_hash_t#; |
| 29 | |
| 30 | /** |
| 31 | * Certain sets of nodes (hash keys and when clauses) check for duplicate nodes |
| 32 | * to alert the user of potential issues. To do this, we keep a set of the nodes |
| 33 | * that have been seen so far, and compare whenever we find a new node. |
| 34 | * |
| 35 | * We bucket the nodes based on their type to minimize the number of comparisons |
| 36 | * that need to be performed. |
| 37 | */ |
| 38 | typedef structcxx . . $ $anonymous_type_3b2b0f0d2925e26f_1# { |
| 39 | /** |
| 40 | * This is the set of IntegerNode and SourceLineNode instances. |
| 41 | */ |
| 42 | pm_node_hash_tcxx . . $ pm_node_hash_t# integer_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#integer_nodes.; |
| 43 | |
| 44 | /** |
| 45 | * This is the set of FloatNode instances. |
| 46 | */ |
| 47 | pm_node_hash_tcxx . . $ pm_node_hash_t# float_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#float_nodes.; |
| 48 | |
| 49 | /** |
| 50 | * This is the set of RationalNode and ImaginaryNode instances. |
| 51 | */ |
| 52 | pm_node_hash_tcxx . . $ pm_node_hash_t# number_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#number_nodes.; |
| 53 | |
| 54 | /** |
| 55 | * This is the set of StringNode and SourceFileNode instances. |
| 56 | */ |
| 57 | pm_node_hash_tcxx . . $ pm_node_hash_t# string_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#string_nodes.; |
| 58 | |
| 59 | /** |
| 60 | * This is the set of RegularExpressionNode instances. |
| 61 | */ |
| 62 | pm_node_hash_tcxx . . $ pm_node_hash_t# regexp_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#regexp_nodes.; |
| 63 | |
| 64 | /** |
| 65 | * This is the set of SymbolNode instances. |
| 66 | */ |
| 67 | pm_node_hash_tcxx . . $ pm_node_hash_t# symbol_nodescxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#symbol_nodes.; |
| 68 | |
| 69 | /** |
| 70 | * A pointer to the last TrueNode instance that was inserted, or NULL. |
| 71 | */ |
| 72 | pm_node_tcxx . . $ pm_node_t# *true_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#true_node.; |
| 73 | |
| 74 | /** |
| 75 | * A pointer to the last FalseNode instance that was inserted, or NULL. |
| 76 | */ |
| 77 | pm_node_tcxx . . $ pm_node_t# *false_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#false_node.; |
| 78 | |
| 79 | /** |
| 80 | * A pointer to the last NilNode instance that was inserted, or NULL. |
| 81 | */ |
| 82 | pm_node_tcxx . . $ pm_node_t# *nil_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#nil_node.; |
| 83 | |
| 84 | /** |
| 85 | * A pointer to the last SourceEncodingNode instance that was inserted, or |
| 86 | * NULL. |
| 87 | */ |
| 88 | pm_node_tcxx . . $ pm_node_t# *source_encoding_nodecxx . . $ $anonymous_type_3b2b0f0d2925e26f_1#source_encoding_node.; |
| 89 | } pm_static_literals_tcxx . . $ pm_static_literals_t#; |
| 90 | |
| 91 | /** |
| 92 | * Add a node to the set of static literals. |
| 93 | * |
| 94 | * @param newline_list The list of newline offsets to use to calculate lines. |
| 95 | * @param start_line The line number that the parser starts on. |
| 96 | * @param literals The set of static literals to add the node to. |
| 97 | * @param node The node to add to the set. |
| 98 | * @param replace Whether to replace the previous node if one already exists. |
| 99 | * @return A pointer to the node that is being overwritten, if there is one. |
| 100 | */ |
| 101 | pm_node_tcxx . . $ pm_node_t# * pm_static_literals_addcxx . . $ pm_static_literals_add(c50d8e366532777f).(const pm_newline_list_tcxx . . $ pm_newline_list_t# *newline_list, int32_tcxx . . $ int32_t# start_line, pm_static_literals_tcxx . . $ pm_static_literals_t# *literals, pm_node_tcxx . . $ pm_node_t# *node, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! replace); |
| 102 | |
| 103 | /** |
| 104 | * Free the internal memory associated with the given static literals set. |
| 105 | * |
| 106 | * @param literals The set of static literals to free. |
| 107 | */ |
| 108 | void pm_static_literals_freecxx . . $ pm_static_literals_free(f2065820d8222ecd).(pm_static_literals_tcxx . . $ pm_static_literals_t# *literals); |
| 109 | |
| 110 | /** |
| 111 | * Create a string-based representation of the given static literal. |
| 112 | * |
| 113 | * @param buffer The buffer to write the string to. |
| 114 | * @param newline_list The list of newline offsets to use to calculate lines. |
| 115 | * @param start_line The line number that the parser starts on. |
| 116 | * @param encoding_name The name of the encoding of the source being parsed. |
| 117 | * @param node The node to create a string representation of. |
| 118 | */ |
| 119 | void pm_static_literal_inspectcxx . . $ pm_static_literal_inspect(e469797467607aef).(pm_buffer_tcxx . . $ pm_buffer_t# *buffer, const pm_newline_list_tcxx . . $ pm_newline_list_t# *newline_list, int32_tcxx . . $ int32_t# start_line, const char *encoding_name, const pm_node_tcxx . . $ pm_node_t# *node); |
| 120 | |
| 121 | #endif |