25 #include <opencog/atomspace/atom_types.h>
37 using namespace opencog;
44 if (2 != oset.size() or
45 GROUNDED_SCHEMA_NODE != oset[0]->getType() or
46 LIST_LINK != oset[1]->getType())
48 throw RuntimeException(TRACE_INFO,
49 "ExecutionOutputLink must have schema and args!");
57 :
FunctionLink(EXECUTION_OUTPUT_LINK, schema, args, tv, av)
59 if (GROUNDED_SCHEMA_NODE != schema->
getType())
60 throw RuntimeException(TRACE_INFO,
"Expecting GroundedSchemaNode!");
62 if (LIST_LINK != args->
getType())
63 throw RuntimeException(TRACE_INFO,
64 "ExecutionOutputLink must have schema and args!");
71 if (EXECUTION_OUTPUT_LINK != tscope)
72 throw RuntimeException(TRACE_INFO,
73 "Expection an ExecutionOutputLink!");
117 std::vector<Handle> new_oset;
118 bool changed =
false;
119 for (
Handle ho : largs->getOutgoingSet())
124 new_oset.push_back(nh);
125 if (nh != ho) changed =
true;
128 args = as->
add_link(LIST_LINK, new_oset);
132 const std::string& schema =
NodeCast(gsn)->getName();
136 if (0 == schema.compare(0,4,
"scm:", 4))
141 while (
' ' == schema[pos]) pos++;
149 throw RuntimeException(TRACE_INFO,
150 "Failed evaluation; see logfile for stack trace.");
153 throw RuntimeException(TRACE_INFO,
154 "Cannot evaluate scheme GroundedSchemaNode!");
158 if (0 == schema.compare(0, 3,
"py:", 3))
163 while (
' ' == schema[pos]) pos++;
174 throw RuntimeException(TRACE_INFO,
175 "Cannot evaluate python GroundedSchemaNode!");
180 throw RuntimeException(TRACE_INFO,
181 "Cannot evaluate unknown GroundedSchemaNode!");
Handle apply(const std::string &func, Handle varargs)
std::vector< Handle > HandleSeq
a list of handles
std::shared_ptr< TruthValue > TruthValuePtr
std::shared_ptr< AttentionValue > AttentionValuePtr
static Handle do_execute(AtomSpace *, const Handle &schema, const Handle &args)
std::shared_ptr< Link > LinkPtr
static NodePtr NodeCast(const Handle &h)
static PythonEval & instance(AtomSpace *atomspace=NULL)
virtual bool eval_error(void)
static SchemeEval * get_evaluator(AtomSpace *=NULL)
Handle apply(AtomSpace *, const std::string &func, Handle varargs)
static LinkPtr LinkCast(const Handle &h)
Handle execute(const Handle &expr)
ExecutionOutputLink(const HandleSeq &oset, TruthValuePtr tv=TruthValue::NULL_TV(), AttentionValuePtr av=AttentionValue::DEFAULT_AV())
unsigned short Type
type of Atoms, represented as short integer (16 bits)
Handle add_link(Type t, const HandleSeq &outgoing, bool async=false)
virtual Handle execute(AtomSpace *=NULL) const