mutan

package module
v0.0.0-...-194e379 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2015 License: MIT Imports: 4 Imported by: 1

README

Compiler & Language definition for the Ethereum project

This is the Mutan 2.0 branch.

Mutan is a C-Like language for the Ethereum project. Mutan supports a full, dynamic higher level language that compiles to native Ethereum Assembler. The language definition and documentation can be found on go-ethereum wiki.

A simple online editor and compiler can be found here

Install compiler

go get -u github.com/obscuren/mutan/mutan

CLI

mutan [flags] filename
-s=""        Compile string
-asm         Output asm instead of bytecode/hex
-b           Output raw byte array instead of hex

Release notes

0.6 (develop)

  • const a = 10

0.5

  • Scoping using { var x = 10; }
  • Proper else if clauses if { } else if { } else { }
  • Added logical and / or var x = 1 && 2; if 1 && 0 { }
  • Changed the this keyword to message.

0.4

Didn't keep release notes :-)

Syntax

import "std.mu"

func fn(var a, var b) {
	var[2] c
	c[0] = a
	c[1] = b
	return c[1]
}

var a = fn(0, 1)
b := 10

if a > b {
    stop()
} else if 0 && 1 || 0 {
    // :-(
    stop()
} else {
    // :-)
    if !a {
        if message.data[0] ** 10 >= 10 {
            message.data[0] = 1000;
        }
    }
}

func ptrs(var * a) {
	*a = *a * 10;
}

ptrs(&a)

message.store[a] = 10000
message.store[b] = message.origin()

for i := 0; i < 10; i++ {
    var[10] out
    call(0xaabbccddeeff112233445566, 0, 10000, i, out)
}

// tx without input data
transact(0xa78f6abe, 10000, nil)
// no args and return values
call(0xab, 0, 10000, nil, nil)
// create contract
var ret = create(value, 0xaabbccddeeff0099887766552211)

asm {
    push1 10
    push1 0
    mstore
}

return 20

Mutan © Jeffrey Wilcke

Documentation

Index

Constants

View Source
const (
	Version = "0.6"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler struct {
	Backend CompilerBackend

	Debug bool

	Silent bool

	OptimizeCode bool
	// contains filtered or unexported fields
}

func NewCompiler

func NewCompiler(backend CompilerBackend) *Compiler

func (*Compiler) Assemble

func (self *Compiler) Assemble(source io.Reader) (asm []interface{}, errors []error)

func (*Compiler) AssemblerStage

func (self *Compiler) AssemblerStage(asm ...interface{}) ([]byte, error)

func (*Compiler) Compile

func (self *Compiler) Compile(source io.Reader) (bytecode []byte, errors []error)

func (*Compiler) CompileStage

func (self *Compiler) CompileStage(instrs *frontend.IntInstr) (asm []interface{}, err error)

func (*Compiler) Intermediate

func (self *Compiler) Intermediate(source io.Reader) (intCode *frontend.IntInstr, errors []error)

func (*Compiler) IntermediateStage

func (self *Compiler) IntermediateStage(code string) (intCode *frontend.IntInstr, errors []error)

func (*Compiler) Optimize

func (self *Compiler) Optimize(intCode *frontend.IntInstr) *frontend.IntInstr

func (*Compiler) PreProcessorStage

func (self *Compiler) PreProcessorStage(str string) (string, error)

func (*Compiler) ReadAll

func (self *Compiler) ReadAll(source io.Reader) (string, error)

type CompilerBackend

type CompilerBackend interface {
	Compile(*frontend.IntInstr) ([]interface{}, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL