c6: github.com/c9s/c6/runtime Index | Files

package runtime

import "github.com/c9s/c6/runtime"


Package Files

color.go compare.go compute.go context.go expr_reduce.go number.go optimizer.go stack.go


const ValueTypeNum = 7

func CanReduceExpr Uses

func CanReduceExpr(expr ast.Expr) bool

func Compute Uses

func Compute(op *ast.Op, a ast.Value, b ast.Value) ast.Value

func EvaluateBinaryExpr Uses

func EvaluateBinaryExpr(expr *ast.BinaryExpr, context *Context) ast.Value

EvaluateBinaryExpr recursively.

func EvaluateBinaryExprInBooleanContext Uses

func EvaluateBinaryExprInBooleanContext(expr *ast.BinaryExpr, context *Context) ast.Value

func EvaluateExpr Uses

func EvaluateExpr(expr ast.Expr, context *Context) ast.Value

EvaluateExpr calls EvaluateBinaryExpr. except EvaluateExpr prevents calculate css slash as division. otherwise it's the same as EvaluateBinaryExpr.

func EvaluateExprInBooleanContext Uses

func EvaluateExprInBooleanContext(anyexpr ast.Expr, context *Context) ast.Value

func EvaluateFunctionCall Uses

func EvaluateFunctionCall(fcall ast.FunctionCall, context *Context) ast.Value

func EvaluateUnaryExpr Uses

func EvaluateUnaryExpr(expr *ast.UnaryExpr, context *Context) ast.Value

func EvaluateUnaryExprInBooleanContext Uses

func EvaluateUnaryExprInBooleanContext(expr *ast.UnaryExpr, context *Context) ast.Value

func HexColorAddNumber Uses

func HexColorAddNumber(c *ast.HexColor, num *ast.Number) *ast.HexColor

func HexColorDivNumber Uses

func HexColorDivNumber(color *ast.HexColor, num *ast.Number) *ast.HexColor

func HexColorMulNumber Uses

func HexColorMulNumber(color *ast.HexColor, num *ast.Number) *ast.HexColor

func HexColorSubNumber Uses

func HexColorSubNumber(c *ast.HexColor, num *ast.Number) *ast.HexColor

func IsComparable Uses

func IsComparable(av ast.Value, bv ast.Value) bool

func IsSimpleExpr Uses

func IsSimpleExpr(expr ast.Expr) bool

A simple expression means the operands are scalar, and can be evaluated.

func IsValue Uses

func IsValue(val ast.Expr) bool

This function returns true when the val is a scalar value, not an expression.

func NumberAddNumber Uses

func NumberAddNumber(a *ast.Number, b *ast.Number) *ast.Number

func NumberComparable Uses

func NumberComparable(a *ast.Number, b *ast.Number) bool

func NumberDivNumber Uses

func NumberDivNumber(a *ast.Number, b *ast.Number) *ast.Number

10px / 3, 10 / 3, 10px / 10px is allowed here

func NumberMulNumber Uses

func NumberMulNumber(a *ast.Number, b *ast.Number) *ast.Number

3 * 10px, 10px * 3, 10px * 10px is allowed here

func NumberSubNumber Uses

func NumberSubNumber(a *ast.Number, b *ast.Number) *ast.Number

func OptimizeIfStmt Uses

func OptimizeIfStmt(parentBlock *ast.Block, stm *ast.IfStmt)

func RGBAColorAddNumber Uses

func RGBAColorAddNumber(c *ast.RGBAColor, n *ast.Number) *ast.RGBAColor

func RGBAColorDivNumber Uses

func RGBAColorDivNumber(c *ast.RGBAColor, n *ast.Number) *ast.RGBAColor

func RGBAColorMulNumber Uses

func RGBAColorMulNumber(c *ast.RGBAColor, n *ast.Number) *ast.RGBAColor

func RGBAColorSubNumber Uses

func RGBAColorSubNumber(c *ast.RGBAColor, n *ast.Number) *ast.RGBAColor

func RGBColorAddNumber Uses

func RGBColorAddNumber(c *ast.RGBColor, n *ast.Number) *ast.RGBColor

func RGBColorDivNumber Uses

func RGBColorDivNumber(c *ast.RGBColor, n *ast.Number) *ast.RGBColor

func RGBColorMulNumber Uses

func RGBColorMulNumber(c *ast.RGBColor, n *ast.Number) *ast.RGBColor

func RGBColorSubNumber Uses

func RGBColorSubNumber(c *ast.RGBColor, n *ast.Number) *ast.RGBColor

func ReduceExpr Uses

func ReduceExpr(expr ast.Expr, context *Context) (ast.Value, bool)

Reduce constant expression to constant.

@return (Value, ok)

ok = true means the expression is reduced to simple constant.

The difference between Evaluate*Expr method is:

- `ReduceExpr` returns either value or expression (when there is an unsolved expression) - `EvaluateBinaryExpr` returns nil if there is an unsolved expression.

type ComputeError Uses

type ComputeError struct {
    Message string
    Left    ast.Value
    Right   ast.Value

Used for Incompatible unit, data type or unsupported operations

TODO: This is not used yet. our compute functions should return error if possible

func (ComputeError) Error Uses

func (self ComputeError) Error() string

type ComputeFunction Uses

type ComputeFunction func(a ast.Value, b ast.Value) ast.Value


type Context Uses

type Context struct {
    RuleSetStack []*ast.RuleSet
    GlobalBlock  *ast.Block
    Mixins       *symtable.SymTable
    Functions    *symtable.SymTable
    Stack        *Stack
    ImportedPath map[string]bool

* The Context contains all runtime variables and ruleset stack

func NewContext Uses

func NewContext() *Context

func (*Context) CurrentBlock Uses

func (context *Context) CurrentBlock() ast.BlockNode

func (*Context) GetVariable Uses

func (context *Context) GetVariable(name string) (interface{}, bool)

func (*Context) PopRuleSet Uses

func (context *Context) PopRuleSet() (*ast.RuleSet, bool)

func (*Context) PushRuleSet Uses

func (context *Context) PushRuleSet(ruleSet *ast.RuleSet)

func (*Context) TopRuleSet Uses

func (context *Context) TopRuleSet() *ast.RuleSet

type Stack Uses

type Stack struct {
    Values []ast.Expr

func (*Stack) Pop Uses

func (stack *Stack) Pop() ast.Expr

func (*Stack) Push Uses

func (stack *Stack) Push(arg ast.Expr)

Package runtime imports 4 packages (graph) and is imported by 4 packages. Updated 2017-10-13. Refresh now. Tools for package owners.