xo-expression: + Expression::attach_envs()
This commit is contained in:
parent
d836f13b88
commit
a877af562a
8 changed files with 83 additions and 13 deletions
|
|
@ -9,9 +9,14 @@
|
|||
#include "xo/refcnt/Refcounted.hpp"
|
||||
#include "exprtype.hpp"
|
||||
#include <functional>
|
||||
#include <set>
|
||||
|
||||
namespace xo {
|
||||
namespace ast {
|
||||
class Variable; /* see Variable.hpp */
|
||||
class Lambda; /* see Lamnbda.hpp */
|
||||
class Environment; /* see Environment.hpp */
|
||||
|
||||
/** @class Expression
|
||||
* @brief abstract syntax tree for an EGAD program
|
||||
*
|
||||
|
|
@ -47,6 +52,22 @@ namespace xo {
|
|||
**/
|
||||
virtual std::size_t visit_preorder(VisitFn visitor_fn) = 0;
|
||||
|
||||
/** attach an environment to each lambda expression X in this subtree,
|
||||
* that will:
|
||||
* - resolve names matching X's arguments (formal parameters) to
|
||||
* from @p X.argv
|
||||
* - resolve free variables from @p parent
|
||||
**/
|
||||
virtual void attach_envs(ref::brw<Environment> parent) = 0;
|
||||
|
||||
/** append to *p_set the set of free variables in this expression.
|
||||
* returns the number of free variables introduced
|
||||
*
|
||||
* @param env stack of lexcically-enclosing lamnbda expressions,
|
||||
* in nesting order, i.e. outermost first, innertmost last
|
||||
**/
|
||||
//virtual std::int32_t find_free_vars(std::vector<ref::brw<Lambda>> env) = 0;
|
||||
|
||||
/** write human-readable representation to stream **/
|
||||
virtual void display(std::ostream & os) const = 0;
|
||||
/** human-readable string representation **/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue