代码拉取完成,页面将自动刷新
// SPDX-FileCopyrightText: 2023 Lars-Peter Clausen <lars@metafoo.de>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "PExpr.h"
#include "ivl_assert.h"
#include "map_named_args.h"
#include "netlist.h"
#include <iostream>
std::vector<PExpr*> map_named_args(Design *des,
const std::vector<perm_string> &names,
const std::vector<named_pexpr_t> &parms)
{
std::vector<PExpr*> args(names.size());
bool has_named = false;
for (size_t i = 0; i < parms.size(); i++) {
if (parms[i].name.nil()) {
if (!parms[i].parm)
continue;
if (has_named) {
std::cerr << parms[i].get_fileline() << ": error: "
<< "Positional argument must preceded "
<< "named arguments."
<< std::endl;
} else if (i < args.size()) {
args[i] = parms[i].parm;
}
continue;
}
has_named = true;
bool found = false;
for (size_t j = 0; j < names.size(); j++) {
if (names[j] == parms[i].name) {
if (args[j]) {
std::cerr << parms[i].get_fileline() << ": error: "
<< "Argument `"
<< parms[i].name
<< "` has already been specified."
<< std::endl;
des->errors++;
} else {
args[j] = parms[i].parm;
}
found = true;
break;
}
}
if (!found) {
std::cerr << parms[i].get_fileline() << ": error: "
<< "No argument called `"
<< parms[i].name << "`."
<< std::endl;
des->errors++;
}
}
return args;
}
std::vector<PExpr*> map_named_args(Design *des, NetBaseDef *def,
const std::vector<named_pexpr_t> &parms,
unsigned int off)
{
std::vector<perm_string> names;
for (size_t j = off; j < def->port_count(); j++)
names.push_back(def->port(j)->name());
return map_named_args(des, names, parms);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。