Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1296)

Unified Diff: src/sksl/ast/SkSLASTForStatement.h

Issue 1984363002: initial checkin of SkSL compiler (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: cleanups Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/sksl/ast/SkSLASTForStatement.h
diff --git a/src/sksl/ast/SkSLASTForStatement.h b/src/sksl/ast/SkSLASTForStatement.h
new file mode 100644
index 0000000000000000000000000000000000000000..e99f302c58048f4e3ea5802ae765780e747ee16b
--- /dev/null
+++ b/src/sksl/ast/SkSLASTForStatement.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SKSL_ASTFORSTATEMENT
+#define SKSL_ASTFORSTATEMENT
+
+#include "SkSLASTStatement.h"
+
+namespace SkSL {
+
+/**
+ * A 'for' loop.
+ */
+struct ASTForStatement : public ASTStatement {
+ ASTForStatement(Position position, std::unique_ptr<ASTStatement> initializer,
+ std::unique_ptr<ASTExpression> test, std::unique_ptr<ASTExpression> next,
dogben 2016/06/20 16:23:18 Should next be a statement?
ethannicholas 2016/06/20 17:45:49 This is for the third entry in a for loop ('for (i
mtklein 2016/06/20 18:25:25 It helps me to remember that many things you think
dogben 2016/06/20 18:26:26 Ok, I see that in the parser, e.g. "i += 2" become
+ std::unique_ptr<ASTStatement> statement)
+ : INHERITED(position, kFor_Kind)
+ , fInitializer(std::move(initializer))
+ , fTest(std::move(test))
+ , fNext(std::move(next))
+ , fStatement(std::move(statement)) {}
+
+ std::string description() const override {
+ std::string result = std::string("for (");
dogben 2016/06/20 16:23:18 uber-nit: "std::string(" unnecessary
+ if (fInitializer) {
+ result.append(fInitializer->description());
dogben 2016/06/20 16:23:18 uber-nit: elsewhere in this CL, you use += rather
+ }
+ result.append(" ");
dogben 2016/06/20 16:23:18 ;
+ if (fTest) {
+ result.append(fTest->description());
+ }
+ result.append("; ");
+ if (fNext) {
+ result.append(fNext->description());
+ }
+ return result + ") " + fStatement->description();
dogben 2016/06/20 16:23:18 nit: Is the compiler smart enough to append to res
+ }
+
+ const std::unique_ptr<ASTStatement> fInitializer;
+ const std::unique_ptr<ASTExpression> fTest;
+ const std::unique_ptr<ASTExpression> fNext;
+ const std::unique_ptr<ASTStatement> fStatement;
+
+ typedef ASTStatement INHERITED;
+};
+
+} // namespace
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698