filter null checks

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2023-07-05 12:40:56 -07:00
parent 099936561d
commit c8c98c76ea
1 changed files with 46 additions and 40 deletions

View File

@ -2495,21 +2495,23 @@ filter_ports(const char *property,
const char *pattern, const char *pattern,
PortSeq *ports) PortSeq *ports)
{ {
Sta *sta = Sta::sta();
PortSeq filtered_ports; PortSeq filtered_ports;
bool exact_match = stringEq(op, "=="); if (ports) {
bool pattern_match = stringEq(op, "=~"); Sta *sta = Sta::sta();
bool not_match = stringEq(op, "!="); bool exact_match = stringEq(op, "==");
for (const Port *port : *ports) { bool pattern_match = stringEq(op, "=~");
PropertyValue value(getProperty(port, property, sta)); bool not_match = stringEq(op, "!=");
const char *prop = value.stringValue(); for (const Port *port : *ports) {
if (prop && PropertyValue value(getProperty(port, property, sta));
((exact_match && stringEq(prop, pattern)) const char *prop = value.stringValue();
|| (not_match && !stringEq(prop, pattern)) if (prop &&
|| (pattern_match && patternMatch(pattern, prop)))) ((exact_match && stringEq(prop, pattern))
filtered_ports.push_back(port); || (not_match && !stringEq(prop, pattern))
|| (pattern_match && patternMatch(pattern, prop))))
filtered_ports.push_back(port);
}
delete ports;
} }
delete ports;
return filtered_ports; return filtered_ports;
} }
@ -2519,22 +2521,24 @@ filter_insts(const char *property,
const char *pattern, const char *pattern,
InstanceSeq *insts) InstanceSeq *insts)
{ {
Sta *sta = Sta::sta();
cmdLinkedNetwork();
bool exact_match = stringEq(op, "==");
bool pattern_match = stringEq(op, "=~");
bool not_match = stringEq(op, "!=");
InstanceSeq filtered_insts; InstanceSeq filtered_insts;
for (const Instance *inst : *insts) { if (insts) {
PropertyValue value(getProperty(inst, property, sta)); Sta *sta = Sta::sta();
const char *prop = value.stringValue(); cmdLinkedNetwork();
if (prop && bool exact_match = stringEq(op, "==");
((exact_match && stringEq(prop, pattern)) bool pattern_match = stringEq(op, "=~");
|| (not_match && !stringEq(prop, pattern)) bool not_match = stringEq(op, "!=");
|| (pattern_match && patternMatch(pattern, prop)))) for (const Instance *inst : *insts) {
filtered_insts.push_back(inst); PropertyValue value(getProperty(inst, property, sta));
const char *prop = value.stringValue();
if (prop &&
((exact_match && stringEq(prop, pattern))
|| (not_match && !stringEq(prop, pattern))
|| (pattern_match && patternMatch(pattern, prop))))
filtered_insts.push_back(inst);
}
delete insts;
} }
delete insts;
return filtered_insts; return filtered_insts;
} }
@ -2544,21 +2548,23 @@ filter_pins(const char *property,
const char *pattern, const char *pattern,
PinSeq *pins) PinSeq *pins)
{ {
Sta *sta = Sta::sta();
PinSeq filtered_pins; PinSeq filtered_pins;
bool exact_match = stringEq(op, "=="); if (pins) {
bool pattern_match = stringEq(op, "=~"); Sta *sta = Sta::sta();
bool not_match = stringEq(op, "!="); bool exact_match = stringEq(op, "==");
for (const Pin *pin : *pins) { bool pattern_match = stringEq(op, "=~");
PropertyValue value(getProperty(pin, property, sta)); bool not_match = stringEq(op, "!=");
const char *prop = value.stringValue(); for (const Pin *pin : *pins) {
if (prop && PropertyValue value(getProperty(pin, property, sta));
((exact_match && stringEq(prop, pattern)) const char *prop = value.stringValue();
|| (not_match && !stringEq(prop, pattern)) if (prop &&
|| (pattern_match && patternMatch(pattern, prop)))) ((exact_match && stringEq(prop, pattern))
filtered_pins.push_back(pin); || (not_match && !stringEq(prop, pattern))
|| (pattern_match && patternMatch(pattern, prop))))
filtered_pins.push_back(pin);
}
delete pins;
} }
delete pins;
return filtered_pins; return filtered_pins;
} }