Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
497 additions
and
136 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 |
---|---|---|
|
@@ -25,3 +25,5 @@ callgrind.out.* | |
src/*/*.o-* | ||
src/*.o-* | ||
hoge.pl | ||
hoge.cc | ||
a.out |
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 |
---|---|---|
|
@@ -55,6 +55,8 @@ glob('src/object/*.cc') | |
Test::LongString | ||
Test::Fatal | ||
|
||
File::which | ||
|
||
syntax | ||
------ | ||
|
||
|
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ class Foo { | |
self.bless(4649); | ||
} | ||
sub DESTROY() { | ||
say("DESTROY"); | ||
$n = ${self}; | ||
} | ||
} | ||
|
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,20 @@ | ||
#include "nanotap.h" | ||
#include "../tora/compiler.h" | ||
#include "../tora/symbol_table.h" | ||
#include "../tora/value.h" | ||
#include "../tora/node.h" | ||
#include <stdarg.h> | ||
|
||
using namespace tora; | ||
|
||
int main() { | ||
{ | ||
SharedPtr<SymbolTable> st = new SymbolTable(); | ||
Compiler compiler(st, "<eval>"); | ||
SharedPtr<Node> n = new FuncdefNode(new StrNode(NODE_IDENTIFIER, "hoge"), new ListNode(), new Node(NODE_VOID)); | ||
compiler.compile(n); | ||
} | ||
|
||
done_testing(); | ||
} | ||
|
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,63 @@ | ||
#include "nanotap.h" | ||
#include "../tora/frame.h" | ||
#include "../tora/vm.h" | ||
#include "../tora/symbol_table.h" | ||
#include "../tora/op_array.h" | ||
#include <stdarg.h> | ||
#include <assert.h> | ||
|
||
using namespace tora; | ||
|
||
int main() { | ||
{ | ||
SharedPtr<OPArray> opa(new OPArray()); | ||
SharedPtr<SymbolTable> st(new SymbolTable()); | ||
VM vm(opa, st, false); | ||
int vars_cnt = 3; | ||
int top = 0; | ||
// LexicalVarsFrame(VM *vm, int vars_cnt, size_t top, frame_type_t type_=FRAME_TYPE_LEXICAL); | ||
SharedPtr<LexicalVarsFrame> f1(new LexicalVarsFrame(&vm, vars_cnt, top)); | ||
vm.frame_stack->push_back(f1); | ||
SharedPtr<LexicalVarsFrame> f2(new LexicalVarsFrame(&vm, vars_cnt, top)); | ||
vm.frame_stack->push_back(f2); | ||
SharedPtr<Value> v = f2->get_variable_dynamic(1, 0); | ||
is(v->value_type, VALUE_TYPE_UNDEF); | ||
} | ||
|
||
{ | ||
SharedPtr<OPArray> opa(new OPArray()); | ||
SharedPtr<SymbolTable> st(new SymbolTable()); | ||
VM vm(opa, st, false); | ||
int vars_cnt = 3; | ||
int top = 0; | ||
// LexicalVarsFrame(VM *vm, int vars_cnt, size_t top, frame_type_t type_=FRAME_TYPE_LEXICAL); | ||
SharedPtr<LexicalVarsFrame> f1(new LexicalVarsFrame(&vm, vars_cnt, top)); | ||
vm.frame_stack->push_back(f1); | ||
f1->set_variable(0, new IntValue(5)); | ||
is(f1->get_variable(0)->to_int(), 5); | ||
f1->set_variable(0, new IntValue(9)); | ||
is(f1->get_variable(0)->to_int(), 9); | ||
} | ||
|
||
{ | ||
SharedPtr<OPArray> opa(new OPArray()); | ||
SharedPtr<SymbolTable> st(new SymbolTable()); | ||
VM vm(opa, st, false); | ||
int vars_cnt = 3; | ||
int top = 0; | ||
// LexicalVarsFrame(VM *vm, int vars_cnt, size_t top, frame_type_t type_=FRAME_TYPE_LEXICAL); | ||
SharedPtr<LexicalVarsFrame> f1(new LexicalVarsFrame(&vm, vars_cnt, top)); | ||
vm.frame_stack->push_back(f1); | ||
SharedPtr<LexicalVarsFrame> f2(new LexicalVarsFrame(&vm, vars_cnt, top)); | ||
vm.frame_stack->push_back(f2); | ||
f2->set_variable(0, new IntValue(4)); | ||
f1->set_variable(0, new IntValue(5)); | ||
is(f2->get_variable(0)->to_int(), 4); | ||
is(f2->get_variable_dynamic(1, 0)->to_int(), 5); | ||
SharedPtr<Value> v = new StrValue("OOO"); | ||
f2->set_variable_dynamic(1, 0, v); | ||
is(f2->get_variable_dynamic(1, 0)->to_s()->str_value(), v->to_s()->str_value()); | ||
} | ||
|
||
done_testing(); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "nanotap.h" | ||
#include "../tora/frame.h" | ||
#include <stdarg.h> | ||
#include <assert.h> | ||
|
||
using namespace tora; | ||
|
||
int main() { | ||
std::string filename_("foo.tra"); | ||
|
||
{ | ||
SharedPtr<PadList> p1 = new PadList(1, NULL); | ||
p1->set(0, new IntValue(5)); | ||
SharedPtr<Value> val = p1->get(0); | ||
ok(!!val.get()); | ||
is(val->value_type, VALUE_TYPE_INT); | ||
is(val->to_int(), 5); | ||
|
||
SharedPtr<Value> val1 = p1->get(1); | ||
is(val1->value_type, VALUE_TYPE_UNDEF); | ||
} | ||
|
||
printf("# second phase\n"); | ||
{ | ||
SharedPtr<PadList> p1 = new PadList(0, NULL); | ||
SharedPtr<PadList> p2 = new PadList(0, p1.get()); | ||
SharedPtr<PadList> p3 = new PadList(0, p2.get()); | ||
is((void*)p1->upper(1), (void*)NULL); | ||
is(p2->upper(1), p1.get()); | ||
is(p3->upper(1), p2.get()); | ||
is(p3->upper(2), p1.get()); | ||
is((void*)p3->upper(3), (void*)NULL); | ||
} | ||
|
||
printf("# third phase\n"); | ||
|
||
{ | ||
SharedPtr<PadList> p1 = new PadList(1, NULL); | ||
SharedPtr<PadList> p2 = new PadList(1, p1.get()); | ||
SharedPtr<PadList> p3 = new PadList(3, p2.get()); | ||
p1->set(0, new IntValue(5)); | ||
p2->set(1, new IntValue(9)); | ||
p3->set(2, new IntValue(6)); | ||
p3->set(0, new IntValue(3)); | ||
|
||
is(p2->get_dynamic(1, 0)->value_type, VALUE_TYPE_INT); | ||
is(p2->get_dynamic(1, 0)->to_int(), 5); | ||
is(p3->get_dynamic(2, 0)->to_int(), 5); | ||
is(p3->get_dynamic(1, 1)->to_int(), 9); | ||
} | ||
|
||
done_testing(); | ||
} |
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
Oops, something went wrong.