bytecode_interfaces

package
v0.0.0-...-2ff796e Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int

func Int(n uint8) int

func Uint8

func Uint8(n int8) uint8

Types

type Inst

type Inst struct {
	Op            Op
	Dst, Lhs, Rhs uint8
}

func Inst16

func Inst16(op Op, dst uint8, src int16) Inst

func (Inst) Src

func (i Inst) Src() int

type Op

type Op uint8

type Prog

type Prog struct {
	IP    int
	Code  []Inst
	Vars  []interface{}
	Outer *Prog
}

func BytecodeCollatz

func BytecodeCollatz() *Prog
  interpreted version of:

	func collatz(n int) {
		for n > 1 {
			if n&1 != 0 {
				n = ((n * 3) + 1) / 2
			} else {
				n = n / 2
			}
		}
	}

func BytecodeSum

func BytecodeSum(N int) *Prog
  bytecode version of:

	func sum(n int) int {
		total := 0
		for i := 1; i <= n; i++ {
			total += i
		}
		return total
	}

func (*Prog) Exec

func (p *Prog) Exec(IP int) []interface{}

Jump to

Keyboard shortcuts

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