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

## Statements: 100% (17 / 17) Branches: 100% (6 / 6) Functions: 100% (2 / 2) Lines: 100% (17 / 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
    32
    33
    34
    35
    361

    1

    3981
    3981
    3981
    3981
    3981

    3981

    1

    151
    139
    1

    150

    150
    12

    138

    1
     var 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)
        if (this.fast) {
          return "this.context." + this.path.join(".");
        }

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

        var path = this.path.join(".");

        if (this._isBoundTo) {
          return "this.reference('" + path + "', " + (this.bindingType !== "<~") + ", " + (this.bindingType !== "~>") + ")";
        }

        return "this.get('" + path + "')";
      }
    });

    module.exports = ReferenceExpression;