fix msvc
This commit is contained in:
87
vendor/mruby-compiler2/include/mrc_ccontext.h
vendored
Normal file
87
vendor/mruby-compiler2/include/mrc_ccontext.h
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifndef MRC_CCONTEXT_H
|
||||
#define MRC_CCONTEXT_H
|
||||
|
||||
#include "mrc_common.h"
|
||||
#include "mrc_diagnostic.h"
|
||||
#include "mrc_throw.h"
|
||||
#include "mrc_pool.h"
|
||||
#include <stddef.h>
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
typedef pm_node_t mrc_node;
|
||||
typedef pm_parser_t mrc_parser_state;
|
||||
typedef pm_constant_id_list_t mrc_constant_id_list;
|
||||
typedef struct {
|
||||
pm_parser_t parser;
|
||||
pm_options_t options;
|
||||
pm_string_t input;
|
||||
bool parsed;
|
||||
} pm_parse_result_t;
|
||||
|
||||
struct mrc_diagnostic_list;
|
||||
|
||||
typedef struct mrc_filename_table {
|
||||
const char *filename;
|
||||
uint32_t start;
|
||||
} mrc_filename_table;
|
||||
|
||||
typedef struct mrc_ccontext {
|
||||
mrb_state *mrb;
|
||||
struct mrc_jmpbuf *jmp;
|
||||
mrc_parser_state *p;
|
||||
pm_options_t *options; // instead of mrb_sym *syms
|
||||
int slen;
|
||||
char *filename;
|
||||
uint16_t lineno;
|
||||
struct RClass *target_class;
|
||||
mrc_bool capture_errors:1;
|
||||
mrc_bool dump_result:1;
|
||||
mrc_bool no_exec:1;
|
||||
mrc_bool keep_lv:1;
|
||||
mrc_bool no_optimize:1;
|
||||
mrc_bool no_ext_ops:1;
|
||||
#if defined(MRC_TARGET_MRUBY)
|
||||
const struct RProc *upper;
|
||||
#endif
|
||||
|
||||
// TODO
|
||||
//size_t parser_nerr;
|
||||
struct mrc_diagnostic_list *diagnostic_list;
|
||||
|
||||
// For PICOIRB
|
||||
uint16_t scope_sp;
|
||||
|
||||
#ifndef MRC_NO_STDIO
|
||||
mrc_pool *pool; // for codedump
|
||||
|
||||
mrc_filename_table *filename_table;
|
||||
uint16_t filename_table_length;
|
||||
uint16_t current_filename_index;
|
||||
#endif
|
||||
} mrc_ccontext; /* compiler context */
|
||||
|
||||
#ifdef MRC_TARGET_MRUBY
|
||||
static inline int mrc_gc_arena_save(mrc_ccontext *c)
|
||||
{
|
||||
if (!c->mrb) return 0;
|
||||
return mrb_gc_arena_save(c->mrb);
|
||||
}
|
||||
static inline void mrc_gc_arena_restore(mrc_ccontext *c, int ai)
|
||||
{
|
||||
if (!c->mrb) return;
|
||||
mrb_gc_arena_restore(c->mrb, ai);
|
||||
}
|
||||
#else
|
||||
# define mrc_gc_arena_save(c) 0;(void)ai
|
||||
# define mrc_gc_arena_restore(c,ai)
|
||||
#endif
|
||||
|
||||
mrc_ccontext *mrc_ccontext_new(mrb_state *mrb);
|
||||
void mrc_ccontext_cleanup_local_variables(mrc_ccontext *c);
|
||||
const char *mrc_ccontext_filename(mrc_ccontext *c, const char *s);
|
||||
void mrc_ccontext_free(mrc_ccontext *c);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_CCONTEXT_H
|
||||
14
vendor/mruby-compiler2/include/mrc_cdump.h
vendored
Normal file
14
vendor/mruby-compiler2/include/mrc_cdump.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef MRC_CDUMP_H
|
||||
#define MRC_CDUMP_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
#include "mrc_irep.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
int mrc_dump_irep_cstruct(mrc_ccontext *c, const mrc_irep *irep, uint8_t flags, FILE *fp, const char *initname);
|
||||
|
||||
#endif // MRC_CDUMP_H
|
||||
|
||||
17
vendor/mruby-compiler2/include/mrc_codedump.h
vendored
Normal file
17
vendor/mruby-compiler2/include/mrc_codedump.h
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef MRC_CODEDUMP_H
|
||||
#define MRC_CODEDUMP_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
#ifndef MRC_NO_STDIO
|
||||
void mrc_codedump_all_file(mrc_ccontext *c, mrc_irep *irep, FILE *out);
|
||||
#endif
|
||||
|
||||
void mrc_codedump_all(mrc_ccontext *c, mrc_irep *irep);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_CODEDUMP_H
|
||||
|
||||
15
vendor/mruby-compiler2/include/mrc_codegen.h
vendored
Normal file
15
vendor/mruby-compiler2/include/mrc_codegen.h
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef MRC_CODEGEN_H
|
||||
#define MRC_CODEGEN_H
|
||||
|
||||
#include "mrc_common.h"
|
||||
#include "mrc_ccontext.h"
|
||||
#include "mrc_irep.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
mrc_irep *mrc_generate_code(mrc_ccontext *c, mrc_node *node);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_CODEGEN_H
|
||||
|
||||
165
vendor/mruby-compiler2/include/mrc_common.h
vendored
Normal file
165
vendor/mruby-compiler2/include/mrc_common.h
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef MRC_COMMON_H
|
||||
#define MRC_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MRC_STRINGIZE0(expr) #expr
|
||||
#define MRC_STRINGIZE(expr) MRC_STRINGIZE0(expr)
|
||||
|
||||
#if defined(PICORB_VM_MRUBY)
|
||||
#if !defined(MRC_TARGET_MRUBY)
|
||||
#define MRC_TARGET_MRUBY
|
||||
#endif
|
||||
#include <mruby.h>
|
||||
#endif
|
||||
#if defined(PICORB_VM_MRUBYC)
|
||||
#if !defined(MRC_TARGET_MRUBYC)
|
||||
#define MRC_TARGET_MRUBYC
|
||||
#endif
|
||||
#include <mrubyc.h>
|
||||
#define mrb_state void
|
||||
#endif
|
||||
|
||||
#if !defined(MRC_TARGET_MRUBY) && !defined(PICORB_VM_MRUBYC)
|
||||
/* May be building mrbc (picorbc) */
|
||||
#define mrb_state void
|
||||
#endif
|
||||
|
||||
#if !defined(PRISM_XALLOCATOR)
|
||||
#define PRISM_XALLOCATOR
|
||||
#endif
|
||||
#include "prism.h"
|
||||
|
||||
#ifndef PICORUBY_VERSION
|
||||
#define MRC_VERSION "unknown (standalone)"
|
||||
#else
|
||||
#define MRC_VERSION PICORUBY_VERSION
|
||||
#endif
|
||||
|
||||
#define MRC_RELEASE_YEAR 2026
|
||||
#define MRC_RELEASE_MONTH 1
|
||||
#define MRC_RELEASE_DAY 21
|
||||
#define MRC_RELEASE_DATE MRC_STRINGIZE(MRC_RELEASE_YEAR) "-" \
|
||||
MRC_STRINGIZE(MRC_RELEASE_MONTH) "-" \
|
||||
MRC_STRINGIZE(MRC_RELEASE_DAY)
|
||||
|
||||
#ifdef MRB_USE_CXX_ABI
|
||||
#define MRC_USE_CXX_ABI
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef MRC_USE_CXX_ABI
|
||||
#define MRC_BEGIN_DECL
|
||||
#define MRC_END_DECL
|
||||
#else
|
||||
#define MRC_BEGIN_DECL extern "C" {
|
||||
#define MRC_END_DECL }
|
||||
#endif
|
||||
#else
|
||||
/** Start declarations in C mode */
|
||||
# define MRC_BEGIN_DECL
|
||||
/** End declarations in C mode */
|
||||
# define MRC_END_DECL
|
||||
#endif
|
||||
|
||||
/** Declare a public mruby API function. */
|
||||
#ifndef MRC_API
|
||||
#if defined(MRC_BUILD_AS_DLL)
|
||||
#if defined(MRC_CORE) || defined(MRC_LIB)
|
||||
# define MRC_API __declspec(dllexport)
|
||||
#else
|
||||
# define MRC_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
# define MRC_API extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) || (defined(__bool_true_false_are_defined) && __bool_true_false_are_defined)
|
||||
typedef bool mrc_bool;
|
||||
|
||||
# ifndef FALSE
|
||||
# define FALSE false
|
||||
# endif
|
||||
# ifndef TRUE
|
||||
# define TRUE true
|
||||
# endif
|
||||
#else
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
typedef _Bool mrc_bool;
|
||||
# else
|
||||
typedef uint8_t mrc_bool;
|
||||
# endif
|
||||
|
||||
# ifndef FALSE
|
||||
# define FALSE 0
|
||||
# endif
|
||||
# ifndef TRUE
|
||||
# define TRUE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(MRC_INT32)
|
||||
#define MRC_INT64 1
|
||||
#endif
|
||||
#if !defined(MRC_32BIT)
|
||||
#define MRC_64BIT 1
|
||||
#endif
|
||||
|
||||
#if defined(MRC_INT64)
|
||||
typedef int64_t mrc_int;
|
||||
typedef uint64_t mrc_uint;
|
||||
#define MRC_INT_BIT 64
|
||||
#define MRC_INT_MIN INT64_MIN
|
||||
#define MRC_INT_MAX INT64_MAX
|
||||
#define MRC_PRIo PRIo64
|
||||
#define MRC_PRId PRId64
|
||||
#define MRC_PRIx PRIx64
|
||||
#else
|
||||
typedef int32_t mrc_int;
|
||||
typedef uint32_t mrc_uint;
|
||||
#define MRC_INT_BIT 32
|
||||
#define MRC_INT_MIN INT32_MIN
|
||||
#define MRC_INT_MAX INT32_MAX
|
||||
#define MRC_PRIo PRIo32
|
||||
#define MRC_PRId PRId32
|
||||
#define MRC_PRIx PRIx32
|
||||
#endif
|
||||
|
||||
#ifdef MRB_NO_FLOAT
|
||||
#define MRC_NO_FLOAT
|
||||
#endif
|
||||
#ifdef MRB_USE_FLOAT32
|
||||
#define MRC_USE_FLOAT32
|
||||
#endif
|
||||
|
||||
#ifndef MRC_NO_FLOAT
|
||||
#ifdef MRC_USE_FLOAT32
|
||||
typedef float mrc_float;
|
||||
#else
|
||||
typedef double mrc_float;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef uint32_t mrc_sym;
|
||||
typedef uint8_t mrc_code;
|
||||
|
||||
/**
|
||||
* \class mrb_aspec
|
||||
*
|
||||
* Specifies the number of arguments a function takes
|
||||
*
|
||||
* Example: `MRB_ARGS_REQ(2) | MRB_ARGS_OPT(1)` for a method that expects 2..3 arguments
|
||||
*/
|
||||
typedef uint32_t mrc_aspec;
|
||||
|
||||
#ifdef MRC_DEBUG
|
||||
#include <assert.h>
|
||||
#define mrc_assert(p) assert(p)
|
||||
#define mrc_assert_int_fit(t1,n,t2,max) assert((n)>=0 && ((sizeof(n)<=sizeof(t2))||(n<=(t1)(max))))
|
||||
#else
|
||||
#define mrc_assert(p) ((void)0)
|
||||
#define mrc_assert_int_fit(t1,n,t2,max) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* MRC_COMMON_H */
|
||||
14
vendor/mruby-compiler2/include/mrc_compile.h
vendored
Normal file
14
vendor/mruby-compiler2/include/mrc_compile.h
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef MRC_COMPILE_H
|
||||
#define MRC_COMPILE_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
#include "mrc_irep.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
mrc_irep *mrc_load_file_cxt(mrc_ccontext *c, const char **filenames, uint8_t **source);
|
||||
mrc_irep *mrc_load_string_cxt(mrc_ccontext *c, const uint8_t **source, size_t length);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif /* MRC_COMPILE_H */
|
||||
78
vendor/mruby-compiler2/include/mrc_debug.h
vendored
Normal file
78
vendor/mruby-compiler2/include/mrc_debug.h
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
** @file mruby/debug.h - mruby debug info
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRC_DEBUG_H
|
||||
#define MRC_DEBUG_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
#include "mrc_irep.h"
|
||||
|
||||
/**
|
||||
* mruby Debugging.
|
||||
*/
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
typedef enum mrc_debug_line_type {
|
||||
mrc_debug_line_ary = 0,
|
||||
mrc_debug_line_flat_map,
|
||||
mrc_debug_line_packed_map
|
||||
} mrc_debug_line_type;
|
||||
|
||||
typedef struct mrc_irep_debug_info_line {
|
||||
uint32_t start_pos;
|
||||
uint16_t line;
|
||||
} mrc_irep_debug_info_line;
|
||||
|
||||
typedef struct mrc_irep_debug_info_file {
|
||||
uint32_t start_pos;
|
||||
mrc_sym filename_sym;
|
||||
uint32_t line_entry_count;
|
||||
mrc_debug_line_type line_type;
|
||||
union {
|
||||
const char *s;
|
||||
void *ptr;
|
||||
const uint16_t *ary;
|
||||
const mrc_irep_debug_info_line *flat_map;
|
||||
const uint8_t *packed_map;
|
||||
} lines;
|
||||
} mrc_irep_debug_info_file;
|
||||
|
||||
typedef struct mrc_irep_debug_info {
|
||||
uint32_t pc_count;
|
||||
uint16_t flen;
|
||||
mrc_irep_debug_info_file **files;
|
||||
} mrc_irep_debug_info;
|
||||
|
||||
/*
|
||||
* get filename from irep's debug info and program counter
|
||||
* @return returns NULL if not found
|
||||
*/
|
||||
const char *mrc_debug_get_filename(mrc_ccontext *c, const mrc_irep *irep, uint32_t pc);
|
||||
|
||||
/*
|
||||
* get line from irep's debug info and program counter
|
||||
* @return returns -1 if not found
|
||||
*/
|
||||
int32_t mrc_debug_get_line(mrc_ccontext *c, const mrc_irep *irep, uint32_t pc);
|
||||
|
||||
/*
|
||||
* get line and filename from irep's debug info and program counter
|
||||
* @return returns FALSE if not found
|
||||
*/
|
||||
mrc_bool mrc_debug_get_position(mrc_ccontext *c, const mrc_irep *irep, uint32_t pc, int32_t *lp, const char **fp);
|
||||
|
||||
const char *mrc_debug_get_filename(mrc_ccontext *c, const mrc_irep *irep, uint32_t pc);
|
||||
mrc_irep_debug_info *mrc_debug_info_alloc(mrc_ccontext *c, mrc_irep *irep);
|
||||
mrc_irep_debug_info_file *mrc_debug_info_append_file(
|
||||
mrc_ccontext *c, mrc_irep_debug_info *info,
|
||||
const char *filename, uint16_t *lines,
|
||||
uint32_t start_pos, uint32_t end_pos);
|
||||
void mrc_debug_info_free(mrc_ccontext *c, mrc_irep_debug_info *d);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif /* MRC_DEBUG_H */
|
||||
|
||||
30
vendor/mruby-compiler2/include/mrc_diagnostic.h
vendored
Normal file
30
vendor/mruby-compiler2/include/mrc_diagnostic.h
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef MRC_DIAGNOSTIC_H
|
||||
#define MRC_DIAGNOSTIC_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
typedef enum {
|
||||
MRC_PARSER_WARNING = 0,
|
||||
MRC_PARSER_ERROR = 1,
|
||||
MRC_GENERATOR_WARNING = 2,
|
||||
MRC_GENERATOR_ERROR = 3,
|
||||
} mrc_diagnostic_code;
|
||||
|
||||
typedef struct mrc_diagnostic_list {
|
||||
mrc_diagnostic_code code;
|
||||
char *message;
|
||||
uint32_t line;
|
||||
uint32_t column;
|
||||
struct mrc_diagnostic_list *next;
|
||||
} mrc_diagnostic_list;
|
||||
|
||||
struct mrc_ccontext;
|
||||
|
||||
void mrc_diagnostic_list_append(struct mrc_ccontext *c, const uint8_t *location_start, const char *message, mrc_diagnostic_code code);
|
||||
void mrc_diagnostic_list_free(struct mrc_ccontext *c);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_DIAGNOSTIC_H
|
||||
154
vendor/mruby-compiler2/include/mrc_dump.h
vendored
Normal file
154
vendor/mruby-compiler2/include/mrc_dump.h
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
#ifndef MRC_DUMP_H
|
||||
#define MRC_DUMP_H
|
||||
|
||||
#include "mrc_irep.h"
|
||||
#include "mrc_ccontext.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
#define MRC_DUMP_DEBUG_INFO 1
|
||||
#define MRC_DUMP_STATIC 2
|
||||
|
||||
#ifndef MRC_NO_STDIO
|
||||
int mrc_dump_irep_cfunc(mrc_ccontext *c, const mrc_irep *irep, uint8_t flags, FILE *fp, const char *initname);
|
||||
int mrc_dump_irep_binary(mrc_ccontext *c, const mrc_irep *irep, uint8_t flags, FILE* fp);
|
||||
int mrc_dump_irep(mrc_ccontext *c, const mrc_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
|
||||
#endif
|
||||
|
||||
/* dump/load error code
|
||||
*
|
||||
* NOTE: MRC_DUMP_GENERAL_FAILURE is caused by
|
||||
* unspecified issues like malloc failed.
|
||||
*/
|
||||
#define MRC_DUMP_OK 0
|
||||
#define MRC_DUMP_GENERAL_FAILURE (-1)
|
||||
#define MRC_DUMP_WRITE_FAULT (-2)
|
||||
#define MRC_DUMP_READ_FAULT (-3)
|
||||
#define MRC_DUMP_INVALID_FILE_HEADER (-4)
|
||||
#define MRC_DUMP_INVALID_IREP (-5)
|
||||
#define MRC_DUMP_INVALID_ARGUMENT (-6)
|
||||
|
||||
/* null symbol length */
|
||||
#define MRC_DUMP_NULL_SYM_LEN 0xFFFF
|
||||
|
||||
/* Rite Binary File header */
|
||||
#define RITE_BINARY_IDENT "RITE"
|
||||
/* Binary Format Version Major:Minor */
|
||||
/* Major: Incompatible to prior versions */
|
||||
/* Minor: Upper-compatible to prior versions */
|
||||
#define RITE_BINARY_MAJOR_VER "03"
|
||||
#define RITE_BINARY_MINOR_VER "00"
|
||||
#define RITE_BINARY_FORMAT_VER RITE_BINARY_MAJOR_VER RITE_BINARY_MINOR_VER
|
||||
#if defined(RITE_COMPILER_NAME)
|
||||
#undef RITE_COMPILER_NAME
|
||||
#endif
|
||||
#define RITE_COMPILER_NAME "HSMK"
|
||||
#define RITE_PARSER_NAME "Prism"
|
||||
#define RITE_COMPILER_VERSION "0000"
|
||||
|
||||
#define RITE_VM_VER "0300"
|
||||
|
||||
#define RITE_BINARY_EOF "END\0"
|
||||
#define RITE_SECTION_IREP_IDENT "IREP"
|
||||
#define RITE_SECTION_DEBUG_IDENT "DBG\0"
|
||||
#define RITE_SECTION_LV_IDENT "LVAR"
|
||||
|
||||
#define MRC_DUMP_DEFAULT_STR_LEN 128
|
||||
#define MRC_DUMP_ALIGNMENT sizeof(uint32_t)
|
||||
|
||||
/* binary header */
|
||||
struct rite_binary_header {
|
||||
uint8_t binary_ident[4]; /* Binary Identifier */
|
||||
uint8_t major_version[2]; /* Binary Format Major Version */
|
||||
uint8_t minor_version[2]; /* Binary Format Minor Version */
|
||||
uint8_t binary_size[4]; /* Binary Size */
|
||||
uint8_t compiler_name[4]; /* Compiler name */
|
||||
uint8_t compiler_version[4];
|
||||
};
|
||||
|
||||
/* section header */
|
||||
#define RITE_SECTION_HEADER \
|
||||
uint8_t section_ident[4]; \
|
||||
uint8_t section_size[4]
|
||||
|
||||
struct rite_section_header {
|
||||
RITE_SECTION_HEADER;
|
||||
};
|
||||
|
||||
struct rite_section_irep_header {
|
||||
RITE_SECTION_HEADER;
|
||||
|
||||
uint8_t rite_version[4]; /* Rite Instruction Specification Version */
|
||||
};
|
||||
|
||||
struct rite_section_debug_header {
|
||||
RITE_SECTION_HEADER;
|
||||
};
|
||||
|
||||
struct rite_section_lv_header {
|
||||
RITE_SECTION_HEADER;
|
||||
};
|
||||
|
||||
#define RITE_LV_NULL_MARK UINT16_MAX
|
||||
|
||||
struct rite_binary_footer {
|
||||
RITE_SECTION_HEADER;
|
||||
};
|
||||
|
||||
static inline size_t
|
||||
mrc_uint8_to_bin(uint8_t s, uint8_t *bin)
|
||||
{
|
||||
*bin = s;
|
||||
return sizeof(uint8_t);
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
mrc_uint16_to_bin(uint16_t s, uint8_t *bin)
|
||||
{
|
||||
*bin++ = (s >> 8) & 0xff;
|
||||
*bin = s & 0xff;
|
||||
return sizeof(uint16_t);
|
||||
}
|
||||
|
||||
static inline size_t
|
||||
mrc_uint32_to_bin(uint32_t l, uint8_t *bin)
|
||||
{
|
||||
*bin++ = (l >> 24) & 0xff;
|
||||
*bin++ = (l >> 16) & 0xff;
|
||||
*bin++ = (l >> 8) & 0xff;
|
||||
*bin = l & 0xff;
|
||||
return sizeof(uint32_t);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
mrc_bin_to_uint32(const uint8_t *bin)
|
||||
{
|
||||
return (uint32_t)bin[0] << 24 |
|
||||
(uint32_t)bin[1] << 16 |
|
||||
(uint32_t)bin[2] << 8 |
|
||||
(uint32_t)bin[3];
|
||||
}
|
||||
|
||||
static inline uint16_t
|
||||
mrc_bin_to_uint16(const uint8_t *bin)
|
||||
{
|
||||
return (uint16_t)bin[0] << 8 |
|
||||
(uint16_t)bin[1];
|
||||
}
|
||||
|
||||
static inline uint8_t
|
||||
mrc_bin_to_uint8(const uint8_t *bin)
|
||||
{
|
||||
return (uint8_t)bin[0];
|
||||
}
|
||||
|
||||
static inline const char*
|
||||
mrc_description(void)
|
||||
{
|
||||
return MRC_VERSION " (" MRC_RELEASE_DATE ") Parser: " RITE_PARSER_NAME ", RITE: " RITE_BINARY_FORMAT_VER;
|
||||
}
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_DUMP_H
|
||||
|
||||
45
vendor/mruby-compiler2/include/mrc_endian.h
vendored
Normal file
45
vendor/mruby-compiler2/include/mrc_endian.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
** @file mruby/endian.h - detect endian-ness
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRC_ENDIAN_H
|
||||
#define MRC_ENDIAN_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
#if !defined(BYTE_ORDER) && defined(__BYTE_ORDER__)
|
||||
# define BYTE_ORDER __BYTE_ORDER__
|
||||
#endif
|
||||
#if !defined(BIG_ENDIAN) && defined(__ORDER_BIG_ENDIAN__)
|
||||
# define BIG_ENDIAN __ORDER_BIG_ENDIAN__
|
||||
#endif
|
||||
#if !defined(LITTLE_ENDIAN) && defined(__ORDER_LITTLE_ENDIAN__)
|
||||
# define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
|
||||
#endif
|
||||
|
||||
#ifdef BYTE_ORDER
|
||||
# if BYTE_ORDER == BIG_ENDIAN
|
||||
# define littleendian 0
|
||||
# elif BYTE_ORDER == LITTLE_ENDIAN
|
||||
# define littleendian 1
|
||||
# endif
|
||||
#endif
|
||||
#ifndef littleendian
|
||||
/* can't distinguish endian in compile time */
|
||||
static inline int
|
||||
check_little_endian(void)
|
||||
{
|
||||
unsigned int n = 1;
|
||||
return (*(unsigned char*)&n == 1);
|
||||
}
|
||||
# define littleendian check_little_endian()
|
||||
#endif
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif /* MRC_ENDIAN_H */
|
||||
|
||||
98
vendor/mruby-compiler2/include/mrc_irep.h
vendored
Normal file
98
vendor/mruby-compiler2/include/mrc_irep.h
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
** @file mruby/irep.h - mrc_irep structure
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRC_IREP_H
|
||||
#define MRC_IREP_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
|
||||
/**
|
||||
* Compiled mruby scripts.
|
||||
*/
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
#define IREP_TT_NFLAG 1 /* number (non string) flag */
|
||||
#define IREP_TT_SFLAG 2 /* static string flag */
|
||||
|
||||
typedef struct mrc_pool_value {
|
||||
uint32_t tt; /* packed type and length (for string) */
|
||||
union {
|
||||
const char *str;
|
||||
int32_t i32;
|
||||
int64_t i64;
|
||||
#ifndef MRC_NO_FLOAT
|
||||
mrc_float f;
|
||||
#endif
|
||||
} u;
|
||||
} mrc_pool_value;
|
||||
|
||||
enum mrc_catch_type {
|
||||
MRC_CATCH_RESCUE = 0,
|
||||
MRC_CATCH_ENSURE = 1,
|
||||
};
|
||||
|
||||
struct mrc_irep_catch_handler {
|
||||
uint8_t type; /* enum mrc_catch_type */
|
||||
uint8_t begin[4]; /* The starting address to match the handler. Includes this. */
|
||||
uint8_t end[4]; /* The endpoint address that matches the handler. Not Includes this. */
|
||||
uint8_t target[4]; /* The address to jump to if a match is made. */
|
||||
};
|
||||
|
||||
/* Program data array struct */
|
||||
typedef struct mrc_irep {
|
||||
uint16_t nlocals; /* Number of local variables */
|
||||
uint16_t nregs; /* Number of register variables */
|
||||
uint16_t clen; /* Number of catch handlers */
|
||||
uint8_t flags;
|
||||
|
||||
const mrc_code *iseq;
|
||||
/*
|
||||
* A catch handler table is placed after the iseq entity.
|
||||
* The reason it doesn't add fields to the structure is to keep the mrc_irep structure from bloating.
|
||||
* The catch handler table can be obtained with `mrc_irep_catch_handler_table(irep)`.
|
||||
*/
|
||||
const mrc_pool_value *pool;
|
||||
const mrc_sym *syms;
|
||||
const struct mrc_irep * const *reps;
|
||||
|
||||
mrc_sym *lv; // Remove const for mrc_resolve_intern
|
||||
/* debug info */
|
||||
struct mrc_irep_debug_info* debug_info;
|
||||
|
||||
uint32_t ilen;
|
||||
uint16_t plen, slen;
|
||||
uint16_t rlen;
|
||||
uint16_t refcnt;
|
||||
} mrc_irep;
|
||||
|
||||
#define MRC_ISEQ_NO_FREE 1
|
||||
#define MRC_IREP_NO_FREE 2
|
||||
|
||||
struct mrc_insn_data {
|
||||
uint8_t insn;
|
||||
uint32_t a;
|
||||
uint16_t b;
|
||||
uint16_t cc;
|
||||
const mrc_code *addr;
|
||||
};
|
||||
|
||||
#define mrc_irep_catch_handler_pack(n, v) mrc_uint32_to_bin(n, v)
|
||||
#define mrc_irep_catch_handler_unpack(v) mrc_bin_to_uint32(v)
|
||||
|
||||
void mrc_irep_remove_lv(mrc_ccontext *c, mrc_irep *irep);
|
||||
void mrc_irep_free(mrc_ccontext *c, mrc_irep *irep);
|
||||
|
||||
#define MRC_ASPEC_REQ(a) (((a) >> 18) & 0x1f)
|
||||
#define MRC_ASPEC_OPT(a) (((a) >> 13) & 0x1f)
|
||||
#define MRC_ASPEC_REST(a) (((a) >> 12) & 0x1)
|
||||
#define MRC_ASPEC_POST(a) (((a) >> 7) & 0x1f)
|
||||
#define MRC_ASPEC_KEY(a) (((a) >> 2) & 0x1f)
|
||||
#define MRC_ASPEC_KDICT(a) (((a) >> 1) & 0x1)
|
||||
#define MRC_ASPEC_BLOCK(a) ((a) & 1)
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif /* MRC_IREP_H */
|
||||
17
vendor/mruby-compiler2/include/mrc_irep_pool_type.h
vendored
Normal file
17
vendor/mruby-compiler2/include/mrc_irep_pool_type.h
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef MRB_IREP_POOL_TYPE_H
|
||||
#define MRB_IREP_POOL_TYPE_H
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
enum irep_pool_type {
|
||||
IREP_TT_STR = 0, /* string (need free) */
|
||||
IREP_TT_SSTR = 2, /* string (static) */
|
||||
IREP_TT_INT32 = 1, /* 32bit integer */
|
||||
IREP_TT_INT64 = 3, /* 64bit integer */
|
||||
IREP_TT_BIGINT = 7, /* big integer (not yet supported) */
|
||||
IREP_TT_FLOAT = 5, /* float (double/float) */
|
||||
};
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif
|
||||
69
vendor/mruby-compiler2/include/mrc_opcode.h
vendored
Normal file
69
vendor/mruby-compiler2/include/mrc_opcode.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
** @file mruby/opcode.h - RiteVM operation codes
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRUBY_OPCODE_H
|
||||
#define MRUBY_OPCODE_H
|
||||
|
||||
enum mrb_insn {
|
||||
#define OPCODE(x,_) OP_ ## x,
|
||||
#include "mrc_ops.h"
|
||||
#undef OPCODE
|
||||
};
|
||||
|
||||
#define OP_L_STRICT 1
|
||||
#define OP_L_CAPTURE 2
|
||||
#define OP_L_METHOD OP_L_STRICT
|
||||
#define OP_L_LAMBDA (OP_L_STRICT|OP_L_CAPTURE)
|
||||
#define OP_L_BLOCK OP_L_CAPTURE
|
||||
|
||||
#define PEEK_B(pc) (*(pc))
|
||||
#define PEEK_S(pc) ((pc)[0]<<8|(pc)[1])
|
||||
#define PEEK_W(pc) ((pc)[0]<<16|(pc)[1]<<8|(pc)[2])
|
||||
|
||||
#define READ_B() PEEK_B(pc++)
|
||||
#define READ_S() (pc+=2, PEEK_S(pc-2))
|
||||
#define READ_W() (pc+=3, PEEK_W(pc-3))
|
||||
|
||||
#define FETCH_Z() /* nothing */
|
||||
#define FETCH_B() do {a=READ_B();} while (0)
|
||||
#define FETCH_BB() do {a=READ_B(); b=READ_B();} while (0)
|
||||
#define FETCH_BBB() do {a=READ_B(); b=READ_B(); cc=READ_B();} while (0)
|
||||
#define FETCH_BS() do {a=READ_B(); b=READ_S();} while (0)
|
||||
#define FETCH_BSS() do {a=READ_B(); b=READ_S(); cc=READ_S();} while (0)
|
||||
#define FETCH_S() do {a=READ_S();} while (0)
|
||||
#define FETCH_W() do {a=READ_W();} while (0)
|
||||
|
||||
/* with OP_EXT1 (1st 16bit) */
|
||||
#define FETCH_Z_1() FETCH_Z()
|
||||
#define FETCH_B_1() FETCH_S()
|
||||
#define FETCH_BB_1() do {a=READ_S(); b=READ_B();} while (0)
|
||||
#define FETCH_BBB_1() do {a=READ_S(); b=READ_B(); cc=READ_B();} while (0)
|
||||
#define FETCH_BS_1() do {a=READ_S(); b=READ_S();} while (0)
|
||||
#define FETCH_BSS_1() do {a=READ_S(); b=READ_S();cc=READ_S();} while (0)
|
||||
#define FETCH_S_1() FETCH_S()
|
||||
#define FETCH_W_1() FETCH_W()
|
||||
|
||||
/* with OP_EXT2 (2nd 16bit) */
|
||||
#define FETCH_Z_2() FETCH_Z()
|
||||
#define FETCH_B_2() FETCH_B()
|
||||
#define FETCH_BB_2() do {a=READ_B(); b=READ_S();} while (0)
|
||||
#define FETCH_BBB_2() do {a=READ_B(); b=READ_S(); cc=READ_B();} while (0)
|
||||
#define FETCH_BS_2() FETCH_BS()
|
||||
#define FETCH_BSS_2() FETCH_BSS()
|
||||
#define FETCH_S_2() FETCH_S()
|
||||
#define FETCH_W_2() FETCH_W()
|
||||
|
||||
/* with OP_EXT3 (1st & 2nd 16bit) */
|
||||
#define FETCH_Z_3() FETCH_Z()
|
||||
#define FETCH_B_3() FETCH_B()
|
||||
#define FETCH_BB_3() do {a=READ_S(); b=READ_S();} while (0)
|
||||
#define FETCH_BBB_3() do {a=READ_S(); b=READ_S(); cc=READ_B();} while (0)
|
||||
#define FETCH_BS_3() do {a=READ_S(); b=READ_S();} while (0)
|
||||
#define FETCH_BSS_3() FETCH_BSS_1()
|
||||
#define FETCH_S_3() FETCH_S()
|
||||
#define FETCH_W_3() FETCH_W()
|
||||
|
||||
#endif /* MRUBY_OPCODE_H */
|
||||
120
vendor/mruby-compiler2/include/mrc_ops.h
vendored
Normal file
120
vendor/mruby-compiler2/include/mrc_ops.h
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
/* operand types:
|
||||
+ Z: no operand
|
||||
+ B: 8bit
|
||||
+ BB: 8+8bit
|
||||
+ BBB: 8+8+8bit
|
||||
+ BS: 8+16bit
|
||||
+ BSS: 8+16+16bit
|
||||
+ S: 16bit
|
||||
+ W: 24bit
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
operation code operands semantics
|
||||
------------------------------------------------------------------------*/
|
||||
OPCODE(NOP, Z) /* no operation */
|
||||
OPCODE(MOVE, BB) /* R[a] = R[b] */
|
||||
OPCODE(LOADL, BB) /* R[a] = Pool[b] */
|
||||
OPCODE(LOADI, BB) /* R[a] = mrb_int(b) */
|
||||
OPCODE(LOADINEG, BB) /* R[a] = mrb_int(-b) */
|
||||
OPCODE(LOADI__1, B) /* R[a] = mrb_int(-1) */
|
||||
OPCODE(LOADI_0, B) /* R[a] = mrb_int(0) */
|
||||
OPCODE(LOADI_1, B) /* R[a] = mrb_int(1) */
|
||||
OPCODE(LOADI_2, B) /* R[a] = mrb_int(2) */
|
||||
OPCODE(LOADI_3, B) /* R[a] = mrb_int(3) */
|
||||
OPCODE(LOADI_4, B) /* R[a] = mrb_int(4) */
|
||||
OPCODE(LOADI_5, B) /* R[a] = mrb_int(5) */
|
||||
OPCODE(LOADI_6, B) /* R[a] = mrb_int(6) */
|
||||
OPCODE(LOADI_7, B) /* R[a] = mrb_int(7) */
|
||||
OPCODE(LOADI16, BS) /* R[a] = mrb_int(b) */
|
||||
OPCODE(LOADI32, BSS) /* R[a] = mrb_int((b<<16)+c) */
|
||||
OPCODE(LOADSYM, BB) /* R[a] = Syms[b] */
|
||||
OPCODE(LOADNIL, B) /* R[a] = nil */
|
||||
OPCODE(LOADSELF, B) /* R[a] = self */
|
||||
OPCODE(LOADT, B) /* R[a] = true */
|
||||
OPCODE(LOADF, B) /* R[a] = false */
|
||||
OPCODE(GETGV, BB) /* R[a] = getglobal(Syms[b]) */
|
||||
OPCODE(SETGV, BB) /* setglobal(Syms[b], R[a]) */
|
||||
OPCODE(GETSV, BB) /* R[a] = Special[Syms[b]] */
|
||||
OPCODE(SETSV, BB) /* Special[Syms[b]] = R[a] */
|
||||
OPCODE(GETIV, BB) /* R[a] = ivget(Syms[b]) */
|
||||
OPCODE(SETIV, BB) /* ivset(Syms[b],R[a]) */
|
||||
OPCODE(GETCV, BB) /* R[a] = cvget(Syms[b]) */
|
||||
OPCODE(SETCV, BB) /* cvset(Syms[b],R[a]) */
|
||||
OPCODE(GETCONST, BB) /* R[a] = constget(Syms[b]) */
|
||||
OPCODE(SETCONST, BB) /* constset(Syms[b],R[a]) */
|
||||
OPCODE(GETMCNST, BB) /* R[a] = R[a]::Syms[b] */
|
||||
OPCODE(SETMCNST, BB) /* R[a+1]::Syms[b] = R[a] */
|
||||
OPCODE(GETUPVAR, BBB) /* R[a] = uvget(b,c) */
|
||||
OPCODE(SETUPVAR, BBB) /* uvset(b,c,R[a]) */
|
||||
OPCODE(GETIDX, B) /* R[a] = R[a][R[a+1]] */
|
||||
OPCODE(SETIDX, B) /* R[a][R[a+1]] = R[a+2] */
|
||||
OPCODE(JMP, S) /* pc+=a */
|
||||
OPCODE(JMPIF, BS) /* if R[a] pc+=b */
|
||||
OPCODE(JMPNOT, BS) /* if !R[a] pc+=b */
|
||||
OPCODE(JMPNIL, BS) /* if R[a]==nil pc+=b */
|
||||
OPCODE(JMPUW, S) /* unwind_and_jump_to(a) */
|
||||
OPCODE(EXCEPT, B) /* R[a] = exc */
|
||||
OPCODE(RESCUE, BB) /* R[b] = R[a].isa?(R[b]) */
|
||||
OPCODE(RAISEIF, B) /* raise(R[a]) if R[a] */
|
||||
OPCODE(SSEND, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
|
||||
OPCODE(SSENDB, BBB) /* R[a] = self.send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
|
||||
OPCODE(SEND, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..) (c=n|k<<4) */
|
||||
OPCODE(SENDB, BBB) /* R[a] = R[a].send(Syms[b],R[a+1]..,R[a+n+1]:R[a+n+2]..,&R[a+n+2k+1]) */
|
||||
OPCODE(CALL, Z) /* self.call(*, **, &) (But overlay the current call frame; tailcall) */
|
||||
OPCODE(SUPER, BB) /* R[a] = super(R[a+1],... ,R[a+b+1]) */
|
||||
OPCODE(ARGARY, BS) /* R[a] = argument array (16=m5:r1:m5:d1:lv4) */
|
||||
OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
|
||||
OPCODE(KEY_P, BB) /* R[a] = kdict.key?(Syms[b]) */
|
||||
OPCODE(KEYEND, Z) /* raise unless kdict.empty? */
|
||||
OPCODE(KARG, BB) /* R[a] = kdict[Syms[b]]; kdict.delete(Syms[b]) */
|
||||
OPCODE(RETURN, B) /* return R[a] (normal) */
|
||||
OPCODE(RETURN_BLK, B) /* return R[a] (in-block return) */
|
||||
OPCODE(BREAK, B) /* break R[a] */
|
||||
OPCODE(BLKPUSH, BS) /* R[a] = block (16=m5:r1:m5:d1:lv4) */
|
||||
OPCODE(ADD, B) /* R[a] = R[a]+R[a+1] */
|
||||
OPCODE(ADDI, BB) /* R[a] = R[a]+mrb_int(b) */
|
||||
OPCODE(SUB, B) /* R[a] = R[a]-R[a+1] */
|
||||
OPCODE(SUBI, BB) /* R[a] = R[a]-mrb_int(b) */
|
||||
OPCODE(MUL, B) /* R[a] = R[a]*R[a+1] */
|
||||
OPCODE(DIV, B) /* R[a] = R[a]/R[a+1] */
|
||||
OPCODE(EQ, B) /* R[a] = R[a]==R[a+1] */
|
||||
OPCODE(LT, B) /* R[a] = R[a]<R[a+1] */
|
||||
OPCODE(LE, B) /* R[a] = R[a]<=R[a+1] */
|
||||
OPCODE(GT, B) /* R[a] = R[a]>R[a+1] */
|
||||
OPCODE(GE, B) /* R[a] = R[a]>=R[a+1] */
|
||||
OPCODE(ARRAY, BB) /* R[a] = ary_new(R[a],R[a+1]..R[a+b]) */
|
||||
OPCODE(ARRAY2, BBB) /* R[a] = ary_new(R[b],R[b+1]..R[b+c]) */
|
||||
OPCODE(ARYCAT, B) /* ary_cat(R[a],R[a+1]) */
|
||||
OPCODE(ARYPUSH, BB) /* ary_push(R[a],R[a+1]..R[a+b]) */
|
||||
OPCODE(ARYSPLAT, B) /* R[a] = ary_splat(R[a]) */
|
||||
OPCODE(AREF, BBB) /* R[a] = R[b][c] */
|
||||
OPCODE(ASET, BBB) /* R[b][c] = R[a] */
|
||||
OPCODE(APOST, BBB) /* *R[a],R[a+1]..R[a+c] = R[a][b..] */
|
||||
OPCODE(INTERN, B) /* R[a] = intern(R[a]) */
|
||||
OPCODE(SYMBOL, BB) /* R[a] = intern(Pool[b]) */
|
||||
OPCODE(STRING, BB) /* R[a] = str_dup(Pool[b]) */
|
||||
OPCODE(STRCAT, B) /* str_cat(R[a],R[a+1]) */
|
||||
OPCODE(HASH, BB) /* R[a] = hash_new(R[a],R[a+1]..R[a+b*2-1]) */
|
||||
OPCODE(HASHADD, BB) /* hash_push(R[a],R[a+1]..R[a+b*2]) */
|
||||
OPCODE(HASHCAT, B) /* R[a] = hash_cat(R[a],R[a+1]) */
|
||||
OPCODE(LAMBDA, BB) /* R[a] = lambda(Irep[b],L_LAMBDA) */
|
||||
OPCODE(BLOCK, BB) /* R[a] = lambda(Irep[b],L_BLOCK) */
|
||||
OPCODE(METHOD, BB) /* R[a] = lambda(Irep[b],L_METHOD) */
|
||||
OPCODE(RANGE_INC, B) /* R[a] = range_new(R[a],R[a+1],FALSE) */
|
||||
OPCODE(RANGE_EXC, B) /* R[a] = range_new(R[a],R[a+1],TRUE) */
|
||||
OPCODE(OCLASS, B) /* R[a] = ::Object */
|
||||
OPCODE(CLASS, BB) /* R[a] = newclass(R[a],Syms[b],R[a+1]) */
|
||||
OPCODE(MODULE, BB) /* R[a] = newmodule(R[a],Syms[b]) */
|
||||
OPCODE(EXEC, BB) /* R[a] = blockexec(R[a],Irep[b]) */
|
||||
OPCODE(DEF, BB) /* R[a].newmethod(Syms[b],R[a+1]); R[a] = Syms[b] */
|
||||
OPCODE(ALIAS, BB) /* alias_method(target_class,Syms[a],Syms[b]) */
|
||||
OPCODE(UNDEF, B) /* undef_method(target_class,Syms[a]) */
|
||||
OPCODE(SCLASS, B) /* R[a] = R[a].singleton_class */
|
||||
OPCODE(TCLASS, B) /* R[a] = target_class */
|
||||
OPCODE(DEBUG, BBB) /* print a,b,c */
|
||||
OPCODE(ERR, B) /* raise(LocalJumpError, Pool[a]) */
|
||||
OPCODE(EXT1, Z) /* make 1st operand (a) 16bit */
|
||||
OPCODE(EXT2, Z) /* make 2nd operand (b) 16bit */
|
||||
OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
|
||||
OPCODE(STOP, Z) /* stop VM */
|
||||
12
vendor/mruby-compiler2/include/mrc_parser_util.h
vendored
Normal file
12
vendor/mruby-compiler2/include/mrc_parser_util.h
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef MRC_PARSER_UTIL_H
|
||||
#define MRC_PARSER_UTIL_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
const char* mrc_sym_name_len(mrc_ccontext *c, mrc_sym sym, mrc_int *lenp);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_PARSER_UTIL_H
|
||||
23
vendor/mruby-compiler2/include/mrc_pool.h
vendored
Normal file
23
vendor/mruby-compiler2/include/mrc_pool.h
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef MRC_POOL_H
|
||||
#define MRC_POOL_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "mrc_ccontext.h"
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
typedef struct mrc_pool {
|
||||
struct mrc_ccontext *c;
|
||||
struct mrc_pool_page *pages;
|
||||
} mrc_pool;
|
||||
|
||||
|
||||
MRC_API mrc_pool *mrc_pool_open(struct mrc_ccontext *c);
|
||||
MRC_API void mrc_pool_close(mrc_pool *pool);
|
||||
MRC_API void *mrc_pool_alloc(mrc_pool *pool, size_t len);
|
||||
MRC_API void *mrc_pool_realloc(mrc_pool *pool, void *p, size_t oldlen, size_t newlen);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_POOL_H
|
||||
|
||||
26
vendor/mruby-compiler2/include/mrc_presym.h
vendored
Normal file
26
vendor/mruby-compiler2/include/mrc_presym.h
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef MRC_PRESYM_H
|
||||
#define MRC_PRESYM_H
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
enum mrc_opsym {
|
||||
#define MRC_OPSYM_2(name, lit, num) MRC_OPSYM_2__##name = num,
|
||||
#define MRC_SYM_1(name, num) MRC_SYM_1__##name = num,
|
||||
#define MRC_SYM_2(name, lit, num) MRC_SYM_2__##name = num,
|
||||
#include "mrc_presym.inc"
|
||||
#undef MRC_OPSYM_2
|
||||
#undef MRC_SYM_1
|
||||
#undef MRC_SYM_2
|
||||
};
|
||||
|
||||
#define MRC_OPSYM_2(name) mrc_sym_offset(MRC_OPSYM_2__##name)
|
||||
#define MRC_SYM_1(name) mrc_sym_offset(MRC_SYM_1__##name)
|
||||
#define MRC_SYM_2(name) mrc_sym_offset(MRC_SYM_2__##name)
|
||||
|
||||
void mrc_init_presym(pm_constant_pool_t *pool);
|
||||
mrc_sym mrc_sym_offset(mrc_sym sym);
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_PRESYM_H
|
||||
|
||||
33
vendor/mruby-compiler2/include/mrc_presym.inc
vendored
Normal file
33
vendor/mruby-compiler2/include/mrc_presym.inc
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
MRC_OPSYM_2(aref, [], 1)
|
||||
MRC_OPSYM_2(lshift, <<, 2)
|
||||
MRC_OPSYM_2(rshift, >>, 3)
|
||||
MRC_OPSYM_2(mod, %, 4)
|
||||
MRC_OPSYM_2(and, &, 5)
|
||||
MRC_OPSYM_2(or, |, 6)
|
||||
MRC_OPSYM_2(xor, ^, 7)
|
||||
MRC_OPSYM_2(neg, ~, 8)
|
||||
MRC_OPSYM_2(pow, **, 9)
|
||||
MRC_OPSYM_2(add, +, 10)
|
||||
MRC_OPSYM_2(sub, -, 11)
|
||||
MRC_OPSYM_2(mul, *, 12)
|
||||
MRC_OPSYM_2(div, /, 13)
|
||||
MRC_OPSYM_2(lt, <, 14)
|
||||
MRC_OPSYM_2(le, <=, 15)
|
||||
MRC_OPSYM_2(gt, >, 16)
|
||||
MRC_OPSYM_2(ge, >=, 17)
|
||||
MRC_OPSYM_2(eq, ==, 18)
|
||||
MRC_OPSYM_2(aset, []=, 19)
|
||||
MRC_OPSYM_2(eqq, ===, 20)
|
||||
MRC_OPSYM_2(tick, `, 21)
|
||||
MRC_SYM_1(each, 22)
|
||||
MRC_SYM_1(__case_eqq, 23)
|
||||
MRC_SYM_1(StandardError, 24)
|
||||
MRC_SYM_1(call, 25)
|
||||
MRC_SYM_1(Kernel, 26)
|
||||
MRC_SYM_1(Regexp, 27)
|
||||
MRC_SYM_1(compile, 28)
|
||||
MRC_SYM_1(__ENCODING__, 29)
|
||||
MRC_SYM_2(nil_p, nil?,30)
|
||||
MRC_SYM_2(back_ref, $+, 31)
|
||||
MRC_SYM_2(defined_p, defined?, 32)
|
||||
30
vendor/mruby-compiler2/include/mrc_proc.h
vendored
Normal file
30
vendor/mruby-compiler2/include/mrc_proc.h
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef MRC_PROC_H
|
||||
#define MRC_PROC_H
|
||||
|
||||
MRC_BEGIN_DECL
|
||||
|
||||
#define MRC_OBJECT_HEADER \
|
||||
struct RClass *c; \
|
||||
struct RBasic *gcnext; \
|
||||
enum mrb_vtype tt:8; \
|
||||
unsigned int gc_color:3; \
|
||||
unsigned int frozen:1; \
|
||||
uint32_t flags:20
|
||||
|
||||
struct RProc {
|
||||
MRC_OBJECT_HEADER;
|
||||
union {
|
||||
const mrc_irep *irep;
|
||||
mrb_func_t func;
|
||||
mrb_sym mid;
|
||||
} body;
|
||||
const struct RProc *upper;
|
||||
union {
|
||||
struct RClass *target_class;
|
||||
struct REnv *env;
|
||||
} e;
|
||||
};
|
||||
|
||||
MRC_END_DECL
|
||||
|
||||
#endif // MRC_PROC_H
|
||||
57
vendor/mruby-compiler2/include/mrc_throw.h
vendored
Normal file
57
vendor/mruby-compiler2/include/mrc_throw.h
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
** @file mruby/throw.h - mruby exception throwing handler
|
||||
**
|
||||
** See Copyright Notice in mruby.h
|
||||
*/
|
||||
|
||||
#ifndef MRC_THROW_H
|
||||
#define MRC_THROW_H
|
||||
|
||||
#if defined(MRC_USE_CXX_ABI) && !defined(__cplusplus)
|
||||
# error Trying to use C++ exception handling in C code
|
||||
#endif
|
||||
|
||||
#if defined(MRC_USE_CXX_EXCEPTION)
|
||||
|
||||
# if defined(__cplusplus)
|
||||
|
||||
#define MRC_TRY(buf) try {
|
||||
#define MRC_CATCH(buf) } catch(mrc_jmpbuf *e) { if (e != (buf)) { throw e; }
|
||||
#define MRC_END_EXC(buf) }
|
||||
|
||||
#define MRC_THROW(buf) throw(buf)
|
||||
typedef void *mrc_jmpbuf_impl;
|
||||
|
||||
# else
|
||||
# error "need to be compiled with C++ compiler"
|
||||
# endif /* __cplusplus */
|
||||
|
||||
#else
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#define MRC_SETJMP _setjmp
|
||||
#define MRC_LONGJMP _longjmp
|
||||
#elif defined(__MINGW64__) && defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define MRC_SETJMP __builtin_setjmp
|
||||
#define MRC_LONGJMP __builtin_longjmp
|
||||
#else
|
||||
#define MRC_SETJMP setjmp
|
||||
#define MRC_LONGJMP longjmp
|
||||
#endif
|
||||
|
||||
#define MRC_TRY(buf) if (MRC_SETJMP((buf)->impl) == 0) {
|
||||
#define MRC_CATCH(buf) } else {
|
||||
#define MRC_END_EXC(buf) }
|
||||
|
||||
#define MRC_THROW(buf) MRC_LONGJMP((buf)->impl, 1);
|
||||
#define mrc_jmpbuf_impl jmp_buf
|
||||
|
||||
#endif
|
||||
|
||||
struct mrc_jmpbuf {
|
||||
mrc_jmpbuf_impl impl;
|
||||
};
|
||||
|
||||
#endif /* MRC_THROW_H */
|
||||
9
vendor/mruby-compiler2/include/mruby_compiler.h
vendored
Normal file
9
vendor/mruby-compiler2/include/mruby_compiler.h
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef MRUBY_COMPILER_H
|
||||
#define MRUBY_COMPILER_H
|
||||
|
||||
#include "mrc_ccontext.h"
|
||||
#include "mrc_irep.h"
|
||||
#include "mrc_compile.h"
|
||||
#include "mrc_dump.h"
|
||||
|
||||
#endif // MRUBY_COMPILER_H
|
||||
73
vendor/mruby-compiler2/include/prism_xallocator.h
vendored
Normal file
73
vendor/mruby-compiler2/include/prism_xallocator.h
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef PRISM_CUSTOM_ALLOCATOR_H
|
||||
#define PRISM_CUSTOM_ALLOCATOR_H
|
||||
|
||||
#if defined(MRC_TARGET_MRUBY)
|
||||
#include "mruby.h"
|
||||
extern mrb_state *global_mrb;
|
||||
|
||||
#define xmalloc(size) mrb_malloc(global_mrb, size)
|
||||
#define xcalloc(nmemb,size) mrb_calloc(global_mrb, nmemb, size)
|
||||
#define xrealloc(ptr,size) mrb_realloc(global_mrb, ptr, size)
|
||||
#define xfree(ptr) mrb_free(global_mrb, ptr)
|
||||
|
||||
#define mrc_malloc(c,size) mrb_malloc(c->mrb, size)
|
||||
#define mrc_calloc(c,nmemb,size) mrb_calloc(c->mrb, nmemb, size)
|
||||
#define mrc_realloc(c,ptr,size) mrb_realloc(c->mrb, ptr, size)
|
||||
#define mrc_free(c,ptr) mrb_free(c->mrb, ptr)
|
||||
#elif defined(MRC_TARGET_MRUBYC)
|
||||
#include "mrubyc.h"
|
||||
#if defined(MRBC_ALLOC_LIBC)
|
||||
#define xmalloc(size) malloc(size)
|
||||
#define xcalloc(nmemb,size) calloc(nmemb, size)
|
||||
#define xrealloc(nmemb,size) realloc(nmemb, size)
|
||||
#define xfree(ptr) free(ptr)
|
||||
|
||||
#define mrc_malloc(c,size) malloc(size)
|
||||
#define mrc_calloc(c,nmemb,size) calloc(nmemb, size)
|
||||
#define mrc_realloc(c,ptr,size) realloc(ptr, size)
|
||||
#define mrc_free(c,ptr) free(ptr)
|
||||
#else
|
||||
#define xmalloc(size) mrbc_raw_alloc(size)
|
||||
#define xcalloc(nmemb,size) mrbc_raw_calloc(nmemb, size)
|
||||
#define xrealloc(nmemb,size) mrc_raw_realloc(nmemb, size)
|
||||
#define xfree(ptr) mrc_raw_free(ptr)
|
||||
|
||||
#define mrc_malloc(c,size) mrbc_raw_alloc(size)
|
||||
#define mrc_calloc(c,nmemb,size) mrbc_raw_calloc(nmemb, size)
|
||||
#define mrc_realloc(c,ptr,size) mrc_raw_realloc(ptr, size)
|
||||
#define mrc_free(c,ptr) mrc_raw_free(ptr)
|
||||
|
||||
static inline void mrc_raw_free(void *ptr)
|
||||
{
|
||||
/* mrbc_raw_free() warns when ptr=NULL but it should be allowed in C99 */
|
||||
if (ptr == NULL) return;
|
||||
mrbc_raw_free(ptr);
|
||||
}
|
||||
|
||||
static inline void*
|
||||
mrc_raw_realloc(void *ptr, unsigned int size)
|
||||
{
|
||||
/* mrbc_raw_realloc() fails when ptr=NULL but it should be allowed in C99 */
|
||||
if (ptr == NULL) {
|
||||
return mrbc_raw_alloc(size);
|
||||
} else {
|
||||
return mrbc_raw_realloc(ptr, size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
||||
// for picorbc
|
||||
#define mrc_malloc(c,size) malloc(size)
|
||||
#define mrc_calloc(c,nmemb,size) calloc(nmemb, size)
|
||||
#define mrc_realloc(c,ptr,size) realloc(ptr, size)
|
||||
#define mrc_free(c,ptr) free(ptr)
|
||||
#define xmalloc(size) malloc(size)
|
||||
#define xcalloc(nmemb,size) calloc(nmemb, size)
|
||||
#define xrealloc(ptr,size) realloc(ptr, size)
|
||||
#define xfree(ptr) free(ptr)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user