From: Chris Lattner
Date: Mon, 5 Nov 2007 19:25:14 +0000 (+0000)
Subject: mention possibility of using a visitor
X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=cac2135bc8a732c495b52aee85800baca2e23c22;p=oota-llvm.git
mention possibility of using a visitor
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43726 91177308-0d34-0410-b5e6-96231b3b80d8
---
diff --git a/docs/tutorial/LangImpl3.html b/docs/tutorial/LangImpl3.html
index 3733a66bfcf..3e629287cc3 100644
--- a/docs/tutorial/LangImpl3.html
+++ b/docs/tutorial/LangImpl3.html
@@ -62,7 +62,7 @@ we define virtual codegen methods in each AST class:
class ExprAST {
public:
virtual ~ExprAST() {}
- virtual Value *Codegen() = 0;
+ virtual Value *Codegen() = 0;
};
/// NumberExprAST - Expression class for numeric literals like "1.0".
@@ -70,7 +70,7 @@ class NumberExprAST : public ExprAST {
double Val;
public:
explicit NumberExprAST(double val) : Val(val) {}
- virtual Value *Codegen();
+ virtual Value *Codegen();
};
...
@@ -88,6 +88,11 @@ more information, please read up on Static Single
Assignment - the concepts are really quite natural once you grok them.
+Note that instead of adding virtual methods to the ExprAST class hierarchy,
+it could also make sense to use a visitor pattern or some other way to model
+this. Again, this tutorial won't dwell on good software engineering practices:
+for our purposes, adding virtual methods is simplest.
+
The
second thing we want is an "Error" method like we used for parser, which will
be used to report errors found during code generation (for example, use of an