forked from sorbet/sorbet
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexandre Terrasa <[email protected]>
- Loading branch information
Showing
11 changed files
with
313 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.