w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

proc.h File Reference
#include "common.h"
#include <mruby/irep.h>
#include <mruby/khash.h>
Include dependency graph for proc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  REnv
 
struct  RProc
 

Macros

#define MRB_ENV_SET_LEN(e, len)   ((e)->flags = (((e)->flags & ~0xff)|((unsigned int)(len) & 0xff)))
 
#define MRB_ENV_LEN(e)   ((mrb_int)((e)->flags & 0xff))
 
#define MRB_ENV_CLOSED   (1<<20)
 
#define MRB_ENV_TOUCHED   (1<<19)
 
#define MRB_ENV_HEAPED   (1<<18)
 
#define MRB_ENV_CLOSE(e)   ((e)->flags |= MRB_ENV_CLOSED)
 
#define MRB_ENV_TOUCH(e)   ((e)->flags |= MRB_ENV_TOUCHED)
 
#define MRB_ENV_HEAP(e)   ((e)->flags |= MRB_ENV_HEAPED)
 
#define MRB_ENV_HEAP_P(e)   ((e)->flags & MRB_ENV_HEAPED)
 
#define MRB_ENV_ONSTACK_P(e)   (((e)->flags & MRB_ENV_CLOSED) == 0)
 
#define MRB_ENV_BIDX(e)   (((e)->flags >> 8) & 0xff)
 
#define MRB_ENV_SET_BIDX(e, idx)   ((e)->flags = (((e)->flags & ~(0xff<<8))|((unsigned int)(idx) & 0xff)<<8))
 
#define MRB_ASPEC_REQ(a)   (((a) >> 18) & 0x1f)
 
#define MRB_ASPEC_OPT(a)   (((a) >> 13) & 0x1f)
 
#define MRB_ASPEC_REST(a)   (((a) >> 12) & 0x1)
 
#define MRB_ASPEC_POST(a)   (((a) >> 7) & 0x1f)
 
#define MRB_ASPEC_KEY(a)   (((a) >> 2) & 0x1f)
 
#define MRB_ASPEC_KDICT(a)   (((a) >> 1) & 0x1)
 
#define MRB_ASPEC_BLOCK(a)   ((a) & 1)
 
#define MRB_PROC_CFUNC_FL   128
 
#define MRB_PROC_CFUNC_P(p)   (((p)->flags & MRB_PROC_CFUNC_FL) != 0)
 
#define MRB_PROC_CFUNC(p)   (p)->body.func
 
#define MRB_PROC_STRICT   256
 
#define MRB_PROC_STRICT_P(p)   (((p)->flags & MRB_PROC_STRICT) != 0)
 
#define MRB_PROC_ORPHAN   512
 
#define MRB_PROC_ORPHAN_P(p)   (((p)->flags & MRB_PROC_ORPHAN) != 0)
 
#define MRB_PROC_ENVSET   1024
 
#define MRB_PROC_ENV_P(p)   (((p)->flags & MRB_PROC_ENVSET) != 0)
 
#define MRB_PROC_ENV(p)   (MRB_PROC_ENV_P(p) ? (p)->e.env : NULL)
 
#define MRB_PROC_TARGET_CLASS(p)   (MRB_PROC_ENV_P(p) ? (p)->e.env->c : (p)->e.target_class)
 
#define MRB_PROC_SET_TARGET_CLASS(p, tc)
 
#define MRB_PROC_SCOPE   2048
 
#define MRB_PROC_SCOPE_P(p)   (((p)->flags & MRB_PROC_SCOPE) != 0)
 
#define mrb_proc_ptr(v)   ((struct RProc*)(mrb_ptr(v)))
 
#define mrb_cfunc_env_get(mrb, idx)   mrb_proc_cfunc_env_get(mrb, idx)
 
#define MRB_METHOD_FUNC_FL   1
 
#define MRB_METHOD_NOARG_FL   2
 
#define MRB_METHOD_FUNC_P(m)   (((uintptr_t)(m))&MRB_METHOD_FUNC_FL)
 
#define MRB_METHOD_NOARG_P(m)   ((((uintptr_t)(m))&MRB_METHOD_NOARG_FL)?1:0)
 
#define MRB_METHOD_NOARG_SET(m)   ((m)=(mrb_method_t)(((uintptr_t)(m))|MRB_METHOD_NOARG_FL))
 
#define MRB_METHOD_FUNC(m)   ((mrb_func_t)((uintptr_t)(m)>>2))
 
#define MRB_METHOD_FROM_FUNC(m, fn)   ((m)=(mrb_method_t)((((uintptr_t)(fn))<<2)|MRB_METHOD_FUNC_FL))
 
#define MRB_METHOD_FROM_PROC(m, pr)   ((m)=(mrb_method_t)(pr))
 
#define MRB_METHOD_PROC_P(m)   (!MRB_METHOD_FUNC_P(m))
 
#define MRB_METHOD_PROC(m)   ((struct RProc*)(m))
 
#define MRB_METHOD_UNDEF_P(m)   ((m)==0)
 
#define MRB_METHOD_CFUNC_P(m)   (MRB_METHOD_FUNC_P(m)?TRUE:(MRB_METHOD_PROC(m)?(MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m))):FALSE))
 
#define MRB_METHOD_CFUNC(m)   (MRB_METHOD_FUNC_P(m)?MRB_METHOD_FUNC(m):((MRB_METHOD_PROC(m)&&MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m)))?MRB_PROC_CFUNC(MRB_METHOD_PROC(m)):NULL))
 

Functions

void mrb_env_unshare (mrb_state *, struct REnv *)
 
struct RProcmrb_proc_new (mrb_state *, const mrb_irep *)
 
struct RProcmrb_closure_new (mrb_state *, const mrb_irep *)
 
struct RProcmrb_proc_new_cfunc (mrb_state *, mrb_func_t)
 
struct RProcmrb_closure_new_cfunc (mrb_state *mrb, mrb_func_t func, int nlocals)
 
void mrb_proc_copy (struct RProc *a, struct RProc *b)
 
mrb_int mrb_proc_arity (const struct RProc *p)
 
struct RProcmrb_proc_new_cfunc_with_env (mrb_state *mrb, mrb_func_t func, mrb_int argc, const mrb_value *argv)
 
mrb_value mrb_proc_cfunc_env_get (mrb_state *mrb, mrb_int idx)
 
mrb_value mrb_load_proc (mrb_state *mrb, const struct RProc *proc)
 
static void mrb_vm_ci_proc_set (mrb_callinfo *ci, const struct RProc *p)
 
static struct RClassmrb_vm_ci_target_class (const mrb_callinfo *ci)
 
static void mrb_vm_ci_target_class_set (mrb_callinfo *ci, struct RClass *tc)
 
static struct REnvmrb_vm_ci_env (const mrb_callinfo *ci)
 
static void mrb_vm_ci_env_set (mrb_callinfo *ci, struct REnv *e)
 

Detailed Description

  • Proc class

See Copyright Notice in mruby.h

Definition in file proc.h.

Macro Definition Documentation

◆ MRB_ASPEC_BLOCK

#define MRB_ASPEC_BLOCK (   a)    ((a) & 1)

Definition at line 61 of file proc.h.

◆ MRB_ASPEC_KDICT

#define MRB_ASPEC_KDICT (   a)    (((a) >> 1) & 0x1)

Definition at line 60 of file proc.h.

◆ MRB_ASPEC_KEY

#define MRB_ASPEC_KEY (   a)    (((a) >> 2) & 0x1f)

Definition at line 59 of file proc.h.

◆ MRB_ASPEC_OPT

#define MRB_ASPEC_OPT (   a)    (((a) >> 13) & 0x1f)

Definition at line 56 of file proc.h.

◆ MRB_ASPEC_POST

#define MRB_ASPEC_POST (   a)    (((a) >> 7) & 0x1f)

Definition at line 58 of file proc.h.

◆ MRB_ASPEC_REQ

#define MRB_ASPEC_REQ (   a)    (((a) >> 18) & 0x1f)

Definition at line 55 of file proc.h.

◆ MRB_ASPEC_REST

#define MRB_ASPEC_REST (   a)    (((a) >> 12) & 0x1)

Definition at line 57 of file proc.h.

◆ mrb_cfunc_env_get

#define mrb_cfunc_env_get (   mrb,
  idx 
)    mrb_proc_cfunc_env_get(mrb, idx)

Definition at line 100 of file proc.h.

◆ MRB_ENV_BIDX

#define MRB_ENV_BIDX (   e)    (((e)->flags >> 8) & 0xff)

Definition at line 36 of file proc.h.

◆ MRB_ENV_CLOSE

#define MRB_ENV_CLOSE (   e)    ((e)->flags |= MRB_ENV_CLOSED)

Definition at line 31 of file proc.h.

◆ MRB_ENV_CLOSED

#define MRB_ENV_CLOSED   (1<<20)

Definition at line 28 of file proc.h.

◆ MRB_ENV_HEAP

#define MRB_ENV_HEAP (   e)    ((e)->flags |= MRB_ENV_HEAPED)

Definition at line 33 of file proc.h.

◆ MRB_ENV_HEAP_P

#define MRB_ENV_HEAP_P (   e)    ((e)->flags & MRB_ENV_HEAPED)

Definition at line 34 of file proc.h.

◆ MRB_ENV_HEAPED

#define MRB_ENV_HEAPED   (1<<18)

Definition at line 30 of file proc.h.

◆ MRB_ENV_LEN

#define MRB_ENV_LEN (   e)    ((mrb_int)((e)->flags & 0xff))

Definition at line 27 of file proc.h.

◆ MRB_ENV_ONSTACK_P

#define MRB_ENV_ONSTACK_P (   e)    (((e)->flags & MRB_ENV_CLOSED) == 0)

Definition at line 35 of file proc.h.

◆ MRB_ENV_SET_BIDX

#define MRB_ENV_SET_BIDX (   e,
  idx 
)    ((e)->flags = (((e)->flags & ~(0xff<<8))|((unsigned int)(idx) & 0xff)<<8))

Definition at line 37 of file proc.h.

◆ MRB_ENV_SET_LEN

#define MRB_ENV_SET_LEN (   e,
  len 
)    ((e)->flags = (((e)->flags & ~0xff)|((unsigned int)(len) & 0xff)))

Definition at line 26 of file proc.h.

◆ MRB_ENV_TOUCH

#define MRB_ENV_TOUCH (   e)    ((e)->flags |= MRB_ENV_TOUCHED)

Definition at line 32 of file proc.h.

◆ MRB_ENV_TOUCHED

#define MRB_ENV_TOUCHED   (1<<19)

Definition at line 29 of file proc.h.

◆ MRB_METHOD_CFUNC

Definition at line 132 of file proc.h.

◆ MRB_METHOD_CFUNC_P

#define MRB_METHOD_CFUNC_P (   m)    (MRB_METHOD_FUNC_P(m)?TRUE:(MRB_METHOD_PROC(m)?(MRB_PROC_CFUNC_P(MRB_METHOD_PROC(m))):FALSE))

Definition at line 131 of file proc.h.

◆ MRB_METHOD_FROM_FUNC

#define MRB_METHOD_FROM_FUNC (   m,
  fn 
)    ((m)=(mrb_method_t)((((uintptr_t)(fn))<<2)|MRB_METHOD_FUNC_FL))

Definition at line 111 of file proc.h.

◆ MRB_METHOD_FROM_PROC

#define MRB_METHOD_FROM_PROC (   m,
  pr 
)    ((m)=(mrb_method_t)(pr))

Definition at line 112 of file proc.h.

◆ MRB_METHOD_FUNC

#define MRB_METHOD_FUNC (   m)    ((mrb_func_t)((uintptr_t)(m)>>2))

Definition at line 110 of file proc.h.

◆ MRB_METHOD_FUNC_FL

#define MRB_METHOD_FUNC_FL   1

Definition at line 102 of file proc.h.

◆ MRB_METHOD_FUNC_P

#define MRB_METHOD_FUNC_P (   m)    (((uintptr_t)(m))&MRB_METHOD_FUNC_FL)

Definition at line 107 of file proc.h.

◆ MRB_METHOD_NOARG_FL

#define MRB_METHOD_NOARG_FL   2

Definition at line 103 of file proc.h.

◆ MRB_METHOD_NOARG_P

#define MRB_METHOD_NOARG_P (   m)    ((((uintptr_t)(m))&MRB_METHOD_NOARG_FL)?1:0)

Definition at line 108 of file proc.h.

◆ MRB_METHOD_NOARG_SET

#define MRB_METHOD_NOARG_SET (   m)    ((m)=(mrb_method_t)(((uintptr_t)(m))|MRB_METHOD_NOARG_FL))

Definition at line 109 of file proc.h.

◆ MRB_METHOD_PROC

#define MRB_METHOD_PROC (   m)    ((struct RProc*)(m))

Definition at line 114 of file proc.h.

◆ MRB_METHOD_PROC_P

#define MRB_METHOD_PROC_P (   m)    (!MRB_METHOD_FUNC_P(m))

Definition at line 113 of file proc.h.

◆ MRB_METHOD_UNDEF_P

#define MRB_METHOD_UNDEF_P (   m)    ((m)==0)

Definition at line 115 of file proc.h.

◆ MRB_PROC_CFUNC

#define MRB_PROC_CFUNC (   p)    (p)->body.func

Definition at line 65 of file proc.h.

◆ MRB_PROC_CFUNC_FL

#define MRB_PROC_CFUNC_FL   128

Definition at line 63 of file proc.h.

◆ MRB_PROC_CFUNC_P

#define MRB_PROC_CFUNC_P (   p)    (((p)->flags & MRB_PROC_CFUNC_FL) != 0)

Definition at line 64 of file proc.h.

◆ MRB_PROC_ENV

#define MRB_PROC_ENV (   p)    (MRB_PROC_ENV_P(p) ? (p)->e.env : NULL)

Definition at line 72 of file proc.h.

◆ MRB_PROC_ENV_P

#define MRB_PROC_ENV_P (   p)    (((p)->flags & MRB_PROC_ENVSET) != 0)

Definition at line 71 of file proc.h.

◆ MRB_PROC_ENVSET

#define MRB_PROC_ENVSET   1024

Definition at line 70 of file proc.h.

◆ MRB_PROC_ORPHAN

#define MRB_PROC_ORPHAN   512

Definition at line 68 of file proc.h.

◆ MRB_PROC_ORPHAN_P

#define MRB_PROC_ORPHAN_P (   p)    (((p)->flags & MRB_PROC_ORPHAN) != 0)

Definition at line 69 of file proc.h.

◆ mrb_proc_ptr

#define mrb_proc_ptr (   v)    ((struct RProc*)(mrb_ptr(v)))

Definition at line 87 of file proc.h.

◆ MRB_PROC_SCOPE

#define MRB_PROC_SCOPE   2048

Definition at line 84 of file proc.h.

◆ MRB_PROC_SCOPE_P

#define MRB_PROC_SCOPE_P (   p)    (((p)->flags & MRB_PROC_SCOPE) != 0)

Definition at line 85 of file proc.h.

◆ MRB_PROC_SET_TARGET_CLASS

#define MRB_PROC_SET_TARGET_CLASS (   p,
  tc 
)
Value:
do {\
if (MRB_PROC_ENV_P(p)) {\
(p)->e.env->c = (tc);\
mrb_field_write_barrier(mrb, (struct RBasic*)(p)->e.env, (struct RBasic*)(tc));\
}\
else {\
(p)->e.target_class = (tc);\
mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)(tc));\
}\
} while (0)
small capitals from c petite p
Definition: afcover.h:72
#define MRB_PROC_ENV_P(p)
Definition: proc.h:71
ShellFileEnvironment e
Definition: sh6.c:388
Definition: object.h:19

Definition at line 74 of file proc.h.

◆ MRB_PROC_STRICT

#define MRB_PROC_STRICT   256

Definition at line 66 of file proc.h.

◆ MRB_PROC_STRICT_P

#define MRB_PROC_STRICT_P (   p)    (((p)->flags & MRB_PROC_STRICT) != 0)

Definition at line 67 of file proc.h.

◆ MRB_PROC_TARGET_CLASS

#define MRB_PROC_TARGET_CLASS (   p)    (MRB_PROC_ENV_P(p) ? (p)->e.env->c : (p)->e.target_class)

Definition at line 73 of file proc.h.

Function Documentation

◆ mrb_closure_new()

struct RProc* mrb_closure_new ( mrb_state mrb,
const mrb_irep irep 
)

Definition at line 109 of file proc.c.

References closure_setup(), RProc::irep, mrb_proc_new(), and p.

Referenced by mrb_vm_exec().

◆ mrb_closure_new_cfunc()

struct RProc* mrb_closure_new_cfunc ( mrb_state mrb,
mrb_func_t  func,
int  nlocals 
)

Definition at line 160 of file proc.c.

References func, mrb_proc_new_cfunc_with_env(), and NULL.

◆ mrb_env_unshare()

void mrb_env_unshare ( mrb_state mrb,
struct REnv e 
)

◆ mrb_load_proc()

mrb_value mrb_load_proc ( mrb_state mrb,
const struct RProc proc 
)

Definition at line 666 of file load.c.

References mrb_top_self(), and mrb_vm_run().

◆ mrb_proc_arity()

mrb_int mrb_proc_arity ( const struct RProc p)

◆ mrb_proc_cfunc_env_get()

◆ mrb_proc_copy()

void mrb_proc_copy ( struct RProc a,
struct RProc b 
)

Definition at line 187 of file proc.c.

References a, b, mrb_irep_incref(), MRB_PROC_CFUNC_P, and NULL.

Referenced by mrb_mod_define_method_m(), mrb_proc_init_copy(), mrb_proc_s_new(), and proc_lambda().

◆ mrb_proc_new()

◆ mrb_proc_new_cfunc()

struct RProc* mrb_proc_new_cfunc ( mrb_state mrb,
mrb_func_t  func 
)

◆ mrb_proc_new_cfunc_with_env()

◆ mrb_vm_ci_env()

◆ mrb_vm_ci_env_set()

static void mrb_vm_ci_env_set ( mrb_callinfo ci,
struct REnv e 
)
inlinestatic

Definition at line 183 of file proc.h.

References REnv::c, e, mrb_callinfo::env, MRB_TT_ENV, mrb_callinfo::target_class, REnv::tt, and mrb_callinfo::u.

Referenced by main(), and mrb_top_run().

◆ mrb_vm_ci_proc_set()

static void mrb_vm_ci_proc_set ( mrb_callinfo ci,
const struct RProc p 
)
inlinestatic

◆ mrb_vm_ci_target_class()

static struct RClass* mrb_vm_ci_target_class ( const mrb_callinfo ci)
inlinestatic

◆ mrb_vm_ci_target_class_set()

static void mrb_vm_ci_target_class_set ( mrb_callinfo ci,
struct RClass tc 
)
inlinestatic