Continue implementation of compilation
This commit is contained in:
@@ -185,11 +185,26 @@ we see a variable that __isn't__ in the current environment, it must be a functi
|
||||
|
||||
Having finished contemplating out method, it's time to define a signature:
|
||||
```C++
|
||||
virtual void compile(const env_ptr env, std::vector<instruction>& into) const;
|
||||
virtual void compile(const env_ptr& env, std::vector<instruction_ptr>& into) const;
|
||||
```
|
||||
|
||||
Ah, but now we have to define "environment". Let's do that:
|
||||
Ah, but now we have to define "environment". Let's do that. Here's our header:
|
||||
|
||||
{{< codeblock "C++" "compiler/06/env.hpp" >}}
|
||||
|
||||
And here's the source file:
|
||||
|
||||
{{< codeblock "C++" "compiler/06/env.cpp" >}}
|
||||
|
||||
{{< todo >}}Explain the code drops. {{< /todo >}}
|
||||
|
||||
It will also help to move some of the functions on the `binop` enum
|
||||
into a separate file. The new neader is pretty small:
|
||||
|
||||
{{< codeblock "C++" "compiler/06/binop.hpp" >}}
|
||||
|
||||
The new source file is not much longer:
|
||||
|
||||
{{< codeblock "C++" "compiler/06/binop.cpp" >}}
|
||||
|
||||
And now, we begin our implementation.
|
||||
|
||||
Reference in New Issue
Block a user