Documentation ¶
Index ¶
- Constants
- func IsFastlySubroutine(name string) bool
- func ScopeString(s int) string
- type Accessor
- type BuiltinFunction
- type Context
- func (c *Context) AddAcl(name string, acl *types.Acl) error
- func (c *Context) AddBackend(name string, backend *types.Backend) error
- func (c *Context) AddDirector(name string, director *types.Director) error
- func (c *Context) AddGoto(name string, newGoto *types.Goto) error
- func (c *Context) AddPenaltybox(name string, penaltybox *types.Penaltybox) error
- func (c *Context) AddRatecounter(name string, ratecounter *types.Ratecounter) error
- func (c *Context) AddSubroutine(name string, subroutine *types.Subroutine) error
- func (c *Context) AddTable(name string, table *types.Table) error
- func (c *Context) AddUserDefinedFunction(name string, scopes int, returnType types.Type) error
- func (c *Context) CurrentFunction() string
- func (c *Context) Declare(name string, valueType types.Type, m *ast.Meta) error
- func (c *Context) Get(name string) (types.Type, error)
- func (c *Context) GetFunction(name string) (*BuiltinFunction, error)
- func (c *Context) GetRatecounterVariable(name string) (types.Type, error)
- func (c *Context) GetRegexGroupVariable(name string) (types.Type, error)
- func (c *Context) Mode() int
- func (c *Context) PushRegexVariables(matchN int) error
- func (c *Context) Restore() *Context
- func (c *Context) Scope(mode int) *Context
- func (c *Context) Set(name string) (types.Type, error)
- func (c *Context) Unset(name string) error
- func (c *Context) UserDefinedFunctionScope(name string, mode int, returnType types.Type) *Context
- type FunctionSpec
- type Functions
- type Object
- type Variables
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func IsFastlySubroutine ¶ added in v0.2.1
func ScopeString ¶
Types ¶
type BuiltinFunction ¶
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 (*Context) AddBackend ¶
func (*Context) AddDirector ¶
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) AddUserDefinedFunction ¶ added in v0.9.3
func (*Context) CurrentFunction ¶ added in v0.9.3
func (*Context) GetFunction ¶
func (c *Context) GetFunction(name string) (*BuiltinFunction, error)
func (*Context) GetRatecounterVariable ¶ added in v0.9.3
Get ratecounter variable
func (*Context) GetRegexGroupVariable ¶
Get regex group variable
func (*Context) PushRegexVariables ¶
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.
type FunctionSpec ¶
type FunctionSpec struct { Items map[string]*FunctionSpec Value *BuiltinFunction }
type Functions ¶
type Functions map[string]*FunctionSpec
Click to show internal directories.
Click to hide internal directories.