PointerList<T>* plist_of(std::initializer_list<T*> elements) { PointerList<T> *result = new PointerList<T>(elements.size()); for (T *el: elements) { result->push_back(el); } return result; }
void monicelli::loadModule(std::string const& from, ModuleRegistry &to) { YAML::Node module = YAML::LoadFile(from); if (!module["functions"]) return; for (auto const& proto: module["functions"]) { PointerList<FunArg> *args = new PointerList<FunArg>(); for (auto const& arg: proto.second["args"]) { args->push_back(new FunArg( new Id(arg.first.as<std::string>()), toType(arg.second.as<std::string>()), false )); } Type type; if (proto.second["type"]) { type = toType(proto.second["type"].as<std::string>()); } else { type = Type::VOID; } to.registerFunction(new FunctionPrototype( new Id(proto.first.as<std::string>()), type, args )); } }