summaryrefslogtreecommitdiffstats
path: root/llvm/docs/tutorial
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-11-05 19:25:14 +0000
committerChris Lattner <sabre@nondot.org>2007-11-05 19:25:14 +0000
commit2a8fd134eab3797a0dc9d465294528722d7cba5b (patch)
tree3d91b795fb5e49279e27ae534cc96d6d1ef65f6e /llvm/docs/tutorial
parenta94cfa13e74951386f37b037afb78a5776f026a9 (diff)
downloadbcm5719-llvm-2a8fd134eab3797a0dc9d465294528722d7cba5b.tar.gz
bcm5719-llvm-2a8fd134eab3797a0dc9d465294528722d7cba5b.zip
mention possibility of using a visitor
llvm-svn: 43726
Diffstat (limited to 'llvm/docs/tutorial')
-rw-r--r--llvm/docs/tutorial/LangImpl3.html9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/docs/tutorial/LangImpl3.html b/llvm/docs/tutorial/LangImpl3.html
index 3733a66bfcf..3e629287cc3 100644
--- a/llvm/docs/tutorial/LangImpl3.html
+++ b/llvm/docs/tutorial/LangImpl3.html
@@ -62,7 +62,7 @@ we define virtual codegen methods in each AST class:</p>
class ExprAST {
public:
virtual ~ExprAST() {}
- virtual Value *Codegen() = 0;
+ <b>virtual Value *Codegen() = 0;</b>
};
/// 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();
+ <b>virtual Value *Codegen();</b>
};
...
</pre>
@@ -88,6 +88,11 @@ more information, please read up on <a
href="http://en.wikipedia.org/wiki/Static_single_assignment_form">Static Single
Assignment</a> - the concepts are really quite natural once you grok them.</p>
+<p>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.</p>
+
<p>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
OpenPOWER on IntegriCloud