Compiler (#23)

* implemented add, mul, div, sub assign for identifiers.

* Implemented struct field initialization.

* Implemented imports

* Implemented storage VM API (interop layer) + additional bug fixes when encountered.

* Bumped version 0.12.0

* fixed double point extension on compiled output file.

* Fixed bug where callExpr in returns where added to voidCall

* fixed binExpr compare equal

* Check the env for the gopath first

* removed travis.yml

* custom types + implemented general declarations.

* commented out the storage test to make the build pass
This commit is contained in:
Anthony De Meulemeester 2018-02-24 10:06:48 +01:00 committed by GitHub
parent bebdabab9f
commit 23cfebf621
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 798 additions and 117 deletions

View file

@ -58,7 +58,9 @@ func emitBytes(w *bytes.Buffer, b []byte) error {
)
if n == 0 {
return errors.New("cannot emit 0 bytes")
// The VM expects a pushf (0x00).
// Empty strings on the stack for example.
return emitOpcode(w, vm.Opushf)
}
if n <= int(vm.Opushbytes75) {
return emit(w, vm.Opcode(n), b)
@ -80,6 +82,16 @@ func emitBytes(w *bytes.Buffer, b []byte) error {
return err
}
func emitSyscall(w *bytes.Buffer, api string) error {
if len(api) == 0 {
return errors.New("syscall api cannot be of length 0")
}
buf := make([]byte, len(api)+1)
buf[0] = byte(len(api))
copy(buf[1:len(buf)], []byte(api))
return emit(w, vm.Osyscall, buf)
}
func emitCall(w *bytes.Buffer, op vm.Opcode, label int16) error {
return emitJmp(w, op, label)
}