mruby/c VM Source Code release 3.4
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 MRBC_SYMBOL_TABLE_INDEX_TYPE   uint8_t
#define OFFSET_BUILTIN_SYMBOL   256

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 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- Shimane IT Open-Innovation Center.

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 25 of file symbol.c.

◆ MRBC_SYMBOL_SEARCH_BTREE

#define MRBC_SYMBOL_SEARCH_BTREE

Definition at line 32 of file symbol.c.

◆ MRBC_SYMBOL_TABLE_INDEX_TYPE

#define MRBC_SYMBOL_TABLE_INDEX_TYPE   uint8_t

Definition at line 36 of file symbol.c.

◆ OFFSET_BUILTIN_SYMBOL

#define OFFSET_BUILTIN_SYMBOL   256

Definition at line 41 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 163 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 72 of file symbol.c.

Here is the caller graph for this function:

◆ make_nested_symbol_s()

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

make internal use strings for class constant

Parameters
bufoutput buffer.
id1parent class symbol id
id2target symbol id

Definition at line 278 of file symbol.c.

Here is the caller graph for this function:

◆ mrbc_cleanup_symbol()

void mrbc_cleanup_symbol ( void )

cleanup

Definition at line 204 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 258 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
make_nested_symbol_s

Definition at line 305 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 217 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 334 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* String.
Return values
NULLInvalid sym_id was given.

Definition at line 238 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 89 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 128 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 58 of file symbol.c.

◆ sym_index_pos

int sym_index_pos
static

Definition at line 59 of file symbol.c.