A Golang SSA Interpreter

Overview

interp

example

package main

import (
	"fmt"

	"github.com/goplus/interp"
)

var souce = `
package main

import "fmt"

func main() {
	fmt.Println("hello")
}
`

func init() {
	interp.RegisterExternal("fmt.init", func() {})
	interp.RegisterExternal("fmt.Println", fmt.Println)
}

func main() {
	err := interp.RunSource(interp.EnableTracing, souce)
	if err != nil {
		panic(err)
	}
}

Issues
  • what's package name of subfolder that import it

    what's package name of subfolder that import it

    - io_extra/
      - file.go
    - main.go
    

    how to import io_extra/file.go in main.go?

    import "io_extra"
    

    panic:

    could not import io_extra (not found provider for types.Importer)

    enhancement 
    opened by fly-studio 1
  • buildPackage: update dump info

    buildPackage: update dump info

    • virtual
    • builtin
    • package
    # virtual internal/poll
    # builtin unsafe
    # builtin runtime
    # builtin sync/atomic
    # builtin sync
    # builtin errors
    # builtin syscall
    # builtin time
    # builtin io
    # builtin unicode/utf8
    # builtin path
    # builtin sort
    # builtin io/fs
    # builtin os
    # builtin math/bits
    # builtin math
    # builtin strconv
    # builtin unicode
    # builtin reflect
    # package internal/testlog /usr/local/go/src/internal/testlog
    
    opened by visualfc 0
  • unexpected type: *reflect.ValueError: reflect: call of reflect.Value.Call on zero Value

    unexpected type: *reflect.ValueError: reflect: call of reflect.Value.Call on zero Value

    package main
    
    import (
    	"fmt"
    	"os"
    )
    
    type fileInfoMeta struct {
    	os.FileInfo
    }
    
    func isSymlink(fi os.FileInfo) bool {
    	return fi != nil && fi.Mode()&os.ModeSymlink == os.ModeSymlink
    }
    
    func main() {
    	fi, err := os.Stat("./main.go")
    	if err != nil {
    		panic(err)
    	}
    	fmi := &fileInfoMeta{fi}
    	fmt.Println(isSymlink(fmi))
    }
    
    

    igop run main.go

    unexpected type: *reflect.ValueError: reflect: call of reflect.Value.Call on zero Value
    
    bug 
    opened by visualfc 0
  • parse.stateFn circle

    parse.stateFn circle

    package main
    
    import (
    	"fmt"
    
    	"github.com/goplus/igop"
    	_ "github.com/goplus/igop/pkg"
    )
    
    var src = `package main
    import _ "text/template/parse"
    
    func main() {
    }
    
    `
    
    func main() {
    	code, err := igop.RunFile("main.go", src, nil, 0)
    	fmt.Println(code, err)
    }
    
    
    opened by visualfc 0
  • bug binary.LittleEndian

    bug binary.LittleEndian

    package main
    
    import (
    	"bytes"
    	"encoding/binary"
    	"fmt"
    )
    
    func main() {
    	var buf bytes.Buffer
    	err := binary.Write(&buf, binary.LittleEndian, int8(1))
    	fmt.Println(buf, err)
    }
    

    igop run main.go

    cannot use binary.LittleEndian (variable of type binary.littleEndian) as binary.ByteOrder value in argument to binary.Write: missing method PutUint16 (PutUint16 has pointer receiver)
    
    bug 
    opened by visualfc 0
  • context import pkg from source

    context import pkg from source

    • support load package from GOMOD project source.
    • custome AddImport/AddImportDir
    func (c *Context) AddImport(path string, filename string, src interface{}) error
    func (c *Context) AddImportDir(path string, dir string) error
    
    opened by visualfc 0
  • Update  igop install command

    Update igop install command

    https://go.dev/doc/go-get-install-deprecation

    • Starting in Go 1.17, installing executables with go get is deprecated.
    • In Go 1.18, go get will no longer build packages.
    opened by si9ma 0
  • vendor support

    vendor support

    https://golang.org/ref/mod#go-mod-vendor https://go.dev/ref/mod#vendoring

    https://go.dev/ref/mod#build-commands The -mod flag controls whether go.mod may be automatically updated and whether the vendor directory is used. -mod=mod tells the go command to ignore the vendor directory and to automatically update go.mod, for example, when an imported package is not provided by any known module. -mod=readonly tells the go command to ignore the vendor directory and to report an error if go.mod needs to be updated. -mod=vendor tells the go command to use the vendor directory. In this mode, the go command will not use the network or the module cache. By default, if the go version in go.mod is 1.14 or higher and a vendor directory is present, the go command acts as if -mod=vendor were used. Otherwise, the go command acts as if -mod=readonly were used.

    enhancement 
    opened by visualfc 0
  • bug: ssa select case call expr order

    bug: ssa select case call expr order

    $GOROOT/test/chan/select5

    bug: golang.org/x/tools/go/ssa build order fp, fc

    package main
    
    var c = make(chan int, 1)
    var nilch chan int
    var n = 1
    var x int
    var i interface{}
    var dummy = make(chan int)
    var m = make(map[int]int)
    var order = 0
    
    // check order of operations by ensuring that
    // successive calls to checkorder have increasing o values.
    func checkorder(o int) {
    	if o <= order {
    		println("invalid order", o, "after", order)
    		panic("order")
    	}
    	order = o
    }
    
    func fc(c chan int, o int) chan int {
    	checkorder(o)
    	return c
    }
    
    func fp(p *int, o int) *int {
    	checkorder(o)
    	return p
    }
    
    func init() {
    	order = 0
    	c <- n
    	select {
    	case *fp(&x, 100) = <-fc(c, 1):
    	}
    	if x != n {
    		die(x)
    	}
    	n++
    }
    
    func die(x int) {
    	println("have", x, "want", n)
    	panic("chan")
    }
    
    func main() {
    }
    
    func init#1():
    0:                                                                entry P:0 S:2
    	*order = 0:int
    	t0 = *c                                                        chan int
    	t1 = *n                                                             int
    	send t0 <- t1
    	t2 = fp(x, 100:int)                                                *int
    	t3 = *c                                                        chan int
    	t4 = fc(t3, 1:int)                                             chan int
    	t5 = <-t4                                                           int
    	*t2 = t5
    	t6 = *x                                                             int
    	t7 = *n                                                             int
    	t8 = t6 != t7                                                      bool
    	if t8 goto 1 else 2
    1:                                                              if.then P:1 S:1
    	t9 = *x                                                             int
    	t10 = die(t9)                                                        ()
    	jump 2
    2:                                                              if.done P:2 S:0
    	t11 = *n                                                            int
    	t12 = t11 + 1:int                                                   int
    	*n = t12
    	return
    
    opened by visualfc 0
  • bug: golang fixedbugs/issue23017.go

    bug: golang fixedbugs/issue23017.go

    package main
    
    import (
    	"fmt"
    )
    
    func main() {
    	type P struct{ i int }
    	var m = map[int]int{}
    	var p *P
    
    	defer func() {
    		recover()
    		check(1, len(m))
    		check(3, m[2])
    	}()
    	m[2], p.i = 3, 2
    }
    
    func check(want, got int) {
    	if want != got {
    		panic(fmt.Sprintf("wanted %d, but got %d", want, got))
    	}
    }
    
    opened by visualfc 1
  • TODO: $GOROOT/test/fixedbugs

    TODO: $GOROOT/test/fixedbugs

    Go1.16

    • runtime runtime/debug unsupport
    runtime.Caller
    runtime.FuncForPC
    runtime.Stack
    debug.Stack
    runtime.ReadMemStats
    testing.AllocsPerRun
    
    • ssa bug

    fixedbugs/bug261.go: ssa slice[low|high], https://github.com/golang/tools/pull/341 fixedbugs/issue45175.go : ssa.Phi call order, use ssa.NaiveForm for disable phi-node

    • interp bug

    fixedbugs/issue32477.go: runtime.SetFinalizer fixedbugs/issue8606b.go: optimization check ~~fixedbugs/issue30116.go: slice bound check~~ ~~fixedbugs/issue7740.go: const float check~~

    fixedbugs/issue7740.go
    const ulp = (1.0 + (2.0 / 3.0)) - (5.0 / 3.0)
    Go 1.14 1.15 1.16 ulp = 1.4916681462400413e-154
    Go 1.17 1.18 ulp = 0
    

    fixedbugs skip list

    	gorootTestSkips["closure.go"] = "runtime.ReadMemStats"
    	gorootTestSkips["divmod.go"] = "timeout"
    	gorootTestSkips["copy.go"] = "slow"
    	gorootTestSkips["gcstring.go"] = "timeout"
    	gorootTestSkips["finprofiled.go"] = "slow"
    	gorootTestSkips["gcgort.go"] = "slow"
    	gorootTestSkips["inline_literal.go"] = "TODO, runtime.FuncForPC"
    	gorootTestSkips["nilptr.go"] = "skip drawin"
    	gorootTestSkips["recover.go"] = "TODO, fix test16"
    	gorootTestSkips["heapsampling.go"] = "runtime.MemProfileRecord"
    	gorootTestSkips["makeslice.go"] = "TODO, panic info, allocation size out of range"
    	gorootTestSkips["stackobj.go"] = "skip gc"
    	gorootTestSkips["stackobj3.go"] = "skip gc"
    	gorootTestSkips["nilptr_aix.go"] = "skip"
    	gorootTestSkips["init1.go"] = "skip gc"
    	gorootTestSkips["string_lit.go"] = "call to os.Exit(0) during test"
    	gorootTestSkips["switch.go"] = "call to os.Exit(0) during test"
    	gorootTestSkips["ken/divconst.go"] = "slow"
    	gorootTestSkips["ken/modconst.go"] = "slow"
    	gorootTestSkips["fixedbugs/bug347.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/bug348.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue24491b.go"] = "timeout"
    	gorootTestSkips["fixedbugs/issue22781.go"] = "slow"
    	gorootTestSkips["fixedbugs/issue16249.go"] = "slow"
    	gorootTestSkips["fixedbugs/issue13169.go"] = "slow"
    	gorootTestSkips["fixedbugs/bug261.go"] = "BUG, ssa slice[low|high] https://github.com/golang/tools/pull/341"
    	gorootTestSkips["fixedbugs/issue11656.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue15281.go"] = "runtime.ReadMemStats"
    	gorootTestSkips["fixedbugs/issue17381.go"] = "runtime.FuncForPC"
    	gorootTestSkips["fixedbugs/issue18149.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue22083.go"] = "debug.Stack"
    	gorootTestSkips["fixedbugs/issue22662.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue27201.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue27201.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue27518b.go"] = "BUG, runtime.SetFinalizer"
    	gorootTestSkips["fixedbugs/issue29504.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue32477.go"] = "BUG, runtime.SetFinalizer"
    	gorootTestSkips["fixedbugs/issue41239.go"] = "BUG, reflect.Append: different capacity on append"
    	gorootTestSkips["fixedbugs/issue32477.go"] = "BUG, runtime.SetFinalizer"
    	gorootTestSkips["fixedbugs/issue45175.go"] = "BUG, ssa.Phi call order"
    	gorootTestSkips["fixedbugs/issue4562.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue4618.go"] = "testing.AllocsPerRun"
    	gorootTestSkips["fixedbugs/issue4667.go"] = "testing.AllocsPerRun"
    	gorootTestSkips["fixedbugs/issue5856.go"] = "runtime.Caller"
    	gorootTestSkips["fixedbugs/issue5963.go"] = "BUG, recover"
    	gorootTestSkips["fixedbugs/issue7740.go"] = "BUG, const float"
    	gorootTestSkips["fixedbugs/issue7690.go"] = "runtime.Stack"
    	gorootTestSkips["fixedbugs/issue8606b.go"] = "BUG, optimization check"
    	gorootTestSkips["fixedbugs/issue30116u.go"] = "BUG, slice bound check"
    
    opened by visualfc 0
Releases(v0.8.6)
Owner
GoPlus
The GoPlus (Go+) Programming Language
GoPlus
bf.go - A dead simple brainfuck interpreter Slow and simple

bf.go - A dead simple brainfuck interpreter Slow and simple. Can execute pretty much all tested Brainfuck scripts. Installation If you have Go install

Chris 0 Oct 15, 2021
Official vilmos visual language interpreter!

vilmos interpreter - let's put software in museums ?? Uninstall all your IDE's, close the terminal, install your favourite drawing software and start

null 29 May 23, 2022
Golang CS:GO external base. Development currently halted due to compiler/runtime Golang bugs.

gogo Golang CS:GO External cheat/base. Also, my first Golang project. Wait! Development momentarily halted due to compiler/runtime bugs. Disclaimer Th

cristei 2 Jun 25, 2022
Belajar Golang Install Golang

Golang belajar Golang Install Golang = download di https://golang.org/dl/ = pilih yg Zip = extract file zipnya = buka foldernya - copy folder go = pas

Arif Fadilah 1 Nov 15, 2021
Golang-module-references - A reference for how to setup a Golang project with modules - Task Management + Math Examples

Golang Module Project The purpose of this project is to act as a reference for setting up future Golang projects using modules. This project has a mat

Bob Bass 0 Jan 2, 2022
Golang-echo-sample - Make an out-of-the-box backend based on golang-echo

Golang-echo-sample - Make an out-of-the-box backend based on golang-echo

Haitwang 0 Dec 31, 2021
Minimalistic, pluggable Golang evloop/timer handler with dependency-injection

Anagent Minimalistic, pluggable Golang evloop/timer handler with dependency-injection - based on codegangsta/inject - go-macaron/inject and chuckpresl

Ettore Di Giacinto 14 Jan 26, 2022
GoLang Library for Browser Capabilities Project

Browser Capabilities GoLang Project PHP has get_browser() function which tells what the user's browser is capable of. You can check original documenta

Maksim N. 41 Jul 22, 2022
Golang counters for readers/writers

Datacounter Golang counters for readers/writers. Examples ReaderCounter buf := bytes.Buffer{} buf.Write(data) counter := datacounter.NewReaderCounter(

Artem Andreenko 40 May 26, 2022
Golang beautify data display for Humans

Golang beautify data display for Humans English 简体中文 Install # Stable version go get -u -v gopkg.in/ffmt.v1 # Latest version go get -u -v github.com/

ffmt 275 Jul 26, 2022
a generic object pool for golang

Go Commons Pool The Go Commons Pool is a generic object pool for Golang, direct rewrite from Apache Commons Pool. Features Support custom PooledObject

jolestar 1.1k Aug 6, 2022
Resiliency patterns for golang

go-resiliency Resiliency patterns for golang. Based in part on Hystrix, Semian, and others. Currently implemented patterns include: circuit-breaker (i

Evan Huus 1.6k Aug 3, 2022
psutil for golang

gopsutil: psutil for golang This is a port of psutil (https://github.com/giampaolo/psutil). The challenge is porting all psutil functions on some arch

shirou 8.1k Aug 12, 2022
Type-safe Prometheus metrics builder library for golang

gotoprom A Prometheus metrics builder gotoprom offers an easy to use declarative API with type-safe labels for building and using Prometheus metrics.

Cabify 93 Jun 9, 2022
Simple licensing library for golang.

license-key A simple licensing library in Golang, that generates license files containing arbitrary data. Note that this implementation is quite basic

Hyperboloide 251 Jul 25, 2022
Some utilities for Persian language in Go (Golang)

persian Some utilities for Persian language in Go (Golang). Installation go get github.com/mavihq/persian API .ToPersianDigits Converts all English d

هلو | آموزش زبان با بازی 65 Aug 9, 2022
A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

Wei He 17 Mar 15, 2022
A golang URL Shortener

url-shortener A golang URL Shortener with mysql support. Using Bijective conversion between natural numbers (IDs) and short strings Installation Using

Leonidas Maroulis 36 Jun 24, 2022
:guardsman: A teeny tiny and somewhat opinionated generator for your next golang project

A Yeoman Golang Generator We are very sorry Gophers, but other names for the generator where taken, so we choose go-lang. But we have gocreate as an a

Axel Springer SE 24 Jun 17, 2022