qlang

package module
v0.0.0-...-e9920c5 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 10 Imported by: 3

README

qlang

A revised version of Qlang, thanks to https://github.com/qiniu/qlang.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Exports = map[string]interface{}{
	"new": New,
	"New": New,
}

Exports is the export table of this module.

View Source
var (
	// InsertSemis is interpreter options that means to insert semis smartly.
	InsertSemis = (*Options)(interpreter.InsertSemis)
)

Functions

func Debug

func Debug(fn func())

Debug sets dump code mode to "1" for debug.

func IfSwitchExists

func IfSwitchExists(argsA []string, switchStrA string) bool

func Import

func Import(mod string, table map[string]interface{})

Import imports a module written in Go.

func SetAutoCall

func SetAutoCall(t reflect.Type)

SetAutoCall is reserved for internal use.

func SetDumpCode

func SetDumpCode(dumpCode string)

SetDumpCode sets dump code mode:

"1" - dump code with rem instruction.
"2" - dump code without rem instruction.
else - don't dump code.

func SetFindEntry

func SetFindEntry(fn func(file string, libs []string) (string, error))

SetFindEntry sets the `FindEntry` function.

func SetOnPop

func SetOnPop(fn func(v interface{}))

SetOnPop sets OnPop callback.

func SetReadFile

func SetReadFile(fn func(file string) ([]byte, error))

SetReadFile sets the `ReadFile` function.

Types

type Options

type Options interpreter.Options

Options represent interpreter options.

type Qlang

type Qlang struct {
	*exec.Context
	Cpl *qcl.Compiler
}

A Qlang represents the qlang compiler and executor.

func New

func New(optionsA ...string) *Qlang

New returns a new qlang instance.

func (*Qlang) Cl

func (p *Qlang) Cl(codeText []byte, fname string) (end int, err error)

Cl compiles a source code.

func (*Qlang) DumpEngine

func (p *Qlang) DumpEngine() error

func (*Qlang) Eval

func (p *Qlang) Eval(expr string) (err error)

Eval compiles and executes a source code.

func (*Qlang) Exec

func (p *Qlang) Exec(codeText []byte, fname string) (err error)

Exec compiles and executes a source code.

func (*Qlang) InjectMethods

func (p *Qlang) InjectMethods(pcls interface{}, code []byte) (err error)

InjectMethods injects some methods into a class. `pcls` can be a `*exec.Class` object or a `string` typed class name.

func (*Qlang) Run

func (p *Qlang) Run() (err error)

func (*Qlang) SafeCl

func (p *Qlang) SafeCl(codeText []byte, fname string) (end int, err error)

SafeCl compiles a source code, without panic (will convert panic into an error).

func (*Qlang) SafeEval

func (p *Qlang) SafeEval(expr string) (err error)

SafeEval compiles and executes a source code, without panic (will convert panic into an error).

func (*Qlang) SafeExec

func (p *Qlang) SafeExec(code []byte, fname string) (err error)

SafeExec compiles and executes a source code, without panic (will convert panic into an error).

func (*Qlang) SetLibs

func (p *Qlang) SetLibs(libs string)

SetLibs sets lib paths for searching modules.

func (*Qlang) TXCompile

func (p *Qlang) TXCompile(srcA string) (err error)

Directories

Path Synopsis
cl
cmd
eql
lib
fmt
io
log
net
os

Jump to

Keyboard shortcuts

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