mruby/c VM Source Code master (2026/08/06)
Loading...
Searching...
No Matches
symbol.c File Reference

mruby/c Symbol class More...

#include "_autogen_builtin_symbol.h"
#include "mrubyc.h"
#include "_autogen_class_symbol.h"
Include dependency graph for symbol.c:

Go to the source code of this file.

Data Structures

struct  SYM_INDEX

Macros

#define MRBC_DEFINE_SYMBOL_TABLE
#define MRBC_SYMBOL_SEARCH_BTREE
#define OFFSET_BUILTIN_SYMBOL   512

Functions

static uint16_t calc_hash (const char *str)
static int search_builtin_symbol (const char *str)
static int search_index (uint16_t hash, const char *str)
static int add_index (uint16_t hash, const char *str)
void mrbc_cleanup_symbol (void)
mrbc_sym mrbc_str_to_symid (const char *str)
const char * mrbc_symid_to_str (mrbc_sym sym_id)
mrbc_sym mrbc_search_symid (const char *str)
void mrbc_make_nested_symbol_s (char *buf, mrbc_sym id1, mrbc_sym id2)
void mrbc_separate_nested_symid (mrbc_sym sym_id, mrbc_sym *id1, mrbc_sym *id2)
mrbc_value mrbc_symbol_new (struct VM *vm, const char *str)

Variables

static struct SYM_INDEX sym_index [MAX_SYMBOLS_COUNT]
static int sym_index_pos

Detailed Description

mruby/c Symbol class

Copyright (C) 2015-      Kyushu Institute of Technology.
Copyright (C) 2015-2026  Shimane IT Open-Innovation Center.
Copyright (C) 2026-      Shimane Institute for Industrial Technology.

This file is distributed under BSD 3-Clause License.

Definition in file symbol.c.

Macro Definition Documentation

◆ MRBC_DEFINE_SYMBOL_TABLE

#define MRBC_DEFINE_SYMBOL_TABLE

Definition at line 26 of file symbol.c.

◆ MRBC_SYMBOL_SEARCH_BTREE

#define MRBC_SYMBOL_SEARCH_BTREE

Definition at line 33 of file symbol.c.

◆ OFFSET_BUILTIN_SYMBOL

#define OFFSET_BUILTIN_SYMBOL   512

Definition at line 36 of file symbol.c.

Function Documentation

◆ add_index()

int add_index ( uint16_t hash,
const char * str )
static

add to index table

Parameters
hashreturn value.
strstring ptr.
Returns
index. or -1 if error.

Definition at line 164 of file symbol.c.

Here is the caller graph for this function:

◆ calc_hash()

uint16_t calc_hash ( const char * str)
inlinestatic

Calculate hash value.

Parameters
strTarget string.
Returns
uint16_t Hash value.

Definition at line 73 of file symbol.c.

Here is the caller graph for this function:

◆ mrbc_cleanup_symbol()

void mrbc_cleanup_symbol ( void )

cleanup

Definition at line 205 of file symbol.c.

Here is the caller graph for this function:

◆ mrbc_make_nested_symbol_s()

void mrbc_make_nested_symbol_s ( char * buf,
mrbc_sym id1,
mrbc_sym id2 )

make internal use strings for class constant

Parameters
[out]bufoutput buffer.
id1parent class symbol id
id2target symbol id

Definition at line 279 of file symbol.c.

Here is the caller graph for this function:

◆ mrbc_search_symid()

mrbc_sym mrbc_search_symid ( const char * str)

Search only.

Parameters
strC string.
Returns
symbol id. or -1 if not registered.

Definition at line 259 of file symbol.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_separate_nested_symid()

void mrbc_separate_nested_symid ( mrbc_sym sym_id,
mrbc_sym * id1,
mrbc_sym * id2 )

separate nested symbol ID

Parameters
sym_idsymbol ID
[out]id1result 1
[out]id2result 2
See also
mrbc_make_nested_symbol_s

Definition at line 312 of file symbol.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_str_to_symid()

mrbc_sym mrbc_str_to_symid ( const char * str)

Convert string to symbol value.

Parameters
strTarget string.
Returns
mrbc_sym Symbol value. -1 if error.

Definition at line 218 of file symbol.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_symbol_new()

mrbc_value mrbc_symbol_new ( struct VM * vm,
const char * str )

constructor

Parameters
vmpointer to VM.
strString
Returns
symbol object

Definition at line 335 of file symbol.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrbc_symid_to_str()

const char * mrbc_symid_to_str ( mrbc_sym sym_id)

Convert symbol value to string.

Parameters
sym_idSymbol value.
Returns
const char* Symbol String. Returns an empty string if the sym_id is invalid.

Definition at line 239 of file symbol.c.

Here is the caller graph for this function:

◆ search_builtin_symbol()

int search_builtin_symbol ( const char * str)
static

search built-in symbol table

Parameters
strstring ptr.
Returns
symbol id. or -1 if not found.

Definition at line 90 of file symbol.c.

Here is the caller graph for this function:

◆ search_index()

int search_index ( uint16_t hash,
const char * str )
static

search index table

Parameters
hashhash value.
strstring ptr.
Returns
index. or -1 if not found.

Definition at line 129 of file symbol.c.

Here is the caller graph for this function:

Variable Documentation

◆ sym_index

struct SYM_INDEX sym_index[MAX_SYMBOLS_COUNT]
static

Definition at line 59 of file symbol.c.

◆ sym_index_pos

int sym_index_pos
static

Definition at line 60 of file symbol.c.