xo-reader2 stack: constants for operator primitive names
This commit is contained in:
parent
b08ba2f9ac
commit
cacfb181b4
3 changed files with 56 additions and 20 deletions
|
|
@ -17,31 +17,56 @@ namespace xo {
|
|||
using AAllocator = xo::mm::AAllocator;
|
||||
|
||||
public:
|
||||
/** name for multiply primitive. Used for op* **/
|
||||
static constexpr const char * c_multiply_pm_name = "_mul";
|
||||
/** polymorphic (in both arguments1) multiply **/
|
||||
static DPrimitive_gco_2_gco_gco * make_multiply_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for divide primitives. Used for op/ **/
|
||||
static constexpr const char * c_divide_pm_name = "_div";
|
||||
/** polymorphic (in both arguments) divide **/
|
||||
static DPrimitive_gco_2_gco_gco * make_divide_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for add primitives. Used for op+ **/
|
||||
static constexpr const char * c_add_pm_name = "_add";
|
||||
/** polymorphic (in both arguments) add **/
|
||||
static DPrimitive_gco_2_gco_gco * make_add_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for sub primitives. Used for op- **/
|
||||
static constexpr const char * c_sub_pm_name = "_sub";
|
||||
/** polymorphic (in both arguments) subtract **/
|
||||
static DPrimitive_gco_2_gco_gco * make_subtract_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for equality-comparison primitive. Used for op== **/
|
||||
static constexpr const char * c_cmpeq_pm_name = "_cmpeq";
|
||||
/** polymorphic (in both arguments) compare (==) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpeq_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for inequality-comparison prmitive. Used for op!= **/
|
||||
static constexpr const char * c_cmpne_pm_name = "_cmpne";
|
||||
/** polymorphic (in both arguments) compare (!=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpne_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for less-comparison primitive. Used for op< **/
|
||||
static constexpr const char * c_cmplt_pm_name = "_cmplt";
|
||||
/** polymorphic (in both arguments) compare (<) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmplt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for lesser-or-equal-comparison primitive. Used for op<= **/
|
||||
static constexpr const char * c_cmple_pm_name = "_cmple";
|
||||
/** polymorphic (in both arguments) compare (<=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmple_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for greater-comparison primitive. Used for op> **/
|
||||
static constexpr const char * c_cmpgt_pm_name = "_cmpgt";
|
||||
/** polymorphic (in both arguments) compare (>) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpgt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace xo {
|
|||
|
||||
auto pm_ty = obj<AType>();
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_mul", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_multiply_pm_name, pm_ty,
|
||||
&NumericDispatch::multiply);
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_div", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_divide_pm_name, pm_ty,
|
||||
&NumericDispatch::divide);
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_add", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_add_pm_name, pm_ty,
|
||||
&NumericDispatch::add);
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_sub", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_sub_pm_name, pm_ty,
|
||||
&NumericDispatch::subtract);
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpeq", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpeq_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_equal);
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpne", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpne_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_notequal);
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmplt", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmplt_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_less);
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmple", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmple_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_lessequal);
|
||||
}
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpgt", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpgt_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_greater);
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpge", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpge_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_greatequal);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "SyntaxStateMachine.hpp"
|
||||
#include "ToplevelSeqSsm.hpp"
|
||||
#include "DefineSsm.hpp"
|
||||
#include <xo/numeric/NumericPrimitives.hpp>
|
||||
#include <xo/procedure2/PrimitiveRegistry.hpp>
|
||||
#include <xo/procedure2/SimpleRcx.hpp>
|
||||
#include <xo/object2/array/IPrintable_DArray.hpp>
|
||||
|
|
@ -107,61 +108,71 @@ namespace xo {
|
|||
//
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_mul");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_multiply_pm_name);
|
||||
assert(name);
|
||||
this->multiply_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_div");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_divide_pm_name);
|
||||
assert(name);
|
||||
this->divide_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_add");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_add_pm_name);
|
||||
assert(name);
|
||||
this->add_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_sub");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_sub_pm_name);
|
||||
assert(name);
|
||||
this->subtract_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_cmpeq");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_cmpeq_pm_name);
|
||||
assert(name);
|
||||
this->cmpeq_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_cmpne");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_cmpne_pm_name);
|
||||
assert(name);
|
||||
this->cmpne_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_cmplt");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_cmplt_pm_name);
|
||||
assert(name);
|
||||
this->cmplt_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_cmple");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_cmple_pm_name);
|
||||
assert(name);
|
||||
this->cmple_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_cmpgt");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_cmpgt_pm_name);
|
||||
assert(name);
|
||||
this->cmpgt_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
||||
{
|
||||
const DUniqueString * name = stringtable_.lookup("_cmpge");
|
||||
const DUniqueString * name
|
||||
= stringtable_.lookup(NumericPrimitives::c_gmpge_pm_name);
|
||||
assert(name);
|
||||
this->cmpge_binding_ = global_symtab_->lookup_binding(name);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue