# Code coverage report for lib/parser/ast/reference.js

## Statements: 94.44% (17 / 18) Branches: 83.33% (5 / 6) Functions: 100% (3 / 3) Lines: 94.12% (16 / 17) Ignored: none

All files » lib/parser/ast/ » reference.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    321

    1
    3459
    3459
    3459
    3459
    3459
    3459

    1

    111
    106

    117

    111
    5

    106

    1var BaseExpression = require("./base");

    function ReferenceExpression (path, bindingType) {
      this.path       = path;
      this.bindingType = bindingType;
      this.fast = bindingType === "^";
      this.unbound  = ["~", "~>"].indexOf(bindingType) !== -1;
      this._isBoundTo = ~["<~", "<~>", "~>"].indexOf(this.bindingType);
      BaseExpression.apply(this, arguments);
    }

    BaseExpression.extend(ReferenceExpression, {
      type: "reference",
      toJavaScript: function () {

        if (!this._isBoundTo)
        Iif (this.fast) {
          return "this.context." + this.path.join(".");
        }

        var path = this.path.map(function(p) { return "'"+p+"'"; }).join(', ');

        if (this._isBoundTo) {
          return "this.bindTo([" + path + "], "+(this.bindingType !== "<~")+")";
        }

        return "this.context.get([" + path + "])";
      }
    });

    module.exports = ReferenceExpression;