Documentation ¶
Index ¶
- Constants
- func CanAccessVariableInScope(objScope int, objReference, name string, currentScope int) error
- func IsFastlySubroutine(name string) bool
- func ScopeString(s int) string
- func ScopesString(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) IsStateMachineMethod() bool
- func (c *Context) Mode() int
- func (c *Context) PushRegexVariables(matchN int) error
- func (c *Context) Resolver() resolver.Resolver
- func (c *Context) Restore() *Context
- func (c *Context) Scope(mode int) *Context
- func (c *Context) Set(name string) (types.Type, error)
- func (c *Context) Snippets() *snippets.Snippets
- 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 Option
- type Variables
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func CanAccessVariableInScope ¶ added in v0.9.3
func IsFastlySubroutine ¶ added in v0.2.1
func ScopeString ¶
func ScopesString ¶ added in v0.9.3
Types ¶
type BuiltinFunction ¶
type Context ¶
type Context struct { Variables Variables // public fields 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{} RegexVariables map[string]int ReturnType *types.Type CurrentSubroutine *ast.SubroutineDeclaration // 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) IsStateMachineMethod ¶ added in v0.22.0
Returns true if statement/expression is inside state-mechine subroutine like "vcl_recv", fastly reserved one
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
type Option ¶ added in v0.9.3
type Option func(c *Context)