Skip to content

Commit

Permalink
revert wrong merge. (f57263c)
Browse files Browse the repository at this point in the history
  • Loading branch information
HirohitoHigashi committed Mar 11, 2021
1 parent c08f27b commit e7e71e1
Show file tree
Hide file tree
Showing 11 changed files with 489 additions and 529 deletions.
39 changes: 10 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
from ruby:3.0.0-slim
from ruby:2.7.2-slim

RUN apt update && apt -y upgrade
RUN apt install -y \
bison \
gcc \
gcc-arm-linux-gnueabi \
git \
make \
qemu \
qemu-kvm \
qemu-system-arm
RUN apt install -y bison make git gcc gcc-arm-linux-gnueabi qemu qemu-kvm qemu-system-arm

RUN gem update --system

ARG USER_ID
RUN useradd -m -u $USER_ID mrubyc
RUN mkdir /work && chown mrubyc /work

USER mrubyc

VOLUME /work/mrubyc
COPY --chown=mrubyc Gemfile /work/mrubyc/
COPY --chown=mrubyc Gemfile.lock /work/mrubyc/
RUN git clone https://github.com/mruby/mruby /root/mruby
ARG MRUBY_TAG
RUN cd /root/mruby; git checkout $MRUBY_TAG; make

USER root
WORKDIR /work/mrubyc
VOLUME /root/mrubyc
COPY Gemfile /root/mrubyc/
COPY Gemfile.lock /root/mrubyc/
WORKDIR /root/mrubyc
RUN bundle install

USER mrubyc
ENV CFLAGS="-DMRBC_USE_MATH=1 -DMAX_SYMBOLS_COUNT=500"

RUN git clone https://github.com/mruby/mruby /work/mruby
ARG MRUBY_TAG
RUN cd /work/mruby; git fetch --prune; git checkout $MRUBY_TAG; make clean && make

CMD ["bundle", "exec", "mrubyc-test", "-e", "10", "-p", "/work/mruby/build/host/bin/mrbc"]
CMD ["bundle", "exec", "mrubyc-test", "-e", "100", "-p", "/root/mruby/build/host/bin/mrbc"]
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source "https://rubygems.org"

gem "mrubyc-test", "~> 0.6.1"
gem "mrubyc-test", "~> 0.6"
27 changes: 14 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.1)
activesupport (6.0.3.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
concurrent-ruby (1.1.7)
i18n (1.8.7)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
minitest (5.14.3)
mrubyc-test (0.6.1)
minitest (5.14.2)
mrubyc-test (0.6.0)
activesupport (~> 6.0)
rufo (~> 0.12)
thor (~> 1.0)
rufo (0.12.0)
thor (1.0.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
zeitwerk (2.4.2)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
zeitwerk (2.4.0)

PLATFORMS
ruby

DEPENDENCIES
mrubyc-test (~> 0.6.1)
mrubyc-test (~> 0.6)

BUNDLED WITH
2.2.5
2.1.4
44 changes: 13 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
#
# mruby/c Makefile
#
# Copyright (C) 2015-2021 Kyushu Institute of Technology.
# Copyright (C) 2015-2021 Shimane IT Open-Innovation Center.
# Copyright (C) 2015-2018 Kyushu Institute of Technology.
# Copyright (C) 2015-2018 Shimane IT Open-Innovation Center.
#
# This file is distributed under BSD 3-Clause License.
#

# MRUBY_TAG corresponds to tag or branch of mruby/mruby
MRUBY_TAG = $(shell grep MRUBY_VERSION mrblib/global.rb | sed 's/MRUBY_VERSION *= *"\(.\+\)"/\1/')
USER_ID = $(shell id -u)

# tag or branch name of mruby/mruby
MRUBY_TAG = `grep MRUBY_VERSION mrblib/global.rb | sed 's/MRUBY_VERSION *= *"\(.\+\)"/\1/'`

all: mrubyc_lib mrubyc_bin

.PHONY: mrblib
mrblib:
cd mrblib ; $(MAKE) distclean all

mrubyc_lib:
cd mrblib ; $(MAKE) all
Expand Down Expand Up @@ -45,28 +40,15 @@ package: clean
rm -Rf pkg ;\
echo Done.

.PHONY: test setup_test check_tag

test: check_tag
docker run --mount type=bind,src=${PWD}/,dst=/work/mrubyc \
.PHONY: test setup_test
test:
docker run --mount type=bind,src=${PWD}/,dst=/root/mrubyc \
-e CFLAGS="-DMRBC_USE_MATH=1 -DMAX_SYMBOLS_COUNT=500 $(CFLAGS)" \
-e MRBC="/work/mruby/build/host/bin/mrbc" \
mrubyc-dev /bin/sh -c "cd mrblib; make distclean all && cd -; \
bundle exec mrubyc-test --every=10 \
--mrbc-path=/work/mruby/build/host/bin/mrbc \
$(file)"

check_tag:
$(eval CURRENT_MRUBY_TAG = $(shell docker run mrubyc-dev \
/bin/sh -c 'cd /work/mruby && git status | ruby -e"puts STDIN.first.split(\" \")[-1]"'))
@echo MRUBY_TAG=$(MRUBY_TAG)
@echo CURRENT_MRUBY_TAG=$(CURRENT_MRUBY_TAG)
if test "$(CURRENT_MRUBY_TAG)" = "$(MRUBY_TAG)"; \
then \
echo 'Skip setup_test'; \
else \
make setup_test; \
fi
mrubyc/mrubyc-test bundle exec mrubyc-test \
--every=100 \
--mrbc-path=/root/mruby/build/host/bin/mrbc \
$(file)

setup_test:
docker build -t mrubyc-dev --build-arg MRUBY_TAG=$(MRUBY_TAG) --build-arg USER_ID=$(USER_ID) .
@echo MRUBY_TAG=$(MRUBY_TAG)
docker build -t mrubyc/mrubyc-test --build-arg MRUBY_TAG=$(MRUBY_TAG) .
4 changes: 2 additions & 2 deletions mrblib/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
#

RUBY_VERSION = "1.9"
MRUBY_VERSION = "33deeae"
MRUBYC_VERSION = "3.0"
MRUBY_VERSION = "2.1.1"
MRUBYC_VERSION = "2.1"
48 changes: 44 additions & 4 deletions src/c_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,30 +289,70 @@ static void c_object_raise(struct VM *vm, mrbc_value v[], int argc)
if( argc == 0 ){
// 1. raise
vm->exc = mrbc_class_runtimeerror;
// vm->exc_message = mrbc_nil_value();
vm->exc_message = mrbc_nil_value();
} else if( argc == 1 ){
if( v[1].tt == MRBC_TT_CLASS ){
// 3. raise Exception
vm->exc = v[1].cls;
// vm->exc_message = mrbc_nil_value();
vm->exc_message = mrbc_nil_value();
} else {
// 2. raise "param"
mrbc_incref( &v[1] );
vm->exc = mrbc_class_runtimeerror;
// vm->exc_message = v[1];
vm->exc_message = v[1];
}
} else if( argc == 2 ){
// 4. raise Exception, "param"
mrbc_incref( &v[2] );
vm->exc = v[1].cls;
// vm->exc_message = v[2];
vm->exc_message = v[2];
}
} else {
// in exception
}

// do nothing if no rescue, no ensure
if( vm->exception_tail == NULL ){
return;
}

// NOT to return to OP_SEND
mrbc_pop_callinfo(vm);

mrbc_callinfo *callinfo = vm->exception_tail;
if( callinfo != NULL ){
if( callinfo->method_id == 0x7fff ){
// "rescue"
// jump to rescue
vm->exception_tail = callinfo->prev;
vm->current_regs = callinfo->current_regs;
vm->pc_irep = callinfo->pc_irep;
vm->inst = callinfo->inst;
vm->target_class = callinfo->target_class;
mrbc_free(vm, callinfo);
callinfo = vm->exception_tail;
} else {
// "ensure"
// jump to ensure
vm->exception_tail = callinfo->prev;
vm->current_regs = callinfo->current_regs;
vm->pc_irep = callinfo->pc_irep;
vm->inst = callinfo->inst;
vm->target_class = callinfo->target_class;
mrbc_free(vm, callinfo);
//
callinfo = vm->exception_tail;
if( callinfo != NULL ){
vm->exception_tail = callinfo->prev;
callinfo->prev = vm->callinfo_tail;
vm->callinfo_tail = callinfo;
}
}
}
if( callinfo == NULL ){
vm->exc_pending = vm->exc;
vm->exc = 0;
}
}


Expand Down
12 changes: 6 additions & 6 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
static void c_exception_message(struct VM *vm, mrbc_value v[], int argc)
{
mrbc_decref( &v[0] );
// if( vm->exc_message.tt == MRBC_TT_NIL ){
if( vm->exc_message.tt == MRBC_TT_NIL ){
v[0] = mrbc_string_new(vm, "", 0);
// } else {
// v[0] = vm->exc_message;
// }
} else {
v[0] = vm->exc_message;
}
}


void mrbc_raiseX(mrbc_vm *vm, mrbc_error_code err, char *msg)
{
vm->exc = mrbc_class_runtimeerror;
// vm->exc_message = mrbc_nil_value();
// if( vm->exception_tail == NULL ) return;
vm->exc_message = mrbc_nil_value();
if( vm->exception_tail == NULL ) return;
}


Expand Down
Loading

0 comments on commit e7e71e1

Please sign in to comment.