Add 'xo-expression/' from commit '5ac3c03a0c'
git-subtree-dir: xo-expression git-subtree-mainline:d0f5ccc1cegit-subtree-split:5ac3c03a0c
This commit is contained in:
commit
aecabbb144
46 changed files with 3241 additions and 0 deletions
1
xo-expression/example/CMakeLists.txt
Normal file
1
xo-expression/example/CMakeLists.txt
Normal file
|
|
@ -0,0 +1 @@
|
|||
add_subdirectory(ex1)
|
||||
12
xo-expression/example/ex1/CMakeLists.txt
Normal file
12
xo-expression/example/ex1/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# xo-expression/example/ex1/CMakeLists.txt
|
||||
|
||||
set(SELF_EXE xo_expression_ex1)
|
||||
set(SELF_SRCS ex1.cpp)
|
||||
|
||||
if (XO_ENABLE_EXAMPLES)
|
||||
xo_add_executable(${SELF_EXE} ${SELF_SRCS})
|
||||
xo_self_dependency(${SELF_EXE} xo_expression)
|
||||
xo_dependency(${SELF_EXE} refcnt)
|
||||
endif()
|
||||
|
||||
# end CMakeLists.txt
|
||||
39
xo-expression/example/ex1/ex1.cpp
Normal file
39
xo-expression/example/ex1/ex1.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/** @file ex1.cpp **/
|
||||
|
||||
#include "xo/expression/Constant.hpp"
|
||||
#include "xo/expression/Primitive.hpp"
|
||||
#include "xo/expression/llvmintrinsic.hpp"
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
int
|
||||
main() {
|
||||
using xo::ast::make_constant;
|
||||
using xo::ast::make_primitive;
|
||||
using xo::ast::llvmintrinsic;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
{
|
||||
auto expr = make_constant(7);
|
||||
}
|
||||
|
||||
{
|
||||
auto expr = make_primitive("sqrt",
|
||||
&::sqrt,
|
||||
false /*!explicit_symbol_def*/,
|
||||
llvmintrinsic::fp_sqrt);
|
||||
|
||||
auto expr_td = expr->value_td();
|
||||
|
||||
cout << "expr_td: " << expr_td->short_name() << endl;
|
||||
cout << "expr_td->is_function(): " << expr_td->is_function() << endl;
|
||||
cout << "expr_td->fn_retval(): " << expr_td->fn_retval()->short_name() << endl;
|
||||
cout << "expr_td->n_fn_arg(): " << expr_td->n_fn_arg() << endl;
|
||||
for (uint32_t i = 0; i < expr_td->n_fn_arg(); ++i)
|
||||
cout << "expr_td->fn_arg(" << i << "): " << expr_td->fn_arg(i)->short_name() << endl;
|
||||
cout << "expr_td->fn_is_noexcept(): " << expr_td->fn_is_noexcept() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
/** end ex1.cpp **/
|
||||
Loading…
Add table
Add a link
Reference in a new issue