Prism Ruby parser
Data Structures | Functions
static_literals.h File Reference

A set of static literal nodes that can be checked for duplicates. More...

#include "prism/defines.h"
#include "prism/ast.h"
#include "prism/util/pm_newline_list.h"
#include <assert.h>
#include <stdbool.h>
Include dependency graph for static_literals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pm_node_hash_t
 An internal hash table for a set of nodes. More...
 
struct  pm_static_literals_t
 Certain sets of nodes (hash keys and when clauses) check for duplicate nodes to alert the user of potential issues. More...
 

Functions

pm_node_tpm_static_literals_add (const pm_newline_list_t *newline_list, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node, bool replace)
 Add a node to the set of static literals. More...
 
void pm_static_literals_free (pm_static_literals_t *literals)
 Free the internal memory associated with the given static literals set. More...
 
void pm_static_literal_inspect (pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node)
 Create a string-based representation of the given static literal. More...
 

Detailed Description

A set of static literal nodes that can be checked for duplicates.

Function Documentation

◆ pm_static_literals_add()

pm_node_t* pm_static_literals_add ( const pm_newline_list_t newline_list,
int32_t  start_line,
pm_static_literals_t literals,
pm_node_t node,
bool  replace 
)

Add a node to the set of static literals.

Parameters
newline_listThe list of newline offsets to use to calculate lines.
start_lineThe line number that the parser starts on.
literalsThe set of static literals to add the node to.
nodeThe node to add to the set.
replaceWhether to replace the previous node if one already exists.
Returns
A pointer to the node that is being overwritten, if there is one.

◆ pm_static_literals_free()

void pm_static_literals_free ( pm_static_literals_t literals)

Free the internal memory associated with the given static literals set.

Parameters
literalsThe set of static literals to free.

◆ pm_static_literal_inspect()

void pm_static_literal_inspect ( pm_buffer_t buffer,
const pm_newline_list_t newline_list,
int32_t  start_line,
const char *  encoding_name,
const pm_node_t node 
)

Create a string-based representation of the given static literal.

Parameters
bufferThe buffer to write the string to.
newline_listThe list of newline offsets to use to calculate lines.
start_lineThe line number that the parser starts on.
encoding_nameThe name of the encoding of the source being parsed.
nodeThe node to create a string representation of.