Skip to content

Commit

Permalink
TMP tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Terrasa <[email protected]>
  • Loading branch information
Morriar committed Dec 3, 2024
1 parent 6039370 commit f2fe1ef
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 243 deletions.
33 changes: 10 additions & 23 deletions main/main.cc
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
#include "common/common.h"
#include "main/options/options.h"
#include "main/realmain.h"

#include "ruby.h"

extern "C" {
#include "rbs_parser/constants.h"
#include "rbs_parser/location.h"
#include "rbs_parser/parser.h"
}
#include "rbs/rbs_common.h"
#include "rbs/RubyVM.h"

int main(int argc, char *argv[]) {
ruby_init();
ruby_init_loadpath();

VALUE rb_load_path = rb_gv_get("$:");
VALUE new_path = rb_str_new_cstr("/Users/at/src/github.com/ruby/rbs/lib");
rb_funcall(rb_load_path, rb_intern("unshift"), 1, new_path);

rb_require("rbs.rb");

rbs__init_constants();
// rbs__init_location();
// rbs__init_parser();
sorbet::rbs::RubyVM::initialize();

int result;
try {
return sorbet::realmain::realmain(argc, argv);
result = sorbet::realmain::realmain(argc, argv);
} catch (sorbet::EarlyReturnWithCode &c) {
return c.returnCode;
result = c.returnCode;
}
};

sorbet::rbs::RubyVM::cleanup();
return result;
}
28 changes: 28 additions & 0 deletions rbs/RubyVM.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "RubyVM.h"
#include "rbs_common.h"

namespace sorbet::rbs {

void RubyVM::initialize() {
RUBY_INIT_STACK;

ruby_init();
ruby_init_loadpath();

// TODO: read this from the dep
VALUE rb_load_path = rb_gv_get("$:");
VALUE new_path = rb_str_new_cstr("/Users/at/src/github.com/ruby/rbs/lib");
rb_funcall(rb_load_path, rb_intern("unshift"), 1, new_path);

rb_require("rbs.rb");

rbs__init_constants();
// rbs__init_location(); // TODO: do we need this?
// rbs__init_parser(); // TODO: do we need this?
}

void RubyVM::cleanup() {
ruby_cleanup(0);
}

} // namespace sorbet::rbs
16 changes: 16 additions & 0 deletions rbs/RubyVM.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef RUBYVM_H
#define RUBYVM_H

#include <memory>

namespace sorbet::rbs {

class RubyVM {
public:
static void initialize();
static void cleanup();
};

} // namespace sorbet::rbs

#endif // RUBYVM_H
12 changes: 12 additions & 0 deletions rbs/rbs_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef RBS_COMMON_H
#define RBS_COMMON_H

#include "ruby.h"

extern "C" {
#include "rbs_parser/constants.h"
#include "rbs_parser/location.h"
#include "rbs_parser/parser.h"
}

#endif // RBS_COMMON_H
205 changes: 0 additions & 205 deletions rewriter/RBSAnnotations.cc

This file was deleted.

Loading

0 comments on commit f2fe1ef

Please sign in to comment.