From caf7c179878baa4b58af01ab7aec59670be4984a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phaneDucasse?= Date: Sun, 29 Dec 2024 18:41:48 +0100 Subject: [PATCH] fixing section capitalisation --- Chapters/06-VariablesAndScopes.md | 16 +++++++++++----- Chapters/07-EvaluatorFirstMessage.md | 6 +++--- Chapters/08-EvaluatorMessageArg.md | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Chapters/06-VariablesAndScopes.md b/Chapters/06-VariablesAndScopes.md index d3dfe49..aa59434 100644 --- a/Chapters/06-VariablesAndScopes.md +++ b/Chapters/06-VariablesAndScopes.md @@ -111,7 +111,7 @@ CInterpreter >> currentScope yourself ``` -### Using the scope +### Using the Scope The basic structure of our lexical scope implementation introduces the method `scopeDefining:`. This method returns the scope defining the given name. The method `scopeDefining:` forwards the search to the current scope, obtained through `currentScope`. Since we only have one scope for now we do not cover the case where the variable is not in the variables of the receiver. @@ -268,11 +268,11 @@ The case of global variable writing is similar to the instance variable assignme -### Little setup +### Little Setup Our first testing scenario, similar to the previous ones, is as follows: we will define a method `returnGlobal` that reads and returns the global named `Global`. Now the question is that from the CInterpretable class the global variable `Global` should be a Pharo global variable. -Note that when the interpreter will encounter such a variable, it will use its own private environment. +Note that when the interpreter encounters such a variable, it uses its own private environment. So to make sure that you can compile the code and execute your tests, we define the class method initialize as follows: @@ -304,13 +304,19 @@ CInterpretable >> returnGlobal We start by enriching the class `CInterpreterTest` with an instance variable pointing to a new interpreter. ``` -CInterpreterTest >> setUp super setUp. interpreter := CInterpreter new. receiver := CInterpretable new +CInterpreterTest >> setUp + + super setUp. + interpreter := CInterpreter new. + receiver := CInterpretable new ``` This implies that we should modify the getter to be ``` -CInterpreterTest >> interpreter ^ interpreter +CInterpreterTest >> interpreter + + ^ interpreter ``` We define a test that specifies that the interpreter's environment has a binding whose key is `#Global` and value is a new object. diff --git a/Chapters/07-EvaluatorFirstMessage.md b/Chapters/07-EvaluatorFirstMessage.md index 7b727c8..bef6c71 100644 --- a/Chapters/07-EvaluatorFirstMessage.md +++ b/Chapters/07-EvaluatorFirstMessage.md @@ -33,7 +33,7 @@ Figure *@callstack@* presents a call stack with two methods. The first method in -### Putting in place the stack +### Putting in Place the Stack We will use the stack implementation available at github://pharo-containers/. @@ -166,7 +166,7 @@ CInterpreter >> visitMessageNode: aMessageNode All our tests should pass and in particular `testSelfSend`. -### Consolidating AST access logic +### Consolidating AST Access Logic Pharo provides a way to get an AST from a compiled method, but we do not want to use because the AST it returns is different from the one we want for this book (the variables are resolved based on a semantical analysis). @@ -253,7 +253,7 @@ CInterpreterTest >> setUp ``` -#### Making the test pass +#### Making the Test Pass Executing this test breaks because the access to the instance variable `x` returns nil, showing the limits of our current implementation. This is due to the fact that evaluating message send `returnInstanceVariableX` creates a new frame with the collaborator as receiver, and since that frame is not popped from of the stack, when the method returns, the access to the `x` instance variable accesses the one of the uninitialized collaborator instead of the caller object. diff --git a/Chapters/08-EvaluatorMessageArg.md b/Chapters/08-EvaluatorMessageArg.md index 6b17b80..5f18a93 100644 --- a/Chapters/08-EvaluatorMessageArg.md +++ b/Chapters/08-EvaluatorMessageArg.md @@ -17,7 +17,7 @@ In addition to simply passing arguments, the evaluator needs to care about evalu #### Initial Argument Setup -To implement some initial support for arguments, our first scenario is to simply send a message with an argument. We already one message with an argument: the `x:` setter. We defines the method `changeCollaboratorWithArgument` which uses it. +To implement some initial support for arguments, our first scenario is to simply send a message with an argument. We already one message with an argument: the `x:` setter. We define the method `changeCollaboratorWithArgument` which uses it. ```language=smalltalk CInterpretable >> changeCollaboratorWithArgument