Commit 909199cf by Aaron Leung

Renaming a variable/method.

parent e2021333
...@@ -16,7 +16,7 @@ namespace Sass { ...@@ -16,7 +16,7 @@ namespace Sass {
source(doc.source), source(doc.source),
position(doc.position), position(doc.position),
end(doc.end), end(doc.end),
line_number(doc.line_number), line(doc.line),
own_source(doc.own_source), own_source(doc.own_source),
context(doc.context), context(doc.context),
root(doc.root), root(doc.root),
...@@ -44,7 +44,7 @@ namespace Sass { ...@@ -44,7 +44,7 @@ namespace Sass {
Document doc(ctx); Document doc(ctx);
doc.path = path; doc.path = path;
doc.line_number = 1; doc.line = 1;
doc.root = ctx.new_Node(Node::root, path, 1, 0); doc.root = ctx.new_Node(Node::root, path, 1, 0);
doc.lexed = Token::make(); doc.lexed = Token::make();
doc.own_source = true; doc.own_source = true;
...@@ -60,7 +60,7 @@ namespace Sass { ...@@ -60,7 +60,7 @@ namespace Sass {
{ {
Document doc(ctx); Document doc(ctx);
doc.path = path; doc.path = path;
doc.line_number = 1; doc.line = 1;
doc.root = ctx.new_Node(Node::root, path, 1, 0); doc.root = ctx.new_Node(Node::root, path, 1, 0);
doc.lexed = Token::make(); doc.lexed = Token::make();
doc.own_source = false; doc.own_source = false;
...@@ -75,7 +75,7 @@ namespace Sass { ...@@ -75,7 +75,7 @@ namespace Sass {
{ {
Document doc(ctx); Document doc(ctx);
doc.path = path; doc.path = path;
doc.line_number = line_number; doc.line = line_number;
doc.root = ctx.new_Node(Node::root, path, 1, 0); doc.root = ctx.new_Node(Node::root, path, 1, 0);
doc.lexed = Token::make(); doc.lexed = Token::make();
doc.own_source = false; doc.own_source = false;
...@@ -87,10 +87,10 @@ namespace Sass { ...@@ -87,10 +87,10 @@ namespace Sass {
} }
void Document::throw_syntax_error(string message, size_t ln) void Document::throw_syntax_error(string message, size_t ln)
{ throw Error(Error::syntax, ln ? ln : line_number, path, message); } { throw Error(Error::syntax, ln ? ln : line, path, message); }
void Document::throw_read_error(string message, size_t ln) void Document::throw_read_error(string message, size_t ln)
{ throw Error(Error::read, ln ? ln : line_number, path, message); } { throw Error(Error::read, ln ? ln : line, path, message); }
using std::string; using std::string;
using std::stringstream; using std::stringstream;
......
...@@ -20,7 +20,7 @@ namespace Sass { ...@@ -20,7 +20,7 @@ namespace Sass {
char* source; char* source;
const char* position; const char* position;
const char* end; const char* end;
size_t line_number; size_t line;
bool own_source; bool own_source;
Context& context; Context& context;
...@@ -89,7 +89,7 @@ namespace Sass { ...@@ -89,7 +89,7 @@ namespace Sass {
else if (mx == spaces) { else if (mx == spaces) {
after_whitespace = spaces(position); after_whitespace = spaces(position);
if (after_whitespace) { if (after_whitespace) {
line_number += count_interval<'\n'>(position, after_whitespace); line += count_interval<'\n'>(position, after_whitespace);
lexed = Token::make(position, after_whitespace); lexed = Token::make(position, after_whitespace);
return position = after_whitespace; return position = after_whitespace;
} }
...@@ -105,7 +105,7 @@ namespace Sass { ...@@ -105,7 +105,7 @@ namespace Sass {
} }
const char* after_token = mx(after_whitespace); const char* after_token = mx(after_whitespace);
if (after_token) { if (after_token) {
line_number += count_interval<'\n'>(position, after_token); line += count_interval<'\n'>(position, after_token);
lexed = Token::make(after_whitespace, after_token); lexed = Token::make(after_whitespace, after_token);
return position = after_token; return position = after_token;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace Sass { namespace Sass {
using std::cerr; using std::endl; using std::cerr; using std::endl;
static void eval_error(string message, size_t line_number, const char* file_name) static void throw_eval_error(string message, size_t line_number, const char* file_name)
{ {
string fn; string fn;
if (file_name) { if (file_name) {
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
namespace Sass { namespace Sass {
using std::map; using std::map;
Node eval(Node& expr, Environment& env, map<pair<string, size_t>, Function>& f_env, vector<vector<Node>*>& registry); Node eval(Node& expr, Environment& env, map<pair<string, size_t>, Function>& f_env, Node_Factory& new_Node);
Node accumulate(Node::Type op, Node& acc, Node& rhs, vector<vector<Node>*>& registry); Node accumulate(Node::Type op, Node& acc, Node& rhs, Node_Factory& new_Node);
double operate(Node::Type op, double lhs, double rhs); double operate(Node::Type op, double lhs, double rhs);
Node apply_mixin(Node& mixin, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, vector<vector<Node>*>& registry); Node apply_mixin(Node& mixin, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, Node_Factory& new_Node);
Node apply_function(const Function& f, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, vector<vector<Node>*>& registry); Node apply_function(const Function& f, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, Node_Factory& new_Node);
} }
\ No newline at end of file
...@@ -82,11 +82,11 @@ namespace Sass { ...@@ -82,11 +82,11 @@ namespace Sass {
return numeric_value() < rhs.numeric_value(); return numeric_value() < rhs.numeric_value();
} }
else { else {
throw Error(Error::evaluation, line_number(), file_name(), "incompatible units"); throw Error(Error::evaluation, line(), path(), "incompatible units");
} }
} }
else { else {
throw Error(Error::evaluation, line_number(), file_name(), "incomparable types"); throw Error(Error::evaluation, line(), path(), "incomparable types");
} }
} }
......
...@@ -163,8 +163,8 @@ namespace Sass { ...@@ -163,8 +163,8 @@ namespace Sass {
bool is_unquoted() const; bool is_unquoted() const;
bool is_numeric() const; bool is_numeric() const;
string& file_name() const; string& path() const;
size_t line_number() const; size_t line() const;
size_t size() const; size_t size() const;
bool empty() const; bool empty() const;
...@@ -200,8 +200,8 @@ namespace Sass { ...@@ -200,8 +200,8 @@ namespace Sass {
// TO DO: look into using a custom allocator in the Node_Factory class // TO DO: look into using a custom allocator in the Node_Factory class
vector<Node> children; // Can't be in the union because it has non-trivial constructors! vector<Node> children; // Can't be in the union because it has non-trivial constructors!
string file_name; string path;
size_t line_number; size_t line;
Node::Type type; Node::Type type;
...@@ -296,8 +296,8 @@ namespace Sass { ...@@ -296,8 +296,8 @@ namespace Sass {
inline bool Node::is_unquoted() const { return ip_->is_unquoted; } inline bool Node::is_unquoted() const { return ip_->is_unquoted; }
inline bool Node::is_numeric() const { return ip_->is_numeric(); } inline bool Node::is_numeric() const { return ip_->is_numeric(); }
inline string& Node::file_name() const { return ip_->file_name; } inline string& Node::path() const { return ip_->path; }
inline size_t Node::line_number() const { return ip_->line_number; } inline size_t Node::line() const { return ip_->line; }
inline size_t Node::size() const { return ip_->size(); } inline size_t Node::size() const { return ip_->size(); }
inline bool Node::empty() const { return ip_->empty(); } inline bool Node::empty() const { return ip_->empty(); }
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
namespace Sass { namespace Sass {
Node_Impl* Node_Factory::alloc_Node_Impl(Node::Type type, string file, size_t line) Node_Impl* Node_Factory::alloc_Node_Impl(Node::Type type, string path, size_t line)
{ {
Node_Impl* ip = new Node_Impl(); Node_Impl* ip = new Node_Impl();
ip->type = type; ip->type = type;
if (type == Node::backref) ip->has_backref = true; if (type == Node::backref) ip->has_backref = true;
ip->file_name = file; ip->path = path;
ip->line_number = line; ip->line = line;
pool_.push_back(ip); pool_.push_back(ip);
return ip; return ip;
} }
...@@ -35,17 +35,17 @@ namespace Sass { ...@@ -35,17 +35,17 @@ namespace Sass {
} }
// for making leaf nodes out of terminals/tokens // for making leaf nodes out of terminals/tokens
Node Node_Factory::operator()(Node::Type type, string file, size_t line, Token& t) Node Node_Factory::operator()(Node::Type type, string path, size_t line, Token& t)
{ {
Node_Impl* ip = alloc_Node_Impl(type, file, line); Node_Impl* ip = alloc_Node_Impl(type, path, line);
ip->value.token = t; ip->value.token = t;
return Node(ip); return Node(ip);
} }
// for making boolean values or interior nodes that have children // for making boolean values or interior nodes that have children
Node Node_Factory::operator()(Node::Type type, string file, size_t line, size_t size) Node Node_Factory::operator()(Node::Type type, string path, size_t line, size_t size)
{ {
Node_Impl* ip = alloc_Node_Impl(type, file, line); Node_Impl* ip = alloc_Node_Impl(type, path, line);
if (type == Node::boolean) ip->value.boolean = size; if (type == Node::boolean) ip->value.boolean = size;
else ip->children.reserve(size); else ip->children.reserve(size);
...@@ -53,38 +53,38 @@ namespace Sass { ...@@ -53,38 +53,38 @@ namespace Sass {
return Node(ip); return Node(ip);
} }
// Node Node_Factory::operator()(Node::Type type, string file, size_t line, bool b) // Node Node_Factory::operator()(Node::Type type, string path, size_t line, bool b)
// { // {
// Node_Impl* ip = alloc_Node_Impl(type, file, line); // Node_Impl* ip = alloc_Node_Impl(type, path, line);
// ip->content.boolean_value = b; // ip->content.boolean_value = b;
// return Node(ip); // return Node(ip);
// } // }
// for making nodes representing numbers // for making nodes representing numbers
Node Node_Factory::operator()(string file, size_t line, double v) Node Node_Factory::operator()(string path, size_t line, double v)
{ {
Node_Impl* ip = alloc_Node_Impl(Node::number, file, line); Node_Impl* ip = alloc_Node_Impl(Node::number, path, line);
ip->value.numeric = v; ip->value.numeric = v;
return Node(ip); return Node(ip);
} }
// for making nodes representing numeric dimensions (e.g. 5px, 3em) // for making nodes representing numeric dimensions (e.g. 5px, 3em)
Node Node_Factory::operator()(string file, size_t line, double v, const Token& t) Node Node_Factory::operator()(string path, size_t line, double v, const Token& t)
{ {
Node_Impl* ip = alloc_Node_Impl(Node::numeric_dimension, file, line); Node_Impl* ip = alloc_Node_Impl(Node::numeric_dimension, path, line);
ip->value.dimension.numeric = v; ip->value.dimension.numeric = v;
ip->value.dimension.unit = t; ip->value.dimension.unit = t;
return Node(ip); return Node(ip);
} }
// for making nodes representing rgba color quads // for making nodes representing rgba color quads
Node Node_Factory::operator()(string file, size_t line, double r, double g, double b, double a) Node Node_Factory::operator()(string path, size_t line, double r, double g, double b, double a)
{ {
Node color((*this)(Node::numeric_color, file, line, 4)); Node color((*this)(Node::numeric_color, path, line, 4));
color << (*this)(file, line, r) color << (*this)(path, line, r)
<< (*this)(file, line, g) << (*this)(path, line, g)
<< (*this)(file, line, b) << (*this)(path, line, b)
<< (*this)(file, line, a); << (*this)(path, line, a);
return color; return color;
} }
......
...@@ -40,7 +40,7 @@ extern "C" { ...@@ -40,7 +40,7 @@ extern "C" {
using namespace Sass; using namespace Sass;
doc.parse_scss(); doc.parse_scss();
// cerr << "PARSED" << endl; // cerr << "PARSED" << endl;
eval(doc.root, doc.context.global_env, doc.context.function_env, doc.context.registry); eval(doc.root, doc.context.global_env, doc.context.function_env, doc.context.new_Node);
// cerr << "EVALUATED" << endl; // cerr << "EVALUATED" << endl;
string output(doc.emit_css(static_cast<Document::CSS_Style>(style))); string output(doc.emit_css(static_cast<Document::CSS_Style>(style)));
// cerr << "EMITTED" << endl; // cerr << "EMITTED" << endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment