context

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INIT    int = 0x000000000
	RECV    int = 0x000000001
	HASH    int = 0x000000010
	HIT     int = 0x000000100
	MISS    int = 0x000001000
	PASS    int = 0x000010000
	FETCH   int = 0x000100000
	ERROR   int = 0x001000000
	DELIVER int = 0x010000000
	LOG     int = 0x100000000
)

Variables

This section is empty.

Functions

func IsFastlySubroutine added in v0.2.1

func IsFastlySubroutine(name string) bool

func ScopeString

func ScopeString(s int) string

Types

type Accessor added in v0.0.7

type Accessor struct {
	Get       types.Type
	Set       types.Type
	Unset     bool
	Scopes    int
	Reference string
}

type BuiltinFunction

type BuiltinFunction struct {
	Arguments             [][]types.Type
	Return                types.Type
	Extra                 func(c *Context, name string) interface{}
	Scopes                int
	Reference             string
	IsUserDefinedFunction bool
}

type Context

type Context struct {
	Acls         map[string]*types.Acl
	Backends     map[string]*types.Backend
	Tables       map[string]*types.Table
	Directors    map[string]*types.Director
	Subroutines  map[string]*types.Subroutine
	Penaltyboxes map[string]*types.Penaltybox
	Ratecounters map[string]*types.Ratecounter
	Gotos        map[string]*types.Goto
	Identifiers  map[string]struct{}

	Variables      Variables
	RegexVariables map[string]int
	ReturnType     *types.Type
	// contains filtered or unexported fields
}

func New

func New() *Context

func (*Context) AddAcl

func (c *Context) AddAcl(name string, acl *types.Acl) error

func (*Context) AddBackend

func (c *Context) AddBackend(name string, backend *types.Backend) error

func (*Context) AddDirector

func (c *Context) AddDirector(name string, director *types.Director) error

func (*Context) AddGoto added in v0.9.3

func (c *Context) AddGoto(name string, newGoto *types.Goto) error

func (*Context) AddPenaltybox added in v0.9.3

func (c *Context) AddPenaltybox(name string, penaltybox *types.Penaltybox) error

func (*Context) AddRatecounter added in v0.9.3

func (c *Context) AddRatecounter(name string, ratecounter *types.Ratecounter) error

func (*Context) AddSubroutine

func (c *Context) AddSubroutine(name string, subroutine *types.Subroutine) error

func (*Context) AddTable

func (c *Context) AddTable(name string, table *types.Table) error

func (*Context) AddUserDefinedFunction added in v0.9.3

func (c *Context) AddUserDefinedFunction(name string, scopes int, returnType types.Type) error

func (*Context) CurrentFunction added in v0.9.3

func (c *Context) CurrentFunction() string

func (*Context) Declare

func (c *Context) Declare(name string, valueType types.Type, m *ast.Meta) error

func (*Context) Get

func (c *Context) Get(name string) (types.Type, error)

func (*Context) GetFunction

func (c *Context) GetFunction(name string) (*BuiltinFunction, error)

func (*Context) GetRatecounterVariable added in v0.9.3

func (c *Context) GetRatecounterVariable(name string) (types.Type, error)

Get ratecounter variable

func (*Context) GetRegexGroupVariable

func (c *Context) GetRegexGroupVariable(name string) (types.Type, error)

Get regex group variable

func (*Context) Mode

func (c *Context) Mode() int

func (*Context) PushRegexVariables

func (c *Context) PushRegexVariables(matchN int) error

Regex variables, "re.group.N" is a special variable in VCL. These variables could use if(else) block statement when condition has regex operator like "~" or "!~". Note that group matched variable has potential of making bugs due to its spec: 1. re.group.N variable scope is subroutine-global, does not have block scope 2. matched value may override on second regex matching

For example:

``` declare local var.S STRING; set var.S = "foo bar baz";

if (req.http.Host) {
	if (var.S) {
		if (var.S !~ "(foo)\s(bar)\s(baz)") { // make matched values first (1)
			set req.http.First = "1";
		}
		set var.S = "hoge huga";
		if (var.S ~ "(hoge)\s(huga)") { // override matched values (2)
			set req.http.First = re.group.1;
		}
	}
	set req.http.Third = re.group.2; // difficult to know which (1) or (2) matched result is used
}
if (req.http.Host) {
	set req.http.Fourth = re.group.3; // difficult to know which (1) or (2) matched result is used or empty
}

```

Therefore we will raise warning if matched value is overridden in subroutine.

func (*Context) Restore

func (c *Context) Restore() *Context

func (*Context) Scope

func (c *Context) Scope(mode int) *Context

func (*Context) Set

func (c *Context) Set(name string) (types.Type, error)

func (*Context) Unset

func (c *Context) Unset(name string) error

func (*Context) UserDefinedFunctionScope added in v0.9.3

func (c *Context) UserDefinedFunctionScope(name string, mode int, returnType types.Type) *Context

type FunctionSpec

type FunctionSpec struct {
	Items map[string]*FunctionSpec
	Value *BuiltinFunction
}

type Functions

type Functions map[string]*FunctionSpec

type Object

type Object struct {
	Items  map[string]*Object
	Value  *Accessor
	IsUsed bool
	Meta   *ast.Meta
}

type Variables

type Variables map[string]*Object

Jump to

Keyboard shortcuts

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