Skip to content

Commit

Permalink
Change String_Schema to only hold PreValue objects
Browse files Browse the repository at this point in the history
The API does not guarantee yet that everything stored in
`String_Schema` is a Value, although it doesn't make much
sense to allow anything else and as it turns out we don't!
Use steamroller tactics to ensure we don't store anything
else after evaluation from Binary_Expression.
  • Loading branch information
mgreter committed Mar 17, 2018
1 parent 0c5e27c commit 37e15bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,16 +1703,16 @@ namespace Sass {
// Interpolated strings. Meant to be reduced to flat strings during the
// evaluation phase.
///////////////////////////////////////////////////////////////////////
class String_Schema : public String, public Vectorized<Expression_Obj> {
class String_Schema : public String, public Vectorized<PreValue_Obj> {
ADD_PROPERTY(bool, css)
size_t hash_;
public:
String_Schema(ParserState pstate, size_t size = 0, bool css = true)
: String(pstate), Vectorized<Expression_Obj>(size), css_(css), hash_(0)
: String(pstate), Vectorized<PreValue_Obj>(size), css_(css), hash_(0)
{ concrete_type(STRING); }
String_Schema(const String_Schema* ptr)
: String(ptr),
Vectorized<Expression_Obj>(*ptr),
Vectorized<PreValue_Obj>(*ptr),
css_(ptr->css_),
hash_(ptr->hash_)
{ concrete_type(STRING); }
Expand Down
8 changes: 4 additions & 4 deletions src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,9 @@ namespace Sass {
b->op(), s_l->last(), b->right());
bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // unverified
for (size_t i = 0; i < s_l->length() - 1; ++i) {
ret_schema->append(s_l->at(i)->perform(this));
ret_schema->append(Cast<PreValue>(s_l->at(i)->perform(this)));
}
ret_schema->append(bin_ex->perform(this));
ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
return ret_schema->perform(this);
}
}
Expand All @@ -676,9 +676,9 @@ namespace Sass {
Binary_Expression_Obj bin_ex = SASS_MEMORY_NEW(Binary_Expression, b->pstate(),
b->op(), b->left(), s_r->first());
bin_ex->is_delayed(b->left()->is_delayed() || b->right()->is_delayed()); // verified
ret_schema->append(bin_ex->perform(this));
ret_schema->append(Cast<PreValue>(bin_ex->perform(this)));
for (size_t i = 1; i < s_r->length(); ++i) {
ret_schema->append(s_r->at(i)->perform(this));
ret_schema->append(Cast<PreValue>(s_r->at(i)->perform(this)));
}
return ret_schema->perform(this);
}
Expand Down

0 comments on commit 37e15bb

Please sign in to comment.