Skip to content

Commit

Permalink
fixing section capitalisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Dec 29, 2024
1 parent 5861a6d commit caf7c17
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions Chapters/06-VariablesAndScopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions Chapters/07-EvaluatorFirstMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/.

Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion Chapters/08-EvaluatorMessageArg.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit caf7c17

Please sign in to comment.