get rid of sleep()

This commit is contained in:
Marc Vertes
2018-09-27 14:00:41 +02:00
parent 7d58f10ee8
commit 335373164f
6 changed files with 29 additions and 33 deletions

10
_test/a15.go Normal file
View File

@@ -0,0 +1,10 @@
package main
import "fmt"
const size = 12
func main() {
var buf [size]int
fmt.Println(buf[:])
}

View File

@@ -6,6 +6,6 @@ func f() {
func main() {
go f()
sleep(100)
//sleep(100)
println("in main")
}

View File

@@ -1,7 +0,0 @@
package main
func main() {
println("sleep")
sleep(1000)
println("bye")
}

View File

@@ -144,7 +144,6 @@ func initUniverse() *Scope {
"make": &Symbol{kind: Bltn, builtin: _make},
"panic": &Symbol{kind: Bltn, builtin: _panic},
"println": &Symbol{kind: Bltn, builtin: _println},
"sleep": &Symbol{kind: Bltn, builtin: sleep}, // Temporary, for debug
// TODO: cap, close, complex, copy, delete, imag, new, print, real, recover
}}
return scope

View File

@@ -134,6 +134,23 @@ func main() {
// [0 0 0 0 0 0 0 0 0 0 0 0]
}
func Example_a15() {
src := `
package main
import "fmt"
const size = 12
func main() {
var buf [size]int
fmt.Println(buf[:])
}`
i := NewInterpreter(Opt{Entry: "main"})
i.Eval(src)
}
func Example_a2() {
src := `
package main
@@ -909,7 +926,7 @@ func f() {
func main() {
go f()
sleep(100)
//sleep(100)
println("in main")
}`
i := NewInterpreter(Opt{Entry: "main"})
@@ -2777,20 +2794,6 @@ func main() {
// 29
}
func Example_sleep() {
src := `
package main
func main() {
println("sleep")
sleep(1000)
println("bye")
}`
i := NewInterpreter(Opt{Entry: "main"})
i.Eval(src)
}
func Example_src0() {
src := `
package main

View File

@@ -4,7 +4,6 @@ import (
"fmt"
"log"
"reflect"
"time"
)
// Builtin type defines functions which run at CFG execution
@@ -954,14 +953,6 @@ func slice0(n *Node) Builtin {
}
}
// Temporary, for debugging purppose
func sleep(n *Node) Builtin {
return func(f *Frame) {
duration := time.Duration(n.child[1].value(f).(int))
time.Sleep(duration * time.Millisecond)
}
}
func isNil(n *Node) Builtin {
i := n.findex
value := n.child[0].value