Documentation ¶
Overview ¶
Package gojis provides a high level API for interaction with ECMAScript code.
Index ¶
Constants ¶
const ( TypeUnknown = iota TypeUndefined TypeNull TypeBoolean TypeString TypeSymbol TypeNumber TypeObject )
Available types. TypeUnknown must not be used. If it appears, this indicates, that somewhere the type was not set (it is the default value for Type).
const (
// Null represents the Null ECMAScript language value.
Null = null(0)
)
const (
// Undefined represents the Undefined ECMAScript language value.
Undefined = undefined(0)
)
Variables ¶
var Opts = optStruct{}
Opts represents functional options.
Functions ¶
This section is empty.
Types ¶
type Args ¶
type Args struct {
// contains filtered or unexported fields
}
Args represent the arguments that are passed to a function call. The arguments can be retrieved using Args#Get(int), and can be used in the function. The arguments are Objects, which can be Null or Undefined. If 3 arguments are passed to the function, args.Get(5) will return Undefined, NOT nil.
func (*Args) Get ¶
Get returns the argument at the given index. If there is no such argument, Undefined will be returned. This method never returns nil.
type Console ¶
Console is an io.Writer that is also an Object.
func NewConsole ¶
NewConsole creates a ready to use console that can be used inside a VM.
type Object ¶
type Object interface { // Lookup returns a property of this object with the given name. If no such // property exists, Undefined will be returned. This method never returns nil. Lookup(string) Object // SetFunction adds a property (more specific, a function object) to this // object. When the function object is invoked, the given function will be // executed, with all parameters wrapped into the Args object. SetFunction(string, func(Args) Object) // CallWithArgs attempts to invoke this objects 'Call' property. Note that this // property is only set if this object is a function or constructor object. If // this object does not have a 'Call' property that is callable, an error will // be returned. CallWithArgs(...interface{}) (Object, error) // SetObject adds a property with the given name to this object. The property's // value will be the given object. SetObject(string, Object) // IsUndefined is used to determine whether this object represents the Undefined // value. IsUndefined() bool // IsNull is used to determine whether this object represents the Null value. IsNull() bool // IsFunction is used to determine whether this object can be invoked. If this // returns true, CallWithArgs will not return an error. IsFunction() bool // Type returns the ECMAScript language type of this object. Type() Type // Value returns the Go value corresponding to the ECMAScript language value of // this object. Value() interface{} }
Object represents any ECMAScript language value. This can be a String or a Number as well as Null or Undefined. To check if the object represents Null, use Object#IsNull. To check if the object represents Undefined, use Object#IsUndefined.
type VM ¶
type VM struct { Object // the global object // contains filtered or unexported fields }
VM represents an instance of the GojisVM. It can be used to evaluate ECMAScript code.
func (*VM) SetConsole ¶
SetConsole is used to change the console of the VM. Calls like 'console.log' will be written to the given Console.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
examples
|
|
internal
|
|
parser
Package parser implements means to parse ECMAScript code that can be provided by different sources.
|
Package parser implements means to parse ECMAScript code that can be provided by different sources. |
parser/ast
Code generated by "aststring"; DO NOT EDIT.
|
Code generated by "aststring"; DO NOT EDIT. |
parser/matcher
Package matcher implements matchers that efficiently let you determine whether a rune is part of a previously defined rune set.
|
Package matcher implements matchers that efficiently let you determine whether a rune is part of a previously defined rune set. |
parser/token
Package token contains token types and a token stream implementation that can be used by lexers and parsers.
|
Package token contains token types and a token stream implementation that can be used by lexers and parsers. |
runtime/lang
Package lang contains all ECMAScript-specified language values, i.e.
|
Package lang contains all ECMAScript-specified language values, i.e. |
tool/analysis/ctxfunc
Package ctxfunc implements an analyzer that checks if a context argument is always the first parameter to a function, and that it is named 'ctx'.
|
Package ctxfunc implements an analyzer that checks if a context argument is always the first parameter to a function, and that it is named 'ctx'. |
tool/analysis/nopanic
Package nopanic implements an analyzer that checks if somewhere in the source, there is a panic.
|
Package nopanic implements an analyzer that checks if somewhere in the source, there is a panic. |
tool/snapshot
Package snapshot is used to create and read byte dumps of objects.
|
Package snapshot is used to create and read byte dumps of objects. |
tool/test262
Package test262 provides helper tools to extract metadata from Test262 files.
|
Package test262 provides helper tools to extract metadata from Test262 files. |