agent

package
v0.0.0-...-4ed146b Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ExecutionContextStack *ExecutionContextStack

	LittleEndian       bool
	CanBlock           bool
	Signifier          ID
	IsLockFree1        bool
	IsLockFree2        bool
	CandidateExecution interface{} // #37: Implement Table 26, CandidateExecutionRecord

	ScriptJobs  *job.Queue
	PromiseJobs *job.Queue
}

Agent comprises a set of ECMAScript execution contexts, an execution context stack, a running execution context, a set of named job queues, an Agent Record, and an executing thread. Except for the executing thread, the constituents of an agent belong exclusively to that agent. An agent's executing thread executes the jobs in the agent's job queues on the agent's execution contexts independently of other agents, except that an executing thread may be used as the executing thread by multiple agents, provided none of the agents sharing the thread have an Agent Record whose [[CanBlock]] property is true. While an agent's executing thread executes the jobs in the agent's job queues, the agent is the surrounding agent for the code in those jobs. The code uses the surrounding agent to access the specification level execution objects held within the agent: the running execution context, the execution context stack, the named job queues, and the Agent Record's fields. Agent is specified in 8.7.

func New

func New() *Agent

New creates a new agent that is ready to use.

func (*Agent) AgentCanSuspend

func (a *Agent) AgentCanSuspend() bool

AgentCanSuspend returns the CanBlock value of the agent.

func (*Agent) AgentSignifier

func (a *Agent) AgentSignifier() ID

AgentSignifier returns the Signifier of the agent.

func (*Agent) EnqueueJob

func (a *Agent) EnqueueJob(q QueueKind, jobName string, arguments []lang.Value)

EnqueueJob enqueues a new job into a given kind of queue, script or promise. EnqueueJob is specified in 8.4.1.

func (*Agent) GetActiveScriptOrModule

func (a *Agent) GetActiveScriptOrModule() lang.InternalValue

GetActiveScriptOrModule returns the active script or module. GetActiveScriptOrModule is specified in 8.3.1.

func (*Agent) GetGlobalObject

func (a *Agent) GetGlobalObject() lang.Value

GetGlobalObject returns the global object used by the running execution context. GetGlobalObject is specified in 8.3.6.

func (*Agent) GetNewTarget

func (a *Agent) GetNewTarget() lang.Value

GetNewTarget determines the NewTarget using the lexical environment of the running execution context. GetNewTarget is specified in 8.3.5.

func (*Agent) GetThisEnvironment

func (a *Agent) GetThisEnvironment() binding.Environment

GetThisEnvironment returns the current environment that currently supplies the binding for the keyword 'this'. GetThisEnvironment is specified in 8.3.3.

func (*Agent) InitializeHostDefinedRealm

func (a *Agent) InitializeHostDefinedRealm()

InitializeHostDefinedRealm is specified in 8.5.

func (*Agent) ResolveBinding

func (a *Agent) ResolveBinding(name lang.String, env binding.Environment) *binding.Reference

ResolveBinding is used to determine the binding with the given name. The optional argument env can be used to explicitly provide the Lexical Environment that is to be searched for the binding. During execution of ECMAScript code, ResolveBinding is performed using the following algorithm. ResolveBinding is specified in 8.3.2.

func (*Agent) ResolveThisBinding

func (a *Agent) ResolveThisBinding() (lang.Value, errors.Error)

ResolveThisBinding determines the binding of the keyword 'this' using the LexicalEnvironment of the running execution context. ResolveThisBinding is specified in 8.3.4.

func (*Agent) RunJobs

func (a *Agent) RunJobs()

RunJobs is specified in 8.6.

func (*Agent) RunningExecutionContext

func (a *Agent) RunningExecutionContext() *ExecutionContext

RunningExecutionContext returns the currently executing ExecutionContext of this agent.

type ExecutionContext

type ExecutionContext struct {
	Function       lang.Value // Object or Null
	Realm          *realm.Realm
	ScriptOrModule lang.InternalValue

	LexicalEnvironment  binding.Environment
	VariableEnvironment binding.Environment

	Generator interface{} // #41: Table 23, GeneratorObject
}

ExecutionContext is a specification device that is used to track the runtime evaluation of code by an ECMAScript implementation. At any point in time, there is at most one execution context per agent that is actually executing code. This is known as the agent's running execution context. All references to the running execution context in this specification denote the running execution context of the surrounding agent. ExecutionContext is specified in 8.3.

type ExecutionContextStack

type ExecutionContextStack struct {
	// contains filtered or unexported fields
}

ExecutionContextStack is a stack that is used to keep track of the currently executing and soon to execute ExecutionContexts. ExecutionContextStack is mentioned in 8.3.

func NewExecutionContextStack

func NewExecutionContextStack() *ExecutionContextStack

NewExecutionContextStack creates a new ExecutionContextStack that is using a SliceStack.

func (ExecutionContextStack) IsEmpty

func (s ExecutionContextStack) IsEmpty() bool

IsEmpty is used to determine if there are any ExecutionContexts on the stack.

func (ExecutionContextStack) Peek

Peek returns the topmost ExecutionContext without removing it.

func (ExecutionContextStack) Pop

Pop removes the topmost ExecutionContext from the stack and returns it.

func (ExecutionContextStack) Push

Push adds a new ExecutionContext to the stack.

type ID

type ID ulid.ULID

ID is a type alias for uuid.UUID, in order to be independent of uuid.UUID as a unique identifier.

func NewID

func NewID() ID

NewID returns a new ID that is guaranteed to be globally unique.

type QueueKind

type QueueKind uint8

QueueKind represents the description of 8.4, Table 25.

const (
	QueueUnknown QueueKind = iota
	QueueScript
	QueuePromise
)

Available QueueKinds. QueueUnknown indicates a severe programming error, since that value must never be used. It is the default value for QueueKind and indicates that something has not been initialized properly.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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