1111namespace intp ::interp {
1212 struct NativeFunction ;
1313 struct Thunk ;
14- struct Env ;
14+ struct Environment ;
1515 struct List ;
1616 struct Value ;
1717
18- // / Runtime representation of Lambda Expression
18+ // / Runtime representation of Lambda- Expression.
1919 struct Closure {
20- std::string param ;
21- const fe::ast::Expression *body; // / Non-owning, read-only AST pointer
22- std::shared_ptr<Env> env ; // / Environment at the time of Lambda Expression creation
20+ std::string parameter ;
21+ const fe::ast::Expression *body; // / Non-owning, read-only AST pointer.
22+ std::shared_ptr<Environment> environment ; // / Environment at the time of Lambda- Expression creation.
2323
24- [[nodiscard]] std::string to_string () const ;
24+ [[nodiscard]] std::string toString () const ;
2525
26- friend std::ostream &operator <<(std::ostream &os , const Closure &closure);
26+ friend std::ostream &operator <<(std::ostream &stream , const Closure &closure);
2727 };
2828
2929 struct List {
3030 std::vector<Value> elements;
3131
32- [[nodiscard]] std::string to_string () const ;
32+ [[nodiscard]] std::string toString () const ;
3333
34- friend std::ostream &operator <<(std::ostream &os , const List &list);
34+ friend std::ostream &operator <<(std::ostream &stream , const List &list);
3535 };
3636
3737 using ValueVariant = std::variant<
@@ -43,87 +43,87 @@ namespace intp::interp {
4343 >;
4444
4545 struct Value : ValueVariant {
46- using ValueVariant::ValueVariant; // inherit constructors
46+ using ValueVariant::ValueVariant; // Inherit constructors.
4747
48- // / Pretty print a runtime value for REPL/diagnostics
49- [[nodiscard]] std::string to_string () const ;
48+ // / Pretty print a runtime value for REPL/diagnostics.
49+ [[nodiscard]] std::string toString () const ;
5050
51- friend std::ostream &operator <<(std::ostream &os , const Value &value);
51+ friend std::ostream &operator <<(std::ostream &stream , const Value &value);
5252 };
5353
5454 struct ResultOptions {
55- bool side_effects = false ;
55+ bool sideEffects = false ;
5656
57- void interpolate (const ResultOptions &result_options_ );
57+ void interpolate (const ResultOptions &resultOptions_ );
5858 };
5959
6060 struct NativeFunction {
61- using Impl = std::function<std::pair<Value, ResultOptions>(
62- const std::vector<std::shared_ptr<Thunk> > &, const std::shared_ptr<Env > &)>;
61+ using Implementation = std::function<std::pair<Value, ResultOptions>(
62+ const std::vector<std::shared_ptr<Thunk> > &, const std::shared_ptr<Environment > &)>;
6363
6464 int arity;
6565 std::string name;
66- Impl impl ;
66+ Implementation implementation ;
6767
68- [[nodiscard]] std::string to_string () const ;
68+ [[nodiscard]] std::string toString () const ;
6969
70- friend std::ostream &operator <<(std::ostream &os , const NativeFunction &native_fn );
70+ friend std::ostream &operator <<(std::ostream &stream , const NativeFunction &nativeFunction );
7171 };
7272
73- // / Lazy Thunk (call-by-need)
73+ // / Lazy- Thunk (call-by-need).
7474 struct Thunk : std::enable_shared_from_this<Thunk> {
7575 mutable std::optional<Value> cached;
76- const fe::ast::Expression *expr = nullptr ; // / Non-owning, read-only AST pointer
77- std::unique_ptr<fe::ast::Expression> owned; // / Owning storage (when needed) (primarily in REPL)
78- std::shared_ptr<Env> env ; // / Environment for evaluating Expression
76+ const fe::ast::Expression *expression = nullptr ; // / Non-owning, read-only AST pointer.
77+ std::unique_ptr<fe::ast::Expression> owned; // / Owning storage (when needed) (primarily in REPL).
78+ std::shared_ptr<Environment> environment ; // / Environment for evaluating Expression.
7979 std::optional<fe::loc::Loc> origin = std::nullopt ;
8080
8181 Thunk () = default ;
8282
83- Thunk (const fe::ast::Expression *expr , std::shared_ptr<Env> env ,
83+ Thunk (const fe::ast::Expression *expression , std::shared_ptr<Environment> environment ,
8484 std::optional<fe::loc::Loc> origin = std::nullopt );
8585
86- // / Force computation on Thunk and return a const reference to Value
87- const Value &force () const ; // / Marked const as cached is mutable
86+ // / Force computation on Thunk and return a const reference to Value.
87+ const Value &force () const ; // / Marked const as cached is mutable.
8888
89- // / Sets Thunk's fields after construction
90- // / Allows for recursive reference
91- void set (const fe::ast::Expression *expr_ , std::shared_ptr<Env> env_ ,
89+ // / Sets Thunk's fields after construction.
90+ // / Allows for recursive reference.
91+ void set (const fe::ast::Expression *expression_ , std::shared_ptr<Environment> environment_ ,
9292 std::optional<fe::loc::Loc> origin_ = std::nullopt );
9393
94- void set_owned (fe::ast::Expression expr_ , std::shared_ptr<Env> env_ ,
94+ void set_owned (fe::ast::Expression expression_ , std::shared_ptr<Environment> environment_ ,
9595 std::optional<fe::loc::Loc> origin_ = std::nullopt );
9696 };
9797
98- struct Env : std::enable_shared_from_this<Env > {
98+ struct Environment : std::enable_shared_from_this<Environment > {
9999 std::unordered_map<std::string, std::shared_ptr<Thunk> > table;
100- std::shared_ptr<Env > parent;
100+ std::shared_ptr<Environment > parent;
101101
102- explicit Env (std::shared_ptr<Env > parent = nullptr );
102+ explicit Environment (std::shared_ptr<Environment > parent = nullptr );
103103
104104 std::shared_ptr<Thunk> lookup (const std::string &name) const ;
105105
106106 void bind (const std::string &name, std::shared_ptr<Thunk> thunk);
107107
108- std::vector<std::vector<std::string> > to_vector (bool force) const ;
108+ std::vector<std::vector<std::string> > toVector (bool force) const ;
109109 };
110110
111- Value eval_expr (const fe::ast::Expression &expr , std::shared_ptr<Env> env );
111+ Value evalExpression (const fe::ast::Expression &expression , std::shared_ptr<Environment> environment );
112112
113- Value apply_fn_apl (Value fn_value , const std::vector<std::shared_ptr<Thunk> > &args ,
114- const std::shared_ptr<Env > &call_site_env ,
115- const std::optional<fe::loc::Loc> &call_loc = std::nullopt );
113+ Value applyFunctionApplication (Value functionName , const std::vector<std::shared_ptr<Thunk> > &arguments ,
114+ const std::shared_ptr<Environment > &callSiteEnvironment ,
115+ const std::optional<fe::loc::Loc> &callLocation = std::nullopt );
116116
117- // / Program Driver
117+ // / Program Driver.
118118 struct Result {
119- std::shared_ptr<Env> global_env ;
119+ std::shared_ptr<Environment> globalEnvironment ;
120120 Value value;
121121 ResultOptions options = {};
122122 };
123123
124- Result interpret (fe::ast::Program &program, std::optional<std::shared_ptr<Env > > global_env = std::nullopt ,
124+ Result interpret (fe::ast::Program &program, std::optional<std::shared_ptr<Environment > > globalEnvironment = std::nullopt ,
125125 options::Options options_ = {});
126126
127- // / Add builtins Native Functions into Environment
128- void install_builtins (const std::shared_ptr<Env > &env );
127+ // / Add builtins Native Functions into Environment.
128+ void installBuiltins (const std::shared_ptr<Environment > &environment );
129129}
0 commit comments