Compiler (#37)

* refactored structs so the scope is not needed anymore + fix passing struct in func arguments.

* implemented byte arrays and added runtime tests

* Added sc examples in compiler README + added quick nested if test.

* Updated README

* Changed import paths to interop layer
This commit is contained in:
Anthony De Meulemeester 2018-03-02 16:49:10 +01:00 committed by GitHub
parent 16ab1d524f
commit b6b8542caf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 21 additions and 12 deletions

View file

@ -1 +1 @@
0.20.0
0.21.0

0
pkg/smartcontract/.keep Normal file
View file

View file

@ -66,8 +66,8 @@ func Main() bool {
package mytoken
import (
"github.com/CityOfZion/neo-go/pkg/smartcontract/runtime"
"github.com/CityOfZion/neo-go/pkg/smartcontract/storage"
"github.com/CityOfZion/neo-go/pkg/vm/smartcontract/runtime"
"github.com/CityOfZion/neo-go/pkg/vm/smartcontract/storage"
)
var owner = []byte{0xaf, 0x12, 0xa8, 0x68, 0x7b, 0x14, 0x94, 0x8b, 0xc4, 0xa0, 0x08, 0x12, 0x8a, 0x55, 0x0a, 0x63, 0x69, 0x5b, 0xc1, 0xa5}

View file

@ -6,7 +6,7 @@ var runtimeTestCases = []testCase{
`
package foo
import "github.com/CityOfZion/neo-go/pkg/smartcontract/runtime"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/runtime"
func Main() bool {
runtime.Notify("hello")
@ -20,7 +20,7 @@ var runtimeTestCases = []testCase{
`
package foo
import "github.com/CityOfZion/neo-go/pkg/smartcontract/runtime"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/runtime"
func Main() bool {
runtime.Log("hello you there!")
@ -34,7 +34,7 @@ var runtimeTestCases = []testCase{
`
package foo
import "github.com/CityOfZion/neo-go/pkg/smartcontract/runtime"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/runtime"
func Main() int {
t := runtime.GetTime()
@ -48,7 +48,7 @@ var runtimeTestCases = []testCase{
`
package foo
import "github.com/CityOfZion/neo-go/pkg/smartcontract/runtime"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/runtime"
func Main() int {
trigger := runtime.GetTrigger()
@ -68,7 +68,7 @@ var runtimeTestCases = []testCase{
`
package foo
import "github.com/CityOfZion/neo-go/pkg/smartcontract/runtime"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/runtime"
func Main() int {
owner := []byte{0xaf, 0x12, 0xa8, 0x68, 0x7b, 0x14, 0x94, 0x8b, 0xc4, 0xa0, 0x08, 0x12, 0x8a, 0x55, 0x0a, 0x63, 0x69, 0x5b, 0xc1, 0xa5}
@ -86,7 +86,7 @@ var runtimeTestCases = []testCase{
`
package foo
import "github.com/CityOfZion/neo-go/pkg/smartcontract/runtime"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/runtime"
func Main() int {
block := runtime.GetCurrentBlock()

View file

@ -6,7 +6,7 @@ var storageTestCases = []testCase{
`
package foo
import "github.com/CityOfZion/neo-go/pkg/smartcontract/storage"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/storage"
func Main() int {
ctx := storage.GetContext()

View file

@ -1,6 +1,6 @@
package runtime
import "github.com/CityOfZion/neo-go/pkg/smartcontract/types"
import "github.com/CityOfZion/neo-go/pkg/vm/smartcontract/types"
// CheckWitness verifies if the invoker is the owner of the contract.
func CheckWitness(hash []byte) bool {

View file

@ -0,0 +1,9 @@
package types
// Block represents a block in the blockchain.
type Block struct{}
// Index returns the height of the block.
func (b Block) Index() int {
return 0
}

View file

@ -1,6 +1,6 @@
package vm
// Syscalls is a mapping between the syscall function name
// Syscalls are a mapping between the syscall function name
// and the registerd VM interop API.
var Syscalls = map[string]string{
// Storage API