refactor xo::ast -> xo::scm + restore nodef ppdetail_atomic build

This commit is contained in:
Roland Conybeare 2025-07-28 10:13:25 -04:00
commit 483ce15988
78 changed files with 243 additions and 237 deletions

View file

@ -16,9 +16,9 @@ double xo_sqrt(double x) {
int
main() {
using xo::ast::make_constant;
using xo::ast::make_primitive;
using xo::ast::llvmintrinsic;
using xo::scm::make_constant;
using xo::scm::make_primitive;
using xo::scm::llvmintrinsic;
using std::cout;
using std::endl;

View file

@ -10,7 +10,7 @@
//#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
/** @class Apply
* @brief syntax for a function call.
@ -210,7 +210,7 @@ namespace xo {
: Apply(apply_valuetype, fn, argv) {}
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -9,7 +9,7 @@
#include "Variable.hpp"
namespace xo {
namespace ast {
namespace scm {
/** @class AssignExpr
* @brief Provide expression for assigning to a variable
*
@ -55,7 +55,7 @@ namespace xo {
/** free variables for this assignment **/
std::set<std::string> free_var_set_;
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -10,7 +10,7 @@
#include <type_traits>
namespace xo {
namespace ast {
namespace scm {
/** @class Constant
* @brief syntax for a literal constant.
*
@ -104,7 +104,7 @@ namespace xo {
return Constant<T>::make(x);
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/** end Constant.hpp **/

View file

@ -11,7 +11,7 @@
#include <type_traits>
namespace xo {
namespace ast {
namespace scm {
/** @class ConstantInterface
* @brief syntax for a literal constant.
**/
@ -44,7 +44,7 @@ namespace xo {
}; /*ConstantInterface*/
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/** end ConstantInterface.hpp **/

View file

@ -8,7 +8,7 @@
#include "Expression.hpp"
namespace xo {
namespace ast {
namespace scm {
/** @class Convertexpr
* @brief Convenience for automatic type conversion
*
@ -103,7 +103,7 @@ namespace xo {
std::move(arg))
{}
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -8,7 +8,7 @@
#include "Expression.hpp"
namespace xo {
namespace ast {
namespace scm {
/** @class DefineExpr
* @brief Provide definition for a constant, variable or function
*
@ -125,7 +125,7 @@ namespace xo {
{}
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/* end DefineExpr.hpp */

View file

@ -11,7 +11,7 @@
namespace xo {
namespace ast {
namespace scm {
class Expression;
class Environment : public ref::Refcount {
@ -45,7 +45,7 @@ namespace xo {
x.print(os);
return os;
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -10,7 +10,7 @@
#include <set>
namespace xo {
namespace ast {
namespace scm {
class Variable; /* see Variable.hpp */
class Lambda; /* see Lamnbda.hpp */
class Environment; /* see Environment.hpp */
@ -84,7 +84,7 @@ namespace xo {
}; /*Expression*/
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/** end Expression.hpp **/

View file

@ -9,7 +9,7 @@
//#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
class FunctionInterface : public Expression {
public:
FunctionInterface(exprtype extype, TypeDescr fn_type)
@ -27,7 +27,7 @@ namespace xo {
private:
}; /*FunctionInterface*/
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/** end FunctionInterface.hpp **/

View file

@ -11,7 +11,7 @@
#include "exprtype.hpp"
namespace xo {
namespace ast {
namespace scm {
/** @class GeneralizedExpression
* @brief abstract syntax tree (non-executable) for schematica
*
@ -65,7 +65,7 @@ namespace xo {
x.display(os);
return os;
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -10,7 +10,7 @@
#include <string>
namespace xo {
namespace ast {
namespace scm {
class GlobalEnv : public Environment {
public:
/** create instance. Probably only need one of these **/
@ -53,7 +53,7 @@ namespace xo {
*/
std::map<std::string, rp<Expression>> global_map_;
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -11,7 +11,7 @@
//#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
/** @class IfExpr
* @brief abstract syntax tree for a function definition
*
@ -168,7 +168,7 @@ namespace xo {
std::move(when_true),
std::move(when_false)) {}
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/** end IfExpr.hpp **/

View file

@ -15,7 +15,7 @@
//#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
/** @class Lambda
* @brief abstract syntax tree for a function definition
*
@ -237,7 +237,7 @@ namespace xo {
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/** end Lambda.hpp **/

View file

@ -10,7 +10,7 @@
#include "xo/reflect/TypeDescr.hpp"
namespace xo {
namespace ast {
namespace scm {
class Lambda;
/** @brief LocalEnv
@ -103,7 +103,7 @@ namespace xo {
rp<Environment> parent_env_;
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -19,7 +19,7 @@ extern "C" {
};
namespace xo {
namespace ast {
namespace scm {
/** @class Primitive
* @brief syntax for a constant that refers to a known function.
*
@ -245,7 +245,7 @@ namespace xo {
/** div2_f64: divide two 64-bit floating-point numbers **/
static rp<PrimitiveType> make_div2_f64();
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -12,7 +12,7 @@
#include <type_traits>
namespace xo {
namespace ast {
namespace scm {
class PrimitiveInterface : public FunctionInterface {
public:
using void_function_type = void (*)();
@ -70,7 +70,7 @@ namespace xo {
private:
}; /*PrimitiveInterface*/
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -8,7 +8,7 @@
#include "Expression.hpp"
namespace xo {
namespace ast {
namespace scm {
class Sequence : public Expression {
public:
Sequence(const std::vector<rp<Expression>> & xv)
@ -44,7 +44,7 @@ namespace xo {
**/
std::vector<rp<Expression>> expr_v_;
};
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -9,7 +9,7 @@
#include "binding_path.hpp"
namespace xo {
namespace ast {
namespace scm {
/** @class Variable
* @brief syntax for a variable reference
@ -91,7 +91,7 @@ namespace xo {
reflect::TypeDescr var_type) {
return Variable::make(name, var_type);
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -6,7 +6,7 @@
#pragma once
namespace xo {
namespace ast {
namespace scm {
/** @class path
*
* @brief path from the *use* of a variable to the environment
@ -22,7 +22,7 @@ namespace xo {
**/
int j_slot_ = 0;
}; /*binding_path*/
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -9,9 +9,9 @@
//#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
/** @enum exprtype
* @brief enum to identify subclasses of xo::ast::Expression.
* @brief enum to identify subclasses of xo::scm::Expression.
*
**/
enum class exprtype {
@ -74,7 +74,7 @@ namespace xo {
os << expr2str(x);
return os;
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -8,20 +8,20 @@
//#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
/** @enum llvminstrinsic
* @brief enum to identify an LLVM instrinsic, e.g. @c IRBuilder::CreateFAdd
*
* Associate an @c llvminstrinsic with an AST @c Primitive p.
* Later, in @c xo::jit::IrPipeline
* - when generating code for @c xo::ast::Apply
* - when generating code for @c xo::scm::Apply
* - with *p* is in the function-call position
* can use the associated llvm instrinsic instead of generating a function call
* @c Primitive::value
*
* @note llvm will still sometimes need to use
* @c Primitive::value (and generate a function call sequence),
* for example when handling an @c xo::ast::Apply instance
* for example when handling an @c xo::scm::Apply instance
* where the function position is a computed function.
* @endnote
*
@ -153,7 +153,7 @@ namespace xo {
return "???llvmintrinsic???";
} /*llvmintrinsic2str*/
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/** end llvmintrinsic.hpp **/

View file

@ -12,17 +12,17 @@
namespace xo {
namespace print {
template<>
struct ppdetail<xo::ast::GeneralizedExpression> {
struct ppdetail<xo::scm::GeneralizedExpression> {
static bool print_pretty(const ppindentinfo & ppii,
const xo::ast::GeneralizedExpression & x) {
const xo::scm::GeneralizedExpression & x) {
return x.pretty_print(ppii);
}
};
template <>
struct ppdetail<xo::ast::Expression> {
struct ppdetail<xo::scm::Expression> {
static bool print_pretty(const ppindentinfo & ppii,
const xo::ast::Expression & x) {
const xo::scm::Expression & x) {
return x.pretty_print(ppii);
}
};

View file

@ -9,20 +9,20 @@
namespace xo {
namespace print {
template <>
struct ppdetail<xo::ast::LocalEnv> {
static bool print_pretty(const ppindentinfo & ppii, const xo::ast::LocalEnv & x) {
struct ppdetail<xo::scm::LocalEnv> {
static bool print_pretty(const ppindentinfo & ppii, const xo::scm::LocalEnv & x) {
return x.pretty_print(ppii);
}
};
template <>
struct ppdetail<xo::ast::LocalEnv*> {
static bool print_pretty(const ppindentinfo & ppii, const xo::ast::LocalEnv* x) {
struct ppdetail<xo::scm::LocalEnv*> {
static bool print_pretty(const ppindentinfo & ppii, const xo::scm::LocalEnv* x) {
if (x) {
return x->pretty_print(ppii);
} else {
ppii.pps()->write("<nullptr ");
ppii.pps()->write(reflect::type_name<xo::ast::LocalEnv>());
ppii.pps()->write(reflect::type_name<xo::scm::LocalEnv>());
ppii.pps()->write(">");
return ppii.pps()->has_margin();
}

View file

@ -11,8 +11,8 @@
namespace xo {
namespace print {
template <>
struct ppdetail<xo::ast::Variable> {
static bool print_pretty(const ppindentinfo & ppii, const xo::ast::Expression & x) {
struct ppdetail<xo::scm::Variable> {
static bool print_pretty(const ppindentinfo & ppii, const xo::scm::Expression & x) {
return x.pretty_print(ppii);
}
};

View file

@ -9,7 +9,7 @@
#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
rp<Apply>
Apply::make(const rp<Expression> & fn,
const std::vector<rp<Expression>> & argv)
@ -196,7 +196,7 @@ namespace xo {
#endif
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -10,7 +10,7 @@
#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
rp<AssignExpr>
AssignExpr::make(const rp<Variable> & lhs,
const rp<Expression> & rhs)
@ -96,7 +96,7 @@ namespace xo {
refrtag("lhs", lhs_),
refrtag("rhs", rhs_));
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -7,7 +7,7 @@
#include "pretty_expression.hpp"
namespace xo {
namespace ast {
namespace scm {
rp<ConvertExpr>
ConvertExpr::make(TypeDescr dest_type,
rp<Expression> arg)
@ -54,7 +54,7 @@ namespace xo {
return new ConvertExprAccess(nullptr /*dest_type*/,
nullptr /*arg*/);
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -9,7 +9,7 @@
#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
rp<DefineExpr>
DefineExpr::make(std::string lhs_name,
rp<Expression> rhs)
@ -117,7 +117,7 @@ namespace xo {
this->free_var_set_ = this->calc_free_variables();
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -3,8 +3,8 @@
#include "Expression.hpp"
namespace xo {
namespace ast {
} /*namespace ast*/
namespace scm {
} /*namespace scm*/
} /*namespace xo*/

View file

@ -5,7 +5,7 @@
#include <cstdint>
namespace xo {
namespace ast {
namespace scm {
namespace {
using xo::scm::prefix_type;
@ -70,7 +70,7 @@ namespace xo {
return ppii.upto() ? pps->scan_no_newline(saved) : true;
}
#endif
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/* end GeneralizedExpression.cpp */

View file

@ -8,7 +8,7 @@
#include "Expression.hpp"
namespace xo {
namespace ast {
namespace scm {
GlobalEnv::GlobalEnv() = default;
bp<Expression>
@ -49,5 +49,5 @@ namespace xo {
return false;
}
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -6,7 +6,7 @@
//#include "xo/indentlog/print/vector.hpp"
namespace xo {
namespace ast {
namespace scm {
auto IfExpr::check_consistent_valuetype(const rp<Expression> & when_true,
const rp<Expression> & when_false) -> TypeDescr
{
@ -95,7 +95,7 @@ namespace xo {
{
this->when_false_ = std::move(x);
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -17,7 +17,7 @@ namespace xo {
using xo::reflect::FunctionTdxInfo;
using std::stringstream;
namespace ast {
namespace scm {
TypeDescr
Lambda::assemble_lambda_td(const std::vector<rp<Variable>> & argv,
TypeDescr return_td)
@ -404,7 +404,7 @@ namespace xo {
this->complete_assembly_from_body();
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/* end Lambda.cpp */

View file

@ -10,7 +10,7 @@
namespace xo {
namespace ast {
namespace scm {
rp<LocalEnv>
LocalEnv::make_empty() {
return new LocalEnv(std::vector<rp<Variable>>(), nullptr);
@ -142,7 +142,7 @@ namespace xo {
}
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -84,7 +84,7 @@ extern "C" {
}
namespace xo {
namespace ast {
namespace scm {
auto
Primitive_cmp_i64::make_cmp_eq2_i64() -> rp<PrimitiveType>
{

View file

@ -5,7 +5,7 @@
#include <cstddef>
namespace xo {
namespace ast {
namespace scm {
std::set<std::string>
Sequence::get_free_variables() const {
std::set<std::string> retval;

View file

@ -5,7 +5,7 @@
#include "pretty_expression.hpp"
namespace xo {
namespace ast {
namespace scm {
std::string
Variable::gensym(const std::string & prefix) {
static std::size_t s_counter = 0;
@ -46,11 +46,11 @@ namespace xo {
*/
return ppii.pps()->pretty_struct(ppii, "Variable",
refrtag("name", name_),
rtag("type", print::quot(this->valuetype()
rtag("type", print::unq(this->valuetype()
? this->valuetype()->short_name()
: "nullptr")));
}
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/

View file

@ -16,7 +16,7 @@ namespace xo {
// Defining this means ppdetail_atomic is not used.
// In that case where not explicitly specialized ppdetail will revert to ordinary printing for a type,
// instead of giving compile-time error about missing template specialization of ppdetail.
//#define ppdetail_atomic ppdetail
#define ppdetail_atomic ppdetail
struct ppindentinfo {
ppindentinfo(ppstate * pps, std::uint32_t ci0, std::uint32_t indent_width, bool upto)
@ -127,7 +127,7 @@ namespace xo {
using voidptr = void*;
PPDETAIL_ATOMIC(voidptr);
#endif
#endif // #ifndef ppdetail_atomic
} /*namespace print*/
} /*namespace xo*/

View file

@ -56,18 +56,18 @@ int
main() {
using xo::scope;
using xo::jit::MachPipeline;
using xo::ast::make_constant;
using xo::ast::make_primitive;
using xo::ast::llvmintrinsic;
using xo::ast::make_apply;
using xo::ast::make_var;
using xo::ast::make_lambda;
using xo::scm::make_constant;
using xo::scm::make_primitive;
using xo::scm::llvmintrinsic;
using xo::scm::make_apply;
using xo::scm::make_var;
using xo::scm::make_lambda;
using xo::reflect::Reflect;
using xo::xtag;
using std::cerr;
using std::endl;
//using xo::ast::make_constant;
//using xo::scm::make_constant;
static llvm::ExitOnError llvm_exit_on_err;

View file

@ -47,18 +47,18 @@ main() {
using xo::scope;
using xo::jit::MachPipeline;
using xo::jit::activation_record;
using xo::ast::make_constant;
using xo::ast::make_primitive;
using xo::ast::llvmintrinsic;
using xo::ast::make_apply;
using xo::ast::make_var;
using xo::ast::make_lambda;
using xo::scm::make_constant;
using xo::scm::make_primitive;
using xo::scm::llvmintrinsic;
using xo::scm::make_apply;
using xo::scm::make_var;
using xo::scm::make_lambda;
using xo::reflect::Reflect;
using xo::xtag;
using std::cerr;
using std::endl;
//using xo::ast::make_constant;
//using xo::scm::make_constant;
static llvm::ExitOnError llvm_exit_on_err;

View file

@ -56,13 +56,13 @@ namespace xo {
**/
class MachPipeline : public ref::Refcount {
public:
using Expression = xo::ast::Expression;
using Lambda = xo::ast::Lambda;
using GlobalEnv = xo::ast::GlobalEnv;
using Expression = xo::scm::Expression;
using Lambda = xo::scm::Lambda;
using GlobalEnv = xo::scm::GlobalEnv;
using TypeDescr = xo::reflect::TypeDescr;
using ExecutionSession = llvm::orc::ExecutionSession;
using DataLayout = llvm::DataLayout;
//using ConstantInterface = xo::ast::ConstantInterface;
//using ConstantInterface = xo::scm::ConstantInterface;
public:
/* tracking KaleidoscopeJIT::Create() here.. */
@ -109,8 +109,8 @@ namespace xo {
* @c llvm::Type instances are *immortal* (llvm interns them into opaque global lookup tables)
**/
llvm::Type * codegen_type(TypeDescr td);
llvm::Value * codegen_constant(bp<xo::ast::ConstantInterface> expr);
llvm::Function * codegen_primitive(bp<xo::ast::PrimitiveInterface> expr);
llvm::Value * codegen_constant(bp<xo::scm::ConstantInterface> expr);
llvm::Function * codegen_primitive(bp<xo::scm::PrimitiveInterface> expr);
/** like @ref codegen_primitive , but create wrapper function that accepts (and discards)
* environment pointer as first argument.
@ -118,7 +118,7 @@ namespace xo {
* Implementation consists of tail call to natural primitive, that skips the unused
* environment pointer
**/
llvm::Function * codegen_primitive_wrapper(bp<xo::ast::PrimitiveInterface> expr,
llvm::Function * codegen_primitive_wrapper(bp<xo::scm::PrimitiveInterface> expr,
llvm::IRBuilder<> & ir_builder);
/** Generate closure for invoking a primitive function.
@ -126,17 +126,17 @@ namespace xo {
* to support function-pointer-like behavior for a target function
* that may resolve to primitive-or-lambda at runtime
**/
llvm::Value * codegen_primitive_closure(bp<xo::ast::PrimitiveInterface> expr,
llvm::Value * codegen_primitive_closure(bp<xo::scm::PrimitiveInterface> expr,
llvm::IRBuilder<> & ir_builder);
llvm::Value * codegen_apply(bp<xo::ast::Apply> expr,
llvm::Value * codegen_apply(bp<xo::scm::Apply> expr,
llvm::Value * envptr,
llvm::IRBuilder<> & ir_builder);
/* NOTE: codegen_lambda() needs to be reentrant too.
* for example can have a lambda in apply position.
*/
llvm::Function * codegen_lambda_decl(bp<xo::ast::Lambda> expr);
llvm::Function * codegen_lambda_defn(bp<xo::ast::Lambda> expr, llvm::IRBuilder<> & ir_builder);
llvm::Function * codegen_lambda_decl(bp<xo::scm::Lambda> expr);
llvm::Function * codegen_lambda_defn(bp<xo::scm::Lambda> expr, llvm::IRBuilder<> & ir_builder);
/** Generate closure for invoking a lambda (user-defined function).
* See @ref MachPipeline::codegen_apply for invocation
* Same ABI as @ref MachPipeline::codegen_primitive_closure
@ -147,13 +147,13 @@ namespace xo {
* @ref MachPipeline::codegen_toplevel and friends are responsible for
* assembling and propagating this.
**/
llvm::Value * codegen_lambda_closure(bp<xo::ast::Lambda> lambda,
llvm::Value * codegen_lambda_closure(bp<xo::scm::Lambda> lambda,
llvm::Value * envptr,
llvm::IRBuilder<> & ir_builder);
llvm::Value * codegen_variable(bp<xo::ast::Variable> var,
llvm::Value * codegen_variable(bp<xo::scm::Variable> var,
llvm::Value * envptr,
llvm::IRBuilder<> & ir_builder);
llvm::Value * codegen_ifexpr(bp<xo::ast::IfExpr> ifexpr,
llvm::Value * codegen_ifexpr(bp<xo::scm::IfExpr> ifexpr,
llvm::Value * envptr,
llvm::IRBuilder<> & ir_builder);

View file

@ -17,7 +17,7 @@
namespace xo {
namespace jit {
/** analagous to xo::ast::binding_path,
/** analagous to xo::scm::binding_path,
* but with locations renumbered to include only vars that belong to an explict runtime
* environment object; in other words we exclude vars with stack-only storage
**/
@ -119,7 +119,7 @@ namespace xo {
**/
class activation_record {
public:
using Lambda = xo::ast::Lambda;
using Lambda = xo::scm::Lambda;
using TypeDescr = xo::reflect::TypeDescr;
public:

View file

@ -20,8 +20,8 @@ namespace xo {
**/
struct type2llvm {
public:
using FunctionInterface = xo::ast::FunctionInterface;
using Lambda = xo::ast::Lambda;
using FunctionInterface = xo::scm::FunctionInterface;
using Lambda = xo::scm::Lambda;
using TypeDescr = xo::reflect::TypeDescr;
public:

View file

@ -7,17 +7,17 @@
#include <string>
namespace xo {
using xo::ast::exprtype;
using xo::ast::Expression;
using xo::ast::ConstantInterface;
//using xo::ast::FunctionInterface;
using xo::ast::PrimitiveInterface;
using xo::ast::Lambda;
using xo::ast::Variable;
using xo::ast::Apply;
using xo::ast::IfExpr;
using xo::ast::GlobalEnv;
using xo::ast::llvmintrinsic;
using xo::scm::exprtype;
using xo::scm::Expression;
using xo::scm::ConstantInterface;
//using xo::scm::FunctionInterface;
using xo::scm::PrimitiveInterface;
using xo::scm::Lambda;
using xo::scm::Variable;
using xo::scm::Apply;
using xo::scm::IfExpr;
using xo::scm::GlobalEnv;
using xo::scm::llvmintrinsic;
using xo::reflect::Reflect;
using xo::reflect::StructMember;
using xo::reflect::TypeDescr;
@ -369,7 +369,7 @@ namespace xo {
} /*codegen_primitive_wrapper*/
llvm::Value *
MachPipeline::codegen_primitive_closure(bp<xo::ast::PrimitiveInterface> expr,
MachPipeline::codegen_primitive_closure(bp<xo::scm::PrimitiveInterface> expr,
llvm::IRBuilder<> & ir_builder)
{
constexpr bool c_debug_flag = true;
@ -435,7 +435,7 @@ namespace xo {
/* we don't need any special checking here.
* already know (from xo-level checking) that pointer has the right type.
*
* Specifically, xo::ast::Apply::make() requires the expression in function position
* Specifically, xo::scm::Apply::make() requires the expression in function position
* have suitable function type.
*
* Now: we have an llvm::Value (fn_value) representing the pointer.
@ -1026,7 +1026,7 @@ namespace xo {
*/
/* WIP. STRATEGY:
* - xo::ast::ClosureExpr (an expression that generates a closure)
* - xo::scm::ClosureExpr (an expression that generates a closure)
* closure = {lambda, env}
*
* - pass 1:

View file

@ -4,16 +4,16 @@
#include <string>
namespace xo {
using xo::ast::exprtype;
using xo::ast::Expression;
using xo::ast::ConstantInterface;
//using xo::ast::FunctionInterface;
using xo::ast::PrimitiveInterface;
using xo::ast::Lambda;
using xo::ast::Variable;
using xo::ast::Apply;
using xo::ast::IfExpr;
using xo::ast::llvmintrinsic;
using xo::scm::exprtype;
using xo::scm::Expression;
using xo::scm::ConstantInterface;
//using xo::scm::FunctionInterface;
using xo::scm::PrimitiveInterface;
using xo::scm::Lambda;
using xo::scm::Variable;
using xo::scm::Apply;
using xo::scm::IfExpr;
using xo::scm::llvmintrinsic;
using xo::reflect::Reflect;
using xo::reflect::StructMember;
using xo::reflect::TypeDescr;
@ -465,7 +465,7 @@ namespace xo {
/* we don't need any special checking here.
* already know (from xo-level checking) that pointer has the right type.
*
* Specifically, xo::ast::Apply::make() requires the expression in function position
* Specifically, xo::scm::Apply::make() requires the expression in function position
* have suitable function type.
*
* Now: we have an llvm::Value (fn_value) representing the pointer.

View file

@ -4,16 +4,16 @@
#include <string>
namespace xo {
using xo::ast::exprtype;
using xo::ast::Expression;
using xo::ast::ConstantInterface;
//using xo::ast::FunctionInterface;
using xo::ast::PrimitiveInterface;
using xo::ast::Lambda;
using xo::ast::Variable;
using xo::ast::Apply;
using xo::ast::IfExpr;
using xo::ast::llvmintrinsic;
using xo::scm::exprtype;
using xo::scm::Expression;
using xo::scm::ConstantInterface;
//using xo::scm::FunctionInterface;
using xo::scm::PrimitiveInterface;
using xo::scm::Lambda;
using xo::scm::Variable;
using xo::scm::Apply;
using xo::scm::IfExpr;
using xo::scm::llvmintrinsic;
using xo::reflect::Reflect;
using xo::reflect::StructMember;
using xo::reflect::TypeDescr;
@ -465,7 +465,7 @@ namespace xo {
/* we don't need any special checking here.
* already know (from xo-level checking) that pointer has the right type.
*
* Specifically, xo::ast::Apply::make() requires the expression in function position
* Specifically, xo::scm::Apply::make() requires the expression in function position
* have suitable function type.
*
* Now: we have an llvm::Value (fn_value) representing the pointer.

View file

@ -10,13 +10,13 @@
namespace xo {
using xo::jit::MachPipeline;
using xo::ast::make_apply;
using xo::ast::make_var;
using xo::ast::make_primitive;
using xo::ast::llvmintrinsic;
using xo::ast::Expression;
using xo::ast::Lambda;
using xo::ast::exprtype;
using xo::scm::make_apply;
using xo::scm::make_var;
using xo::scm::make_primitive;
using xo::scm::llvmintrinsic;
using xo::scm::Expression;
using xo::scm::Lambda;
using xo::scm::exprtype;
using xo::reflect::Reflect;
using xo::reflect::reflect_struct;
using xo::ref::brw;

View file

@ -17,21 +17,21 @@
#include <cmath>
namespace xo {
namespace ast {
using xo::ast::exprtype;
using xo::ast::Expression;
using xo::ast::make_apply;
using xo::ast::PrimitiveInterface;
using xo::ast::Primitive;
using xo::ast::make_primitive;
using xo::ast::ConstantInterface;
using xo::ast::Constant;
using xo::ast::Variable;
using xo::ast::make_var;
using xo::ast::Lambda;
using xo::ast::make_lambda;
using xo::ast::IfExpr;
using xo::ast::make_ifexpr;
namespace scm {
using xo::scm::exprtype;
using xo::scm::Expression;
using xo::scm::make_apply;
using xo::scm::PrimitiveInterface;
using xo::scm::Primitive;
using xo::scm::make_primitive;
using xo::scm::ConstantInterface;
using xo::scm::Constant;
using xo::scm::Variable;
using xo::scm::make_var;
using xo::scm::Lambda;
using xo::scm::make_lambda;
using xo::scm::IfExpr;
using xo::scm::make_ifexpr;
using xo::reflect::TaggedPtr;
using xo::rp;
namespace py = pybind11;
@ -188,7 +188,7 @@ namespace xo {
m.def("make_ifexpr", &make_ifexpr);
} /*pyexpresion*/
} /*namespace ast*/
} /*namespace scm*/
} /*namespace xo*/
/* end pyexpression.cpp */

View file

@ -12,9 +12,9 @@
namespace xo {
namespace jit {
using xo::ast::Expression;
using xo::ast::make_primitive;
using xo::ast::llvmintrinsic;
using xo::scm::Expression;
using xo::scm::make_primitive;
using xo::scm::llvmintrinsic;
using xo::pyutil::pycaller_base;
using xo::pyutil::pycaller;
using xo::reflect::Reflect;
@ -105,7 +105,7 @@ namespace xo {
pycaller_store::s_instance;
PYBIND11_MODULE(XO_PYJIT_MODULE_NAME(), m) {
// e.g. for xo::ast::Expression
// e.g. for xo::scm::Expression
XO_PYEXPRESSION_IMPORT_MODULE(); // py::module_::import("pyexpression");
m.doc() = "pybind11 plugin for xo-jit";

View file

@ -61,7 +61,7 @@ int
main() {
using namespace replxx;
using namespace xo::scm;
using xo::ast::Expression;
using xo::scm::Expression;
using xo::print::ppconfig;
using xo::print::ppstate_standalone;
using xo::rp;

View file

@ -57,7 +57,7 @@ namespace xo {
*/
class apply_xs : public exprstate {
public:
using Apply = xo::ast::Apply;
using Apply = xo::scm::Apply;
public:
explicit apply_xs();
@ -109,7 +109,9 @@ namespace xo {
} /*namespace scm */
namespace print {
#ifndef ppdetail_atomic
PPDETAIL_ATOMIC(xo::scm::applyexprstatetype);
#endif
}
} /*namespace xo*/

View file

@ -67,8 +67,8 @@ namespace xo {
**/
class define_xs : public exprstate {
public:
using DefineExprAccess = xo::ast::DefineExprAccess;
using ConvertExprAccess = xo::ast::ConvertExprAccess;
using DefineExprAccess = xo::scm::DefineExprAccess;
using ConvertExprAccess = xo::scm::ConvertExprAccess;
public:
define_xs(rp<DefineExprAccess> def_expr);

View file

@ -21,9 +21,9 @@ namespace xo {
**/
class envframe {
public:
using Environment = xo::ast::Environment;
using LocalEnv = xo::ast::LocalEnv;
using Variable = xo::ast::Variable;
using Environment = xo::scm::Environment;
using LocalEnv = xo::scm::LocalEnv;
using Variable = xo::scm::Variable;
public:
envframe() = default;

View file

@ -14,8 +14,8 @@ namespace xo {
**/
class envframestack {
public:
using LocalEnv = xo::ast::LocalEnv;
using Variable = xo::ast::Variable;
using LocalEnv = xo::scm::LocalEnv;
using Variable = xo::scm::Variable;
using ppstate = xo::print::ppstate;
using ppindentinfo = xo::print::ppindentinfo;

View file

@ -48,7 +48,7 @@ namespace xo {
**/
class expect_formal_arglist_xs : public exprstate {
public:
using Variable = xo::ast::Variable;
using Variable = xo::scm::Variable;
public:
expect_formal_arglist_xs();

View file

@ -95,9 +95,9 @@ namespace xo {
**/
class exprstate {
public:
using Expression = xo::ast::Expression;
using Variable = xo::ast::Variable;
using exprtype = xo::ast::exprtype;
using Expression = xo::scm::Expression;
using Variable = xo::scm::Variable;
using exprtype = xo::scm::exprtype;
using token_type = token<char>;
using TypeDescr = xo::reflect::TypeDescr;

View file

@ -51,7 +51,7 @@ namespace xo {
**/
class if_else_xs : public exprstate {
public:
using IfExprAccess = xo::ast::IfExprAccess;
using IfExprAccess = xo::scm::IfExprAccess;
public:
if_else_xs(rp<IfExprAccess> if_expr);
@ -100,7 +100,9 @@ namespace xo {
} /*namespace scm*/
namespace print {
#ifndef ppdetail_atomic
PPDETAIL_ATOMIC(xo::scm::ifexprstatetype);
#endif
}
} /*namespace xo*/

View file

@ -55,8 +55,8 @@ namespace xo {
**/
class lambda_xs : public exprstate {
public:
using Environment = xo::ast::Environment;
using LocalEnv = xo::ast::LocalEnv;
using Environment = xo::scm::Environment;
using LocalEnv = xo::scm::LocalEnv;
public:
lambda_xs();
@ -111,7 +111,9 @@ namespace xo {
} /*namespace scm*/
namespace print {
#ifndef ppdetail_atomic
PPDETAIL_ATOMIC(xo::scm::lambdastatetype);
#endif
}
} /*namespace xo*/

View file

@ -12,7 +12,7 @@ namespace xo {
namespace scm {
class let1_xs : public exprstate {
public:
using LocalEnv = xo::ast::LocalEnv;
using LocalEnv = xo::scm::LocalEnv;
public:
/** given local definition equivalent to

View file

@ -153,7 +153,7 @@ namespace xo {
**/
class parser {
public:
using Expression = xo::ast::Expression;
using Expression = xo::scm::Expression;
using token_type = exprstate::token_type; // token<char>;
public:

View file

@ -19,7 +19,7 @@ namespace xo {
};
struct parser_result {
using Expression = xo::ast::Expression;
using Expression = xo::scm::Expression;
public:
parser_result() = default;

View file

@ -22,9 +22,9 @@ namespace xo {
**/
class parserstatemachine {
public:
using Expression = xo::ast::Expression;
using Variable = xo::ast::Variable;
using LocalEnv = xo::ast::LocalEnv;
using Expression = xo::scm::Expression;
using Variable = xo::scm::Variable;
using LocalEnv = xo::scm::LocalEnv;
using token_type = token<char>;
public:

View file

@ -17,7 +17,7 @@ namespace xo {
* @brief Result object returned from reader::read_expr
**/
struct reader_result {
using Expression = xo::ast::Expression;
using Expression = xo::scm::Expression;
using span_type = span<const char>;
reader_result(rp<Expression> expr, span_type rem, std::size_t psz, const reader_error & error)

View file

@ -9,14 +9,14 @@
#include <vector>
namespace xo {
namespace ast { class Sequence; }
namespace ast { class Lambda; }
namespace scm { class Sequence; }
namespace scm { class Lambda; }
namespace scm {
class sequence_xs : public exprstate {
public:
using Sequence = xo::ast::Sequence;
using Lambda = xo::ast::Lambda;
using Sequence = xo::scm::Sequence;
using Lambda = xo::scm::Lambda;
public:
/** start parsing a sequence-expr.

View file

@ -7,7 +7,7 @@
#include "xo/indentlog/print/vector.hpp"
namespace xo {
using xo::ast::Variable;
using xo::scm::Variable;
namespace scm {
#ifdef OBSOLETE

View file

@ -8,8 +8,8 @@
#include "pretty_localenv.hpp"
namespace xo {
using xo::ast::LocalEnv;
using xo::ast::Variable;
using xo::scm::LocalEnv;
using xo::scm::Variable;
namespace scm {
bp<LocalEnv>

View file

@ -17,7 +17,7 @@
#include "xo/expression/pretty_expression.hpp"
namespace xo {
using xo::ast::Constant;
using xo::scm::Constant;
namespace scm {

View file

@ -11,7 +11,7 @@
#include "xo/expression/Variable.hpp"
namespace xo {
using xo::ast::Variable;
using xo::scm::Variable;
using xo::reflect::TypeDescr;
namespace scm{

View file

@ -123,7 +123,7 @@ namespace xo {
exprseq_xs::on_bool_token(const token_type & tk,
parserstatemachine * p_psm)
{
using xo::ast::Constant;
using xo::scm::Constant;
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -150,7 +150,7 @@ namespace xo {
exprseq_xs::on_i64_token(const token_type & tk,
parserstatemachine * p_psm)
{
using xo::ast::Constant;
using xo::scm::Constant;
scope log(XO_DEBUG(p_psm->debug_flag()));
@ -176,7 +176,7 @@ namespace xo {
exprseq_xs::on_f64_token(const token_type & tk,
parserstatemachine * p_psm)
{
using xo::ast::Constant;
using xo::scm::Constant;
scope log(XO_DEBUG(p_psm->debug_flag()));

View file

@ -18,7 +18,7 @@
//#include "xo/reflect/Reflect.hpp"
namespace xo {
//using xo::ast::Constant;
//using xo::scm::Constant;
//using xo::reflect::Reflect;
using xo::reflect::TypeDescr;
using xo::print::ppindentinfo;

View file

@ -10,8 +10,8 @@
#include "xo/expression/Lambda.hpp"
namespace xo {
using xo::ast::Lambda;
using xo::ast::LocalEnv;
using xo::scm::Lambda;
using xo::scm::LocalEnv;
namespace scm {
const char *

View file

@ -12,14 +12,14 @@
#include "xo/expression/Lambda.hpp"
namespace xo {
using Sequence = xo::ast::Sequence;
using DefineExpr = xo::ast::DefineExpr;
using Apply = xo::ast::Apply;
using Lambda = xo::ast::Lambda;
using LambdaAccess = xo::ast::LambdaAccess;
using Environment = xo::ast::Environment;
using LocalEnv = xo::ast::LocalEnv;
using Variable = xo::ast::Variable;
using Sequence = xo::scm::Sequence;
using DefineExpr = xo::scm::DefineExpr;
using Apply = xo::scm::Apply;
using Lambda = xo::scm::Lambda;
using LambdaAccess = xo::scm::LambdaAccess;
using Environment = xo::scm::Environment;
using LocalEnv = xo::scm::LocalEnv;
using Variable = xo::scm::Variable;
namespace scm {
std::unique_ptr<let1_xs>

View file

@ -17,8 +17,8 @@
#include <stdexcept>
namespace xo {
using xo::ast::Expression;
using xo::ast::LocalEnv;
using xo::scm::Expression;
using xo::scm::LocalEnv;
using xo::reflect::TypeDescr;
namespace scm {

View file

@ -11,8 +11,8 @@
#include "xo/expression/pretty_expression.hpp"
namespace xo {
using xo::ast::LocalEnv;
using xo::ast::Variable;
using xo::scm::LocalEnv;
using xo::scm::Variable;
namespace scm {
bp<Variable>

View file

@ -11,10 +11,10 @@
#include "xo/expression/pretty_expression.hpp"
namespace xo {
using xo::ast::Expression;
using xo::ast::AssignExpr;
using xo::ast::Variable;
using xo::ast::Apply;
using xo::scm::Expression;
using xo::scm::AssignExpr;
using xo::scm::Variable;
using xo::scm::Apply;
namespace scm {
const char *

View file

@ -9,7 +9,7 @@
#include "xo/expression/pretty_expression.hpp"
namespace xo {
using xo::ast::DefineExpr;
using xo::scm::DefineExpr;
namespace scm {
std::unique_ptr<sequence_xs>

View file

@ -16,7 +16,7 @@ namespace xo {
using std::cerr;
using std::endl;
//using xo::ast::Expression;
//using xo::scm::Expression;
namespace ut {
TEST_CASE("parser", "[parser]") {