expressiongenerator

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: BSD-3-Clause Imports: 8 Imported by: 2

Documentation

Overview

expressiongenerator defines code for translating from CodeDOM expressions into esbuilder ExpressionBuilder objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncOption

type AsyncOption int

AsyncOption defines the various options around asynchrounous expression generation.

const (
	// AllowedSync indicates that GenerateExpression can return a synchronous expression.
	AllowedSync AsyncOption = iota

	// EnsureAsync indicates that GenerateExpression must return an asynchronous expression.
	// If the provided expression is synchronous, it will be wrapped in a new promise.
	EnsureAsync
)

type ByKey

ByKey is a helper to sort ObjectLiteralEntryNode's.

func (ByKey) Len

func (s ByKey) Len() int

func (ByKey) Less

func (s ByKey) Less(i, j int) bool

func (ByKey) Swap

func (s ByKey) Swap(i, j int)

type ExpressionResult

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

ExpressionResult represents the result of generating an expression.

func GenerateExpression

func GenerateExpression(expression codedom.Expression, asyncOption AsyncOption, scopegraph *scopegraph.ScopeGraph,
	machineBuilder StateMachineBuilder) ExpressionResult

GenerateExpression generates the full ES5 expression for the given CodeDOM expression representation.

func (ExpressionResult) Build

Build returns the builder for this expression.

func (ExpressionResult) BuildWrapped

func (er ExpressionResult) BuildWrapped(wrappingTemplateStr string, data interface{}) esbuilder.SourceBuilder

BuildWrapped returns the builder for this expression. If specified, the expression will be wrapped via the given template string. The original expression builder reference will be placed into a template field with name "ResultExpr", while any data passed into this method will be placed into "Data".

func (ExpressionResult) IsAsync

func (er ExpressionResult) IsAsync() bool

IsAsync returns true if the generated expression is asynchronous.

func (ExpressionResult) Variables

func (er ExpressionResult) Variables() []string

Variables returns the names of all variables generated by the expression.

type StateMachineBuilder

type StateMachineBuilder func(body codedom.StatementOrExpression, functionTraits shared.StateFunctionTraits) esbuilder.SourceBuilder

Jump to

Keyboard shortcuts

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