add more examples
This commit is contained in:
parent
67a74f3417
commit
3e46c04513
|
@ -1,13 +1,6 @@
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
var add = Fn.new { |a, b|
|
|
||||||
return a + b
|
|
||||||
}
|
|
||||||
|
|
||||||
var sum = add.call(1, 1)
|
|
||||||
System.print(sum.toString)
|
|
|
@ -1,10 +0,0 @@
|
||||||
class Fib {
|
|
||||||
static fib(n) {
|
|
||||||
if (n < 2) return n
|
|
||||||
return fib(n-1) + fib(n-2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = Fib.fib(35)
|
|
||||||
|
|
||||||
System.print(result)
|
|
|
@ -1,10 +0,0 @@
|
||||||
var a = 5.0
|
|
||||||
var i = 5
|
|
||||||
while (i >= 0) {
|
|
||||||
a = a + 5.0
|
|
||||||
i = i - 1
|
|
||||||
}
|
|
||||||
var b = a
|
|
||||||
System.write("Enter a string: ")
|
|
||||||
System.print(a.toString)
|
|
||||||
System.print(b.toString)
|
|
|
@ -16,22 +16,22 @@ print_section() {
|
||||||
printf '\n\e[1;34m%s\e[0m\n' "$1"
|
printf '\n\e[1;34m%s\e[0m\n' "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wren Implementation
|
# Unfair LuaJIT Implementation
|
||||||
print_section "Wren ($FILENAME.wren)"
|
print_section "Lua ($FILENAME.lua)"
|
||||||
time wren "$FILENAME.wren"
|
echo "test input" | time luajit "$FILENAME.lua"
|
||||||
|
|
||||||
# Lua Implementation
|
# Lua Implementation
|
||||||
print_section "Lua ($FILENAME.lua)"
|
print_section "Lua ($FILENAME.lua)"
|
||||||
time lua "$FILENAME.lua"
|
echo "test input" | time lua "$FILENAME.lua"
|
||||||
|
|
||||||
# Perl Implementation
|
# Perl Implementation
|
||||||
print_section "Perl ($FILENAME.pl)"
|
print_section "Perl ($FILENAME.pl)"
|
||||||
time perl "$FILENAME.pl"
|
echo "test input" | time perl "$FILENAME.pl"
|
||||||
|
|
||||||
# Python Implementation
|
# Python Implementation
|
||||||
print_section "Python ($FILENAME.py)"
|
print_section "Python ($FILENAME.py)"
|
||||||
time python3 "$FILENAME.py"
|
echo "test input" | time python3 "$FILENAME.py"
|
||||||
|
|
||||||
# ZRE Implementation
|
# ZRE Implementation
|
||||||
print_section "zre ($FILENAME.zre)"
|
print_section "zre ($FILENAME.zre)"
|
||||||
time ../../src/zre "$FILENAME.zre"
|
echo "test input" | time ../../src/zre "$FILENAME.zre"
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
main:
|
||||||
|
loadf $0 5.0
|
||||||
|
loadi $1 5
|
||||||
|
loadi $2 0
|
||||||
|
loadi $3 -1
|
||||||
|
loop:
|
||||||
|
loadf $5 5.0
|
||||||
|
addr $0 $0 $5
|
||||||
|
addi $1 $1 $3
|
||||||
|
loadu $4 &loop
|
||||||
|
jgei $4 $1 $2
|
||||||
|
rtou $1 $0
|
||||||
|
gets $2
|
||||||
|
utos $3 $1
|
||||||
|
puts $3
|
||||||
|
rtos $3 $0
|
||||||
|
puts $3
|
||||||
|
puts $2
|
||||||
|
halt
|
Loading…
Reference in New Issue