xo-interpreter: Object->TaggedPtr conversion (prep for primitives)
This commit is contained in:
parent
a49fe25ace
commit
0e2ddcf839
5 changed files with 45 additions and 12 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/** @file FunctionInterface.hpp
|
||||
/** @file ProcedureExprInterface.hpp
|
||||
*
|
||||
* Author: Roland Conybeare
|
||||
**/
|
||||
|
|
@ -10,14 +10,14 @@
|
|||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
class FunctionExprInterface : public Expression {
|
||||
class ProcedureExprInterface : public Expression {
|
||||
public:
|
||||
FunctionExprInterface(exprtype extype, TypeDescr fn_type)
|
||||
ProcedureExprInterface(exprtype extype, TypeDescr fn_type)
|
||||
: Expression(extype, fn_type) {}
|
||||
|
||||
/** downcast from Expression **/
|
||||
static bp<FunctionExprInterface> from(bp<Expression> x) {
|
||||
return bp<FunctionExprInterface>::from(x);
|
||||
static bp<ProcedureExprInterface> from(bp<Expression> x) {
|
||||
return bp<ProcedureExprInterface>::from(x);
|
||||
}
|
||||
|
||||
virtual const std::string & name() const = 0;
|
||||
|
|
@ -30,4 +30,4 @@ namespace xo {
|
|||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end FunctionInterface.hpp **/
|
||||
/** end ProcedureExprInterface.hpp **/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Expression.hpp"
|
||||
#include "FunctionExprInterface.hpp"
|
||||
#include "ProcedureExprInterface.hpp"
|
||||
#include "Variable.hpp"
|
||||
#include "LocalSymtab.hpp"
|
||||
#include <map>
|
||||
|
|
@ -19,7 +19,7 @@ namespace xo {
|
|||
* @brief abstract syntax tree for a function definition
|
||||
*
|
||||
**/
|
||||
class Lambda : public FunctionExprInterface {
|
||||
class Lambda : public ProcedureExprInterface {
|
||||
public:
|
||||
/**
|
||||
* @p name. Name for this lambda -- must be unique
|
||||
|
|
|
|||
|
|
@ -5,19 +5,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "FunctionExprInterface.hpp"
|
||||
#include "ProcedureExprInterface.hpp"
|
||||
#include "llvmintrinsic.hpp"
|
||||
#include <type_traits>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
class PrimitiveExprInterface : public FunctionExprInterface {
|
||||
class PrimitiveExprInterface : public ProcedureExprInterface {
|
||||
public:
|
||||
using void_function_type = void (*)();
|
||||
|
||||
public:
|
||||
explicit PrimitiveExprInterface(TypeDescr fn_type)
|
||||
: FunctionExprInterface(exprtype::primitive, fn_type) {}
|
||||
: ProcedureExprInterface(exprtype::primitive, fn_type) {}
|
||||
|
||||
/** downcast from Expression **/
|
||||
static bp<PrimitiveExprInterface> from(bp<Expression> x) {
|
||||
|
|
|
|||
33
include/xo/expression/ProcedureExprInterface.hpp
Normal file
33
include/xo/expression/ProcedureExprInterface.hpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/** @file FunctionExprInterface.hpp
|
||||
*
|
||||
* Author: Roland Conybeare
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Expression.hpp"
|
||||
//#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
class ProcedureExprInterface : public Expression {
|
||||
public:
|
||||
ProcedureExprInterface(exprtype extype, TypeDescr fn_type)
|
||||
: Expression(extype, fn_type) {}
|
||||
|
||||
/** downcast from Expression **/
|
||||
static bp<ProcedureExprInterface> from(bp<Expression> x) {
|
||||
return bp<ProcedureExprInterface>::from(x);
|
||||
}
|
||||
|
||||
virtual const std::string & name() const = 0;
|
||||
virtual int n_arg() const = 0; // { return this->value_td()->n_fn_arg(); }
|
||||
virtual TypeDescr fn_retval() const = 0; // { return this->value_td()->fn_retval(); }
|
||||
virtual TypeDescr fn_arg(uint32_t i) const = 0; // { return this->value_td()->fn_arg(i); }
|
||||
|
||||
private:
|
||||
}; /*FunctionInterface*/
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/** end FunctionExprInterface.hpp **/
|
||||
|
|
@ -259,7 +259,7 @@ namespace xo {
|
|||
TypeDescr lambda_td,
|
||||
const rp<LocalSymtab> & local_env,
|
||||
const rp<Expression> & body)
|
||||
: FunctionExprInterface(exprtype::lambda, lambda_td),
|
||||
: ProcedureExprInterface(exprtype::lambda, lambda_td),
|
||||
name_{name},
|
||||
body_{body},
|
||||
local_env_{local_env}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue