Skip to content

Commit 0f5cb4a

Browse files
committed
WIP merging microruby
1 parent 1a5e739 commit 0f5cb4a

File tree

7 files changed

+31
-9
lines changed

7 files changed

+31
-9
lines changed

lib/picoruby/build.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def picoruby(alloc_libc: true)
6666
.gsub('@PICORUBY_COMMIT_HASH@', commit_hash)
6767
)
6868

69+
cc.include_paths << "#{gems['picoruby-mrubyc'].dir}/include"
6970
cc.include_paths << "#{gems['mruby-compiler2'].dir}/include"
7071
cc.include_paths << "#{gems['mruby-compiler2'].dir}/lib/prism/include"
7172
cc.include_paths << "#{MRUBY_ROOT}/include/picoruby"

mrbgems/picoruby-crc/src/mrubyc/crc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ c_crc_crc32(mrbc_vm *vm, mrbc_value v[], int argc)
1010
mrbc_value string = GET_ARG(1);
1111
mrbc_int_t crc = GET_INT_ARG(2);
1212
if (string.tt == MRBC_TT_NIL) {
13-
return mrb_fixnum_value(0);
13+
SET_INT_RETURN(0);
14+
return;
1415
} else if (string.tt != MRBC_TT_STRING) {
1516
mrbc_raise(vm, MRBC_CLASS(TypeError), "string expected");
1617
return;
1718
}
18-
uint32_t crc_value = generate_crc32((uint8_t *)string.string->data, string.string->len, crc);
19+
uint32_t crc_value = generate_crc32((uint8_t *)string.string->data, string.string->size, crc);
1920
SET_INT_RETURN(crc_value);
2021
}
2122

mrbgems/picoruby-machine/include/hal.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@ extern "C" {
99
#include "mruby.h"
1010
void mrb_tick(mrb_state *mrb);
1111
void hal_init(mrb_state *mrb);
12-
//#elif defined(PICORB_VM_MRUBYC)
13-
//#include "mrubyc.h"
14-
//typedef void mrb_state;
15-
//void mrbc_tick();
16-
//void hal_init(mrb_state *mrb);
17-
//#define mrb_tick(mrb) mrbc_tick()
18-
//#define MRB_TICK_UNIT MRBC_TICK_UNIT
1912
#elif defined(PICORB_VM_MRUBYC)
13+
void mrbc_tick();
2014
void hal_init(void);
2115
#endif
2216

mrbgems/picoruby-machine/ports/rp2040/machine.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ static volatile uint32_t interrupt_nesting = 0;
4242

4343
static volatile bool in_tick_processing = false;
4444

45+
#if defined(PICORB_VM_MRUBY)
4546
static mrb_state *mrb_;
47+
#endif
4648

4749
static void
4850
alarm_handler(void)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _MRUBY_H_FOR_MRUBYC
2+
#define _MRUBY_H_FOR_MRUBYC
3+
4+
#define mrb_state void
5+
6+
void mrb_init_mrblib(mrb_state *mrb);
7+
8+
#endif
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef _MRUBY_IREP_H_FOR_MRUBYC
2+
#define _MRUBY_IREP_H_FOR_MRUBYC
3+
4+
#include <stdint.h>
5+
6+
inline void mrb_load_irep(mrb_state *mrb, const uint8_t *mrblib_irep) { }
7+
8+
#endif
9+

mrbgems/picoruby-shell/src/mrubyc/shell.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ mrbc_shell_init(mrbc_vm *vm)
4444
mrbc_class *mrbc_class_Shell = mrbc_define_class(vm, "Shell", mrbc_class_object);
4545
mrbc_define_method(vm, mrbc_class_Shell, "next_executable", c_next_executable);
4646
}
47+
48+
void
49+
picoruby_init_executables(mrbc_vm *vm)
50+
{
51+
mrbc_class *mrbc_class_Shell = mrbc_define_class(vm, "Shell", mrbc_class_object);
52+
mrbc_define_method(vm, mrbc_class_Shell, "next_executable", c_next_executable);
53+
}

0 commit comments

Comments
 (0)