Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

Location:
EcnlProtoTool/trunk/mruby-1.3.0
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-eval/src/eval.c

    r321 r331  
    1 #include "mruby.h"
    2 #include "mruby/class.h"
    3 #include "mruby/compile.h"
    4 #include "mruby/irep.h"
    5 #include "mruby/proc.h"
    6 #include "mruby/opcode.h"
     1#include <mruby.h>
     2#include <mruby/class.h>
     3#include <mruby/compile.h>
     4#include <mruby/irep.h>
     5#include <mruby/proc.h>
     6#include <mruby/opcode.h>
     7#include <mruby/error.h>
     8
     9mrb_value mrb_exec_irep(mrb_state *mrb, mrb_value self, struct RProc *p);
     10mrb_value mrb_obj_instance_eval(mrb_state *mrb, mrb_value self);
    711
    812static struct mrb_irep *
     
    2731
    2832  if (!e) return NULL;
     33  if (!MRB_ENV_STACK_SHARED_P(e)) return NULL;
     34  c = e->cxt.c;
    2935  proc = c->cibase[e->cioff].proc;
    3036
     
    127133      }
    128134      break;
    129     }
    130   }
    131 }
     135
     136    case OP_STOP:
     137      if (mrb->c->ci->acc >= 0) {
     138        irep->iseq[i] = MKOP_AB(OP_RETURN, irep->nlocals, OP_R_NORMAL);
     139      }
     140      break;
     141    }
     142  }
     143}
     144
     145void mrb_codedump_all(mrb_state*, struct RProc*);
    132146
    133147static struct RProc*
    134 create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, char *file, mrb_int line)
     148create_proc_from_string(mrb_state *mrb, char *s, int len, mrb_value binding, const char *file, mrb_int line)
    135149{
    136150  mrbc_context *cxt;
     
    146160  cxt = mrbc_context_new(mrb);
    147161  cxt->lineno = line;
    148   if (file) {
    149     mrbc_filename(mrb, cxt, file);
    150   }
     162
     163  mrbc_filename(mrb, cxt, file ? file : "(eval)");
    151164  cxt->capture_errors = TRUE;
    152165  cxt->no_optimize = TRUE;
     
    161174  if (0 < p->nerr) {
    162175    /* parse error */
    163     char buf[256];
    164     int n;
    165     n = snprintf(buf, sizeof(buf), "line %d: %s\n", p->error_buffer[0].lineno, p->error_buffer[0].message);
     176    mrb_value str;
     177
     178    if (file) {
     179      str = mrb_format(mrb, " file %S line %S: %S",
     180                       mrb_str_new_cstr(mrb, file),
     181                       mrb_fixnum_value(p->error_buffer[0].lineno),
     182                       mrb_str_new_cstr(mrb, p->error_buffer[0].message));
     183    }
     184    else {
     185      str = mrb_format(mrb, " line %S: %S",
     186                       mrb_fixnum_value(p->error_buffer[0].lineno),
     187                       mrb_str_new_cstr(mrb, p->error_buffer[0].message));
     188    }
    166189    mrb_parser_free(p);
    167190    mrbc_context_free(mrb, cxt);
    168     mrb_exc_raise(mrb, mrb_exc_new(mrb, E_SYNTAX_ERROR, buf, n));
     191    mrb_exc_raise(mrb, mrb_exc_new_str(mrb, E_SYNTAX_ERROR, str));
    169192  }
    170193
     
    182205  if (!e) e = c->ci[-1].env;
    183206  e = (struct REnv*)mrb_obj_alloc(mrb, MRB_TT_ENV, (struct RClass*)e);
    184   e->mid = c->ci[-1].mid;
    185   e->cioff = c->ci - c->cibase - 1;
     207  e->cxt.c = c;
     208  e->cioff = c->ci - c->cibase;
    186209  e->stack = c->ci->stackent;
    187   MRB_SET_ENV_STACK_LEN(e, c->ci[-1].proc->body.irep->nlocals);
    188   c->ci->env = e;
     210  MRB_SET_ENV_STACK_LEN(e, c->ci->proc->body.irep->nlocals);
     211  c->ci->target_class = proc->target_class;
     212  c->ci->env = 0;
    189213  proc->env = e;
    190214  patch_irep(mrb, proc->body.irep, 0);
     
    194218
    195219  return proc;
     220}
     221
     222static mrb_value
     223exec_irep(mrb_state *mrb, mrb_value self, struct RProc *proc)
     224{
     225  if (mrb->c->ci->acc < 0) {
     226    mrb_value ret = mrb_top_run(mrb, proc, mrb->c->stack[0], 0);
     227    if (mrb->exc) {
     228      mrb_exc_raise(mrb, mrb_obj_value(mrb->exc));
     229    }
     230    return ret;
     231  }
     232  return mrb_exec_irep(mrb, self, proc);
    196233}
    197234
     
    204241  char *file = NULL;
    205242  mrb_int line = 1;
    206   mrb_value ret;
    207243  struct RProc *proc;
    208244
     
    210246
    211247  proc = create_proc_from_string(mrb, s, len, binding, file, line);
    212   ret = mrb_toplevel_run(mrb, proc);
    213   if (mrb->exc) {
    214     mrb_exc_raise(mrb, mrb_obj_value(mrb->exc));
    215   }
    216 
    217   return ret;
    218 }
    219 
    220 mrb_value mrb_obj_instance_eval(mrb_state *mrb, mrb_value self);
    221 
    222 #define CI_ACC_SKIP    -1
     248  mrb_assert(!MRB_PROC_CFUNC_P(proc));
     249  return exec_irep(mrb, self, proc);
     250}
    223251
    224252static mrb_value
    225253f_instance_eval(mrb_state *mrb, mrb_value self)
    226254{
    227   struct mrb_context *c = mrb->c;
    228255  mrb_value b;
    229256  mrb_int argc; mrb_value *argv;
     
    237264    mrb_int line = 1;
    238265    mrb_value cv;
     266    struct RProc *proc;
    239267
    240268    mrb_get_args(mrb, "s|zi", &s, &len, &file, &line);
    241     c->ci->acc = CI_ACC_SKIP;
    242269    cv = mrb_singleton_class(mrb, self);
    243     c->ci->target_class = mrb_class_ptr(cv);
    244     return mrb_run(mrb, create_proc_from_string(mrb, s, len, mrb_nil_value(), file, line), self);
     270    proc = create_proc_from_string(mrb, s, len, mrb_nil_value(), file, line);
     271    proc->target_class = mrb_class_ptr(cv);
     272    mrb->c->ci->env = NULL;
     273    mrb_assert(!MRB_PROC_CFUNC_P(proc));
     274    return exec_irep(mrb, self, proc);
    245275  }
    246276  else {
Note: See TracChangeset for help on using the changeset viewer.