mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Fixed repl bug
This commit is contained in:
@@ -152,6 +152,9 @@ int main(int argc, const char* argv[]) {
|
||||
if (Toy_commandLine.compilefile && Toy_commandLine.outfile) {
|
||||
size_t size = 0;
|
||||
char* source = Toy_readFile(Toy_commandLine.compilefile, &size);
|
||||
if (!source) {
|
||||
return 1;
|
||||
}
|
||||
unsigned char* tb = Toy_compileString(source, &size);
|
||||
if (!tb) {
|
||||
return 1;
|
||||
|
||||
@@ -145,6 +145,9 @@ void Toy_runSource(char* source) {
|
||||
void Toy_runSourceFile(char* fname) {
|
||||
size_t size = 0; //not used
|
||||
char* source = Toy_readFile(fname, &size);
|
||||
if (!source) {
|
||||
return;
|
||||
}
|
||||
Toy_runSource(source);
|
||||
free((void*)source);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
fn fib(n : int) {
|
||||
if (n < 2) {
|
||||
return n;
|
||||
}
|
||||
|
||||
if (n < 2) return n;
|
||||
return fib(n-1) + fib(n-2);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//number of iterations
|
||||
var SIZE: int const = 100;
|
||||
var SIZE: int const = 260;
|
||||
|
||||
//lookup table
|
||||
var lookup = [
|
||||
@@ -32,7 +32,7 @@ prev += "*"; //initial
|
||||
print prev;
|
||||
|
||||
//run
|
||||
for (var iteration = 0; iteration < 100; iteration++) {
|
||||
for (var iteration = 0; iteration < SIZE -1; iteration++) {
|
||||
//left
|
||||
var output = (lookup[" "][prev[0]][prev[1]]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user