Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2594 from mgreter/cleanup/roundhouse-1
Browse files Browse the repository at this point in the history
Roundhouse cleanup nr 1
  • Loading branch information
mgreter authored Mar 17, 2018
2 parents b29e27d + 5564ab3 commit 035bfef
Show file tree
Hide file tree
Showing 62 changed files with 3,381 additions and 2,982 deletions.
11 changes: 10 additions & 1 deletion Makefile.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ SOURCES = \
node.cpp \
context.cpp \
constants.cpp \
fn_utils.cpp \
fn_miscs.cpp \
fn_maps.cpp \
fn_lists.cpp \
fn_colors.cpp \
fn_numbers.cpp \
fn_strings.cpp \
fn_selectors.cpp \
functions.cpp \
color_maps.cpp \
environment.cpp \
Expand Down Expand Up @@ -43,7 +51,8 @@ SOURCES = \
sass2scss.cpp \
backtrace.cpp \
operators.cpp \
to_c.cpp \
ast2c.cpp \
c2ast.cpp \
to_value.cpp \
source_map.cpp \
subset_map.cpp \
Expand Down
80 changes: 43 additions & 37 deletions src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ namespace Sass {
return list;
}

Selector_List_Ptr Selector_List::resolve_parent_refs(std::vector<Selector_List_Obj>& pstack, Backtraces& traces, bool implicit_parent)
Selector_List_Ptr Selector_List::resolve_parent_refs(SelectorStack& pstack, Backtraces& traces, bool implicit_parent)
{
if (!this->has_parent_ref()) return this;
Selector_List_Ptr ss = SASS_MEMORY_NEW(Selector_List, pstate());
Expand All @@ -1273,7 +1273,7 @@ namespace Sass {
return ss;
}

Selector_List_Ptr Complex_Selector::resolve_parent_refs(std::vector<Selector_List_Obj>& pstack, Backtraces& traces, bool implicit_parent)
Selector_List_Ptr Complex_Selector::resolve_parent_refs(SelectorStack& pstack, Backtraces& traces, bool implicit_parent)
{
Complex_Selector_Obj tail = this->tail();
Compound_Selector_Obj head = this->head();
Expand Down Expand Up @@ -1590,8 +1590,8 @@ namespace Sass {
bool Selector_Schema::has_real_parent_ref() const
{
if (String_Schema_Obj schema = Cast<String_Schema>(contents())) {
Parent_Selector_Obj p = Cast<Parent_Selector>(schema->at(0));
return schema->length() > 0 && p && p->is_real_parent_ref();
if (schema->length() == 0) return false;
return Cast<Parent_Reference>(schema->at(0));
}
return false;
}
Expand Down Expand Up @@ -2108,6 +2108,44 @@ namespace Sass {
}
}

Function_Call::Function_Call(ParserState pstate, std::string n, Arguments_Obj args, void* cookie)
: PreValue(pstate), sname_(SASS_MEMORY_NEW(String_Constant, pstate, n)), arguments_(args), func_(0), via_call_(false), cookie_(cookie), hash_(0)
{ concrete_type(FUNCTION); }
Function_Call::Function_Call(ParserState pstate, std::string n, Arguments_Obj args, Function_Obj func)
: PreValue(pstate), sname_(SASS_MEMORY_NEW(String_Constant, pstate, n)), arguments_(args), func_(func), via_call_(false), cookie_(0), hash_(0)
{ concrete_type(FUNCTION); }
Function_Call::Function_Call(ParserState pstate, std::string n, Arguments_Obj args)
: PreValue(pstate), sname_(SASS_MEMORY_NEW(String_Constant, pstate, n)), arguments_(args), via_call_(false), cookie_(0), hash_(0)
{ concrete_type(FUNCTION); }

bool Function_Call::operator==(const Expression& rhs) const
{
try
{
Function_Call_Ptr_Const m = Cast<Function_Call>(&rhs);
if (!(m && *sname() == *m->sname())) return false;
if (!(m && arguments()->length() == m->arguments()->length())) return false;
for (size_t i =0, L = arguments()->length(); i < L; ++i)
if (!(*(*arguments())[i] == *(*m->arguments())[i])) return false;
return true;
}
catch (std::bad_cast&)
{
return false;
}
catch (...) { throw; }
}

size_t Function_Call::hash()
{
if (hash_ == 0) {
hash_ = std::hash<std::string>()(name());
for (auto argument : arguments()->elements())
hash_combine(hash_, argument->hash());
}
return hash_;
}

//////////////////////////////////////////////////////////////////////////////////////////
// Convert map to (key, value) list.
//////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -2124,38 +2162,6 @@ namespace Sass {
return ret;
}

//////////////////////////////////////////////////////////////////////////////////////////
// Copy implementations
//////////////////////////////////////////////////////////////////////////////////////////

#ifdef DEBUG_SHARED_PTR

#define IMPLEMENT_AST_OPERATORS(klass) \
klass##_Ptr klass::copy(std::string file, size_t line) const { \
klass##_Ptr cpy = new klass(this); \
cpy->trace(file, line); \
return cpy; \
} \
klass##_Ptr klass::clone(std::string file, size_t line) const { \
klass##_Ptr cpy = copy(file, line); \
cpy->cloneChildren(); \
return cpy; \
} \

#else

#define IMPLEMENT_AST_OPERATORS(klass) \
klass##_Ptr klass::copy() const { \
return new klass(this); \
} \
klass##_Ptr klass::clone() const { \
klass##_Ptr cpy = copy(); \
cpy->cloneChildren(); \
return cpy; \
} \

#endif

IMPLEMENT_AST_OPERATORS(Supports_Operator);
IMPLEMENT_AST_OPERATORS(Supports_Negation);
IMPLEMENT_AST_OPERATORS(Compound_Selector);
Expand All @@ -2182,6 +2188,7 @@ namespace Sass {
IMPLEMENT_AST_OPERATORS(Color);
IMPLEMENT_AST_OPERATORS(Null);
IMPLEMENT_AST_OPERATORS(Parent_Selector);
IMPLEMENT_AST_OPERATORS(Parent_Reference);
IMPLEMENT_AST_OPERATORS(Import);
IMPLEMENT_AST_OPERATORS(Import_Stub);
IMPLEMENT_AST_OPERATORS(Function_Call);
Expand Down Expand Up @@ -2213,7 +2220,6 @@ namespace Sass {
IMPLEMENT_AST_OPERATORS(Arguments);
IMPLEMENT_AST_OPERATORS(Argument);
IMPLEMENT_AST_OPERATORS(Unary_Expression);
IMPLEMENT_AST_OPERATORS(Function_Call_Schema);
IMPLEMENT_AST_OPERATORS(Block);
IMPLEMENT_AST_OPERATORS(Content);
IMPLEMENT_AST_OPERATORS(Trace);
Expand Down
Loading

0 comments on commit 035bfef

Please sign in to comment.