mruby/c VM Source Code release 3.4
Loading...
Searching...
No Matches
load.c File Reference

mruby bytecode loader. More...

#include "mrubyc.h"
Include dependency graph for load.c:

Go to the source code of this file.

Enumerations

enum  irep_pool_type {
  IREP_TT_STR = 0 , IREP_TT_SSTR = 2 , IREP_TT_INT32 = 1 , IREP_TT_INT64 = 3 ,
  IREP_TT_FLOAT = 5
}

Functions

static int load_header (struct VM *vm, const uint8_t *bin)
static mrbc_irepload_irep_1 (struct VM *vm, const uint8_t *bin, int *len)
static mrbc_irepload_irep (struct VM *vm, const uint8_t *bin, int *len)
int mrbc_load_mrb (struct VM *vm, const void *bytecode)
int mrbc_load_irep (struct VM *vm, const void *bytecode)
void mrbc_irep_free (struct IREP *irep)
mrbc_value mrbc_irep_pool_value (struct VM *vm, int n)

Variables

static const char RITE [4] = "RITE"
static const char RITE_VERSION [4] = "0300"
static const int SIZE_RITE_BINARY_HEADER = 20
static const int SIZE_RITE_SECTION_HEADER = 12
static const int SIZE_RITE_CATCH_HANDLER = 13
static const char IREP [4] = "IREP"
static const char END [4] = "END\0"

Detailed Description

mruby bytecode loader.

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 load.c.

Enumeration Type Documentation

◆ irep_pool_type

IREP TT

Enumerator
IREP_TT_STR 
IREP_TT_SSTR 
IREP_TT_INT32 
IREP_TT_INT64 
IREP_TT_FLOAT 

Definition at line 39 of file load.c.

Function Documentation

◆ load_header()

int load_header ( struct VM * vm,
const uint8_t * bin )
static

Parse header section.

Parameters
vmA pointer to VM.
binA pointer to RITE header.
Returns
int zero if no error.
Structure
 "RITE"     identifier
 "03"       major version
 "00"       minor version
 0000_0000  total size
 "MATZ"     compiler name
 "0000"     compiler version

Definition at line 73 of file load.c.

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

◆ load_irep()

mrbc_irep * load_irep ( struct VM * vm,
const uint8_t * bin,
int * len )
static

Load IREP section.

Parameters
vmA pointer to VM.
binA pointer to RITE ISEQ.
lenReturns the parsed length.
Returns
Pointer to allocated mrbc_irep or NULL

Definition at line 263 of file load.c.

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

◆ load_irep_1()

mrbc_irep * load_irep_1 ( struct VM * vm,
const uint8_t * bin,
int * len )
static

read one irep section.

Parameters
vmA pointer to VM.
binA pointer to RITE ISEQ.
lenReturns the parsed length.
Returns
Pointer to allocated mrbc_irep or NULL
 (loop n of child irep below)
 0000_0000      record size
 0000           n of local variable
 0000           n of register
 0000           n of child irep
 0000           n of catch handler
 0000_0000      n of byte code  (ISEQ BLOCK)
 ...            byte codes

 (CATCH HANDLER 13bytes)
 00             type
 0000_0000      begin
 0000_0000      end
 0000_0000      target

 (POOL BLOCK)
 0000           n of pool
 (loop n of pool)
   00           type
   ...  pool data

 (SYMS BLOCK)
 0000           n of symbol
 (loop n of symbol)
   0000 length
   ...  symbol data

Definition at line 129 of file load.c.

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

◆ mrbc_irep_free()

void mrbc_irep_free ( struct IREP * irep)

release mrbc_irep holds memory

Parameters
irepPointer to allocated mrbc_irep.

Definition at line 340 of file load.c.

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

◆ mrbc_irep_pool_value()

mrbc_value mrbc_irep_pool_value ( struct VM * vm,
int n )

get a mrbc_value in irep pool.

Parameters
vmPointer to VM.
nn'th
Returns
mrbc_value value

Definition at line 360 of file load.c.

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

◆ mrbc_load_irep()

int mrbc_load_irep ( struct VM * vm,
const void * bytecode )

Load the IREP section.

Parameters
vmPointer to VM.
bytecodePointer to IREP section.
Returns
int zero if no error.

Definition at line 324 of file load.c.

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

◆ mrbc_load_mrb()

int mrbc_load_mrb ( struct VM * vm,
const void * bytecode )

Load the VM bytecode. (full .mrb file)

Parameters
vmPointer to VM.
bytecodePointer to bytecode.
Returns
int zero if no error.

Definition at line 292 of file load.c.

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

Variable Documentation

◆ END

const char END[4] = "END\0"
static

Definition at line 35 of file load.c.

◆ IREP

const char IREP[4] = "IREP"
static

Definition at line 34 of file load.c.

◆ RITE

const char RITE[4] = "RITE"
static

Definition at line 29 of file load.c.

◆ RITE_VERSION

const char RITE_VERSION[4] = "0300"
static

Definition at line 30 of file load.c.

◆ SIZE_RITE_BINARY_HEADER

const int SIZE_RITE_BINARY_HEADER = 20
static

Definition at line 31 of file load.c.

◆ SIZE_RITE_CATCH_HANDLER

const int SIZE_RITE_CATCH_HANDLER = 13
static

Definition at line 33 of file load.c.

◆ SIZE_RITE_SECTION_HEADER

const int SIZE_RITE_SECTION_HEADER = 12
static

Definition at line 32 of file load.c.