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 686ceffe5c
38 changed files with 84 additions and 84 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*/