-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new interpreter and more control flow work.
- v5.0
- v4.20
- v4.19
- v4.18
- v4.17
- v4.16
- v4.15
- v4.14
- v4.13
- v4.12
- v4.11
- v4.10
- v4.9
- v4.8
- v4.7
- v4.6
- v4.5
- v4.4
- v4.3
- v4.2
- v4.1
- v4.0
- v3.107
- v3.106
- v3.105
- v3.104
- v3.103
- v3.102
- v3.101
- v3.100
- v3.99
- v3.98
- v3.97
- v3.96
- v3.95
- v3.94
- v3.93
- v3.92
- v3.91
- v3.90
- v3.89
- v3.88
- v3.87
- v3.86
- v3.85
- v3.84
- v3.83
- v3.82
- v3.81
- v3.80
- v3.79
- v3.78
- v3.77
- v3.76
- v3.75
- v3.74
- v3.73
- v3.72
- v3.71
- v3.70
- v3.69
- v3.68
- v3.67
- v3.66
- v3.65
- v3.64
- v3.63
- v3.62
- v3.61
- v3.60
- v3.59
- v3.58
- v3.57
- v3.56
- v3.55
- v3.54
- v3.53
- v3.52
Showing
308 changed files
with
3,029 additions
and
2,045 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
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
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
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,4 +1,5 @@ | ||
#include "memory.hpp" | ||
#include "machine_code.hpp" | ||
#include "call_frame.hpp" | ||
#include "on_stack.hpp" | ||
|
||
|
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
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
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,10 +1,14 @@ | ||
#include "interpreter/instructions.hpp" | ||
|
||
inline void rubinius::instruction_add_scope(STATE, CallFrame* call_frame) { | ||
Object* obj = stack_pop(); | ||
Module* mod = as<Module>(obj); | ||
LexicalScope* scope = LexicalScope::create(state); | ||
scope->module(state, mod); | ||
scope->parent(state, call_frame->lexical_scope()); | ||
call_frame->lexical_scope_ = scope; | ||
namespace rubinius { | ||
namespace instructions { | ||
inline void add_scope(STATE, CallFrame* call_frame) { | ||
Object* obj = stack_pop(); | ||
Module* mod = as<Module>(obj); | ||
LexicalScope* scope = LexicalScope::create(state); | ||
scope->module(state, mod); | ||
scope->parent(state, call_frame->lexical_scope()); | ||
call_frame->lexical_scope_ = scope; | ||
} | ||
} | ||
} |
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,4 +1,8 @@ | ||
#include "interpreter/instructions.hpp" | ||
|
||
inline void rubinius::instruction_allow_private() { | ||
namespace rubinius { | ||
namespace instructions { | ||
inline void allow_private() { | ||
} | ||
} | ||
} |
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,34 +1,42 @@ | ||
#include "interpreter/instructions.hpp" | ||
|
||
inline bool rubinius::instruction_cast_array(STATE, CallFrame* call_frame) { | ||
// Use stack_top and not stack_pop because we may need | ||
// to preserve and reread the value from the stack below. | ||
Object* t1 = stack_top(); | ||
if(t1->nil_p()) { | ||
t1 = Array::create(state, 0); | ||
} else if(Tuple* tup = try_as<Tuple>(t1)) { | ||
t1 = Array::from_tuple(state, tup); | ||
} else if(!kind_of<Array>(t1)) { | ||
Object* recv = G(type); | ||
Arguments args(G(sym_coerce_to_array), recv, 1, &t1); | ||
Dispatch dispatch(G(sym_coerce_to_array)); | ||
#include "object_utils.hpp" | ||
|
||
Object* res = dispatch.send(state, args); | ||
#include "builtin/array.hpp" | ||
|
||
// If the send still doesn't produce an array, wrap | ||
// the value in one. | ||
if(res && !kind_of<Array>(res)) { | ||
Array* ary = Array::create(state, 1); | ||
// Don't read t1 here, it's not GC safe because we called | ||
// a method. | ||
ary->set(state, 0, stack_top()); | ||
t1 = ary; | ||
} else { | ||
t1 = res; | ||
} | ||
} | ||
namespace rubinius { | ||
namespace instructions { | ||
inline bool cast_array(STATE, CallFrame* call_frame) { | ||
// Use stack_top and not stack_pop because we may need | ||
// to preserve and reread the value from the stack below. | ||
Object* t1 = stack_top(); | ||
if(t1->nil_p()) { | ||
t1 = Array::create(state, 0); | ||
} else if(Tuple* tup = try_as<Tuple>(t1)) { | ||
t1 = Array::from_tuple(state, tup); | ||
} else if(!rubinius::kind_of<Array>(t1)) { | ||
Object* recv = G(type); | ||
Arguments args(G(sym_coerce_to_array), recv, 1, &t1); | ||
Dispatch dispatch(G(sym_coerce_to_array)); | ||
|
||
Object* res = dispatch.send(state, args); | ||
|
||
(void)stack_pop(); // Remove original value | ||
// If the send still doesn't produce an array, wrap | ||
// the value in one. | ||
if(res && !rubinius::kind_of<Array>(res)) { | ||
Array* ary = Array::create(state, 1); | ||
// Don't read t1 here, it's not GC safe because we called | ||
// a method. | ||
ary->set(state, 0, stack_top()); | ||
t1 = ary; | ||
} else { | ||
t1 = res; | ||
} | ||
} | ||
|
||
CHECK_AND_PUSH(t1); | ||
(void)stack_pop(); // Remove original value | ||
|
||
CHECK_AND_PUSH(t1); | ||
} | ||
} | ||
} |
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,39 +1,45 @@ | ||
#include "interpreter/instructions.hpp" | ||
|
||
inline bool rubinius::instruction_cast_for_multi_block_arg(STATE, CallFrame* call_frame) { | ||
if(!call_frame->arguments) { | ||
Exception::internal_error(state, "no arguments object"); | ||
return false; | ||
} | ||
#include "builtin/array.hpp" | ||
|
||
/* If there is only one argument and that thing is an array... | ||
AND the thing being invoked is not a lambda... */ | ||
if(!(call_frame->flags & CallFrame::cIsLambda) && | ||
call_frame->arguments->total() == 1) { | ||
Object* obj = call_frame->arguments->get_argument(0); | ||
if(kind_of<Array>(obj)) { | ||
stack_push(obj); | ||
} else if(CBOOL(obj->respond_to(state, G(sym_to_ary), cFalse))) { | ||
obj = obj->send(state, G(sym_to_ary)); | ||
if(!obj) return false; | ||
if(kind_of<Array>(obj)) { | ||
stack_push(obj); | ||
} else { | ||
Exception::type_error(state, "to_ary must return an Array"); | ||
namespace rubinius { | ||
namespace instructions { | ||
inline bool cast_for_multi_block_arg(STATE, CallFrame* call_frame) { | ||
if(!call_frame->arguments) { | ||
Exception::internal_error(state, "no arguments object"); | ||
return false; | ||
} | ||
} else { | ||
Array* ary = Array::create(state, 1); | ||
ary->set(state, 0, obj); | ||
stack_push(ary); | ||
} | ||
} else { | ||
Array* ary = Array::create(state, call_frame->arguments->total()); | ||
for(size_t i = 0; i < call_frame->arguments->total(); i++) { | ||
ary->set(state, i, call_frame->arguments->get_argument(i)); | ||
|
||
/* If there is only one argument and that thing is an array... | ||
AND the thing being invoked is not a lambda... */ | ||
if(!(call_frame->flags & CallFrame::cIsLambda) && | ||
call_frame->arguments->total() == 1) { | ||
Object* obj = call_frame->arguments->get_argument(0); | ||
if(rubinius::kind_of<Array>(obj)) { | ||
stack_push(obj); | ||
} else if(CBOOL(obj->respond_to(state, G(sym_to_ary), cFalse))) { | ||
obj = obj->send(state, G(sym_to_ary)); | ||
if(!obj) return false; | ||
if(rubinius::kind_of<Array>(obj)) { | ||
stack_push(obj); | ||
} else { | ||
Exception::type_error(state, "to_ary must return an Array"); | ||
return false; | ||
} | ||
} else { | ||
Array* ary = Array::create(state, 1); | ||
ary->set(state, 0, obj); | ||
stack_push(ary); | ||
} | ||
} else { | ||
Array* ary = Array::create(state, call_frame->arguments->total()); | ||
for(size_t i = 0; i < call_frame->arguments->total(); i++) { | ||
ary->set(state, i, call_frame->arguments->get_argument(i)); | ||
} | ||
stack_push(ary); | ||
} | ||
|
||
return true; | ||
} | ||
stack_push(ary); | ||
} | ||
|
||
return true; | ||
} |
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,23 +1,27 @@ | ||
#include "interpreter/instructions.hpp" | ||
|
||
inline bool rubinius::instruction_cast_for_single_block_arg(STATE, CallFrame* call_frame) { | ||
if(!call_frame->arguments) { | ||
Exception::internal_error(state, "no arguments object"); | ||
return false; | ||
} | ||
namespace rubinius { | ||
namespace instructions { | ||
inline bool cast_for_single_block_arg(STATE, CallFrame* call_frame) { | ||
if(!call_frame->arguments) { | ||
Exception::internal_error(state, "no arguments object"); | ||
return false; | ||
} | ||
|
||
int k = call_frame->arguments->total(); | ||
if(k == 0) { | ||
stack_push(cNil); | ||
} else if(k == 1) { | ||
stack_push(call_frame->arguments->get_argument(0)); | ||
} else { | ||
Array* ary = Array::create(state, k); | ||
for(int i = 0; i < k; i++) { | ||
ary->set(state, i, call_frame->arguments->get_argument(i)); | ||
} | ||
stack_push(ary); | ||
} | ||
|
||
int k = call_frame->arguments->total(); | ||
if(k == 0) { | ||
stack_push(cNil); | ||
} else if(k == 1) { | ||
stack_push(call_frame->arguments->get_argument(0)); | ||
} else { | ||
Array* ary = Array::create(state, k); | ||
for(int i = 0; i < k; i++) { | ||
ary->set(state, i, call_frame->arguments->get_argument(i)); | ||
return true; | ||
} | ||
stack_push(ary); | ||
} | ||
|
||
return true; | ||
} |
Oops, something went wrong.