Sha256: e9f230d8861d3169d724f8035ef9d6af96fc7cad0550d3e736bb3e94450aeb1e

Contents?: true

Size: 1.52 KB

Versions: 13

Compression:

Stored size: 1.52 KB

Contents

#ifndef SASS_BACKTRACE_H
#define SASS_BACKTRACE_H

#include <sstream>

#include "file.hpp"
#include "position.hpp"

namespace Sass {


  struct Backtrace {

    Backtrace*  parent;
    ParserState pstate;
    std::string      caller;

    Backtrace(Backtrace* prn, ParserState pstate, std::string c)
    : parent(prn),
      pstate(pstate),
      caller(c)
    { }

    std::string to_string(bool warning = false)
    {
      size_t i = -1;
      std::stringstream ss;
      std::string cwd(Sass::File::get_cwd());
      Backtrace* this_point = this;

      if (!warning) ss << std::endl << "Backtrace:";
      // the first tracepoint (which is parent-less) is an empty placeholder
      while (this_point->parent) {

        // make path relative to the current directory
        std::string rel_path(Sass::File::abs2rel(this_point->pstate.path, cwd, cwd));

        if (warning) {
          ss << std::endl
             << "\t"
             << (++i == 0 ? "on" : "from")
             << " line "
             << this_point->pstate.line + 1
             << " of "
             << rel_path;
        } else {
          ss << std::endl
             << "\t"
             << rel_path
             << ":"
             << this_point->pstate.line + 1
             << this_point->parent->caller;
        }

        this_point = this_point->parent;
      }

      return ss.str();
    }

    size_t depth()
    {
      size_t d = 0;
      Backtrace* p = parent;
      while (p) {
        ++d;
        p = p->parent;
      }
      return d-1;
    }

  };

}

#endif

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
sassc-1.11.4 ext/libsass/src/backtrace.hpp
sassc-1.11.3 ext/libsass/src/backtrace.hpp
sassc-1.11.2 ext/libsass/src/backtrace.hpp
sassc-1.11.1 ext/libsass/src/backtrace.hpp
sassc-1.11.0 ext/libsass/src/backtrace.hpp
sassc-1.10.1 ext/libsass/src/backtrace.hpp
sassc-1.10.0 ext/libsass/src/backtrace.hpp
blackboard-3.1.9 lib/site_template/node_modules/node-sass/src/libsass/src/backtrace.hpp
sassc-1.9.0 ext/libsass/src/backtrace.hpp
sassc-1.8.5 ext/libsass/src/backtrace.hpp
sassc-1.8.4 ext/libsass/src/backtrace.hpp
sassc-1.8.3 ext/libsass/src/backtrace.hpp
sassc-1.8.2 ext/libsass/src/backtrace.hpp