Skip to content

Commit 2096899

Browse files
committed
Fix extend edge case
1 parent d50ce73 commit 2096899

File tree

4 files changed

+16
-83
lines changed

4 files changed

+16
-83
lines changed

src/ast_fwd_decl.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,4 @@
99

1010
namespace Sass {
1111

12-
#define IMPLEMENT_BASE_CAST(T) \
13-
template<> \
14-
T* Cast(AstNode* ptr) { \
15-
return dynamic_cast<T*>(ptr); \
16-
}; \
17-
\
18-
template<> \
19-
const T* Cast(const AstNode* ptr) { \
20-
return dynamic_cast<const T*>(ptr); \
21-
}; \
22-
23-
IMPLEMENT_BASE_CAST(Expression);
24-
IMPLEMENT_BASE_CAST(Statement);
25-
IMPLEMENT_BASE_CAST(ParentStatement);
26-
IMPLEMENT_BASE_CAST(CssParentNode);
27-
IMPLEMENT_BASE_CAST(CallableDeclaration);
28-
IMPLEMENT_BASE_CAST(Value);
29-
IMPLEMENT_BASE_CAST(Color);
30-
IMPLEMENT_BASE_CAST(List);
31-
IMPLEMENT_BASE_CAST(Callable);
32-
IMPLEMENT_BASE_CAST(String);
33-
IMPLEMENT_BASE_CAST(SupportsCondition);
34-
IMPLEMENT_BASE_CAST(Selector);
35-
IMPLEMENT_BASE_CAST(SelectorComponent);
36-
IMPLEMENT_BASE_CAST(SimpleSelector);
37-
IMPLEMENT_BASE_CAST(NameSpaceSelector);
38-
IMPLEMENT_BASE_CAST(CssNode);
39-
40-
4112
}

src/ast_fwd_decl.hpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -336,44 +336,6 @@ namespace Sass {
336336
typedef sass::vector<ExpressionObj> ExpressionVector;
337337
typedef std::unordered_set<sass::string> StringSet;
338338

339-
/////////////////////////////////////////////////////////////////////////#
340-
// explicit type conversion functions
341-
/////////////////////////////////////////////////////////////////////////#
342-
343-
template<class T>
344-
T* Cast(AstNode* ptr);
345-
346-
template<class T>
347-
const T* Cast(const AstNode* ptr);
348-
349-
// sometimes you know the class you want to cast to is final
350-
// in this case a simple typeid check is faster and safe to use
351-
352-
#define DECLARE_BASE_CAST(T) \
353-
template<> T* Cast(AstNode* ptr); \
354-
template<> const T* Cast(const AstNode* ptr); \
355-
356-
/////////////////////////////////////////////////////////////////////////#
357-
// implement specialization for final classes
358-
/////////////////////////////////////////////////////////////////////////#
359-
360-
DECLARE_BASE_CAST(AstNode)
361-
DECLARE_BASE_CAST(Expression)
362-
DECLARE_BASE_CAST(Statement)
363-
DECLARE_BASE_CAST(ParentStatement)
364-
DECLARE_BASE_CAST(CssParentNode)
365-
DECLARE_BASE_CAST(Value)
366-
DECLARE_BASE_CAST(Callable)
367-
DECLARE_BASE_CAST(Color)
368-
DECLARE_BASE_CAST(List)
369-
DECLARE_BASE_CAST(String)
370-
DECLARE_BASE_CAST(SupportsCondition)
371-
DECLARE_BASE_CAST(Selector)
372-
DECLARE_BASE_CAST(SimpleSelector)
373-
DECLARE_BASE_CAST(NameSpaceSelector);
374-
DECLARE_BASE_CAST(SelectorComponent)
375-
DECLARE_BASE_CAST(ImportBase);
376-
DECLARE_BASE_CAST(CssNode);
377339

378340
class Eval;
379341
class Logger;

src/debugger.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -638,18 +638,18 @@ inline void debug_ast(AstNode* node, std::string ind)
638638
ForwardRule* rule = Cast<ForwardRule>(node);
639639
std::cerr << ind << "ForwardRule " << rule;
640640
std::cerr << " (" << pstate_source_position(rule) << ")";
641-
debug_idxs(rule->module());
641+
debug_idxs(rule->module32());
642642
std::cerr << std::endl;
643-
debug_ast(rule->root(), ind + " =@ ");
643+
debug_ast(rule->root47(), ind + " =@ ");
644644

645645
}
646646
else if (Cast<UseRule>(node)) {
647647
UseRule* rule = Cast<UseRule>(node);
648648
std::cerr << ind << "UseRule " << rule;
649649
std::cerr << " (" << pstate_source_position(rule) << ")";
650-
debug_idxs(rule->module());
650+
debug_idxs(rule->module32());
651651
std::cerr << std::endl;
652-
debug_ast(rule->root(), ind + " =@ ");
652+
debug_ast(rule->root47(), ind + " =@ ");
653653

654654
}
655655
else if (Cast<UserDefinedCallable>(node)) {
@@ -872,9 +872,9 @@ inline void debug_ast(AstNode* node, std::string ind)
872872
IncludeImport* block = Cast<IncludeImport>(node);
873873
std::cerr << ind << "IncludeImport " << block;
874874
std::cerr << " (" << pstate_source_position(node) << ")";
875-
debug_idxs(block->module());
875+
debug_idxs(block->module32());
876876
std::cerr << std::endl;
877-
debug_ast(block->root(), ind + " @ ");
877+
debug_ast(block->root47(), ind + " @ ");
878878
}
879879
else if (Cast<ImportRule>(node)) {
880880
ImportRule* block = Cast<ImportRule>(node);
@@ -1121,10 +1121,10 @@ inline void debug_ast(AstNode* node, std::string ind)
11211121
MapExpression* expression = Cast<MapExpression>(node);
11221122
std::cerr << ind << "MapExpression " << expression;
11231123
std::cerr << " (" << pstate_source_position(node) << ")";
1124-
std::cerr << " (" << expression->size() << ") " <<
1124+
std::cerr << " (" << expression->kvlist().size() << ") " <<
11251125
std::endl;
1126-
for (size_t i = 0; i < expression->size(); i++) {
1127-
debug_ast(expression->get(i), ind + " ");
1126+
for (size_t i = 0; i < expression->kvlist().size(); i++) {
1127+
debug_ast(expression->kvlist().at(i), ind + " ");
11281128
}
11291129
}
11301130
else if (Cast<ArgumentList>(node)) {

src/extender.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ namespace Sass {
7272
extenders[complex] = complex;
7373
}
7474

75+
ExtSelExtMap extensions;
76+
77+
Extender extender(mode, logger);
78+
7579
for (auto complex : targets->elements()) {
7680

7781
if (complex->size() > 1) {
@@ -94,23 +98,16 @@ namespace Sass {
9498

9599
if (const CompoundSelector* compound = complex->first()->isaCompoundSelector()) {
96100

97-
ExtSelExtMap extensions;
98-
99101
for (const SimpleSelectorObj& simple : compound->elements()) {
100102
extensions.insert(std::make_pair(simple, extenders));
101103
}
102104

103-
Extender extender(mode, logger);
104-
105105
// if (!selector->hasInvisible()) {
106106
for (auto sel : selector->elements()) {
107107
extender.originals.insert(sel);
108108
}
109109
// }
110110

111-
extender.extendList(selector, extensions,
112-
{}, selector->elements());
113-
114111
}
115112
else {
116113
throw Exception::RuntimeException(logger,
@@ -120,6 +117,9 @@ namespace Sass {
120117

121118
}
122119

120+
extender.extendList(selector, extensions,
121+
{}, selector->elements());
122+
123123
return selector;
124124

125125
}

0 commit comments

Comments
 (0)