#ifndef GUARD_RTGLIB_PROGRAM_HPP #define GUARD_RTGLIB_PROGRAM_HPP #include #include #include #include #include namespace rtg { struct program { template instruction * add_instruction(operand op, Ts*... args) { shape r = op.compute_shape({args->result...}); instructions.push_back({op, r, {args...}}); return std::addressof(instructions.back()); } template instruction * add_literal(Ts&&... xs) { instructions.emplace_back(literal{std::forward(xs)...}); return std::addressof(instructions.back()); } instruction * add_parameter(std::string name, shape s) { instructions.push_back({builtin::param{std::move(name)}, s, {}}); return std::addressof(instructions.back()); } literal eval(std::unordered_map params) const; // TODO: Change to stream operator void print() const; private: // A list is used to keep references to an instruction stable std::list instructions; }; } #endif