Permalink
Browse files

Remove CYExpression::ReplaceAll into CYCompound::Replace.

  • Loading branch information...
1 parent d3fdf3a commit 4a8e0029374b43a1e1e8145f4a388d99829ca5db saurik committed Jul 12, 2010
Showing with 4 additions and 16 deletions.
  1. +0 −2 Parser.hpp
  2. +4 −14 Replace.cpp
View
@@ -561,8 +561,6 @@ struct CYExpression :
virtual CYExpression *ClassName(CYContext &context, bool object);
virtual void ClassName(CYOutput &out, bool object) const;
- CYExpression *ReplaceAll(CYContext &context);
-
virtual CYExpression *Replace(CYContext &context) = 0;
virtual CYExpression *Primitive(CYContext &context) {
View
@@ -136,8 +136,10 @@ CYStatement *CYComment::Replace(CYContext &context) {
}
CYExpression *CYCompound::Replace(CYContext &context) {
- expressions_ = expressions_->ReplaceAll(context);
- return expressions_ == NULL ? NULL : this;
+ CYExpression **last(&expressions_);
+ for (CYExpression *next(expressions_); next != NULL; next = next->next_)
+ last = &(*last = next->Replace(context))->next_;
+ return this;
}
CYFunctionParameter *CYComprehension::Parameters(CYContext &context) const { $T(NULL)
@@ -283,18 +285,6 @@ CYExpression *CYExpression::ForEachIn(CYContext &context) {
return this;
}
-CYExpression *CYExpression::ReplaceAll(CYContext &context) { $T(NULL)
- CYExpression *replace(this);
- context.Replace(replace);
-
- if (CYExpression *next = next_->ReplaceAll(context))
- replace->SetNext(next);
- else
- replace->SetNext(next_);
-
- return replace;
-}
-
CYNumber *CYFalse::Number(CYContext &context) {
return $D(0);
}

0 comments on commit 4a8e002

Please sign in to comment.