mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-11 13:40:53 +00:00
Merge pull request #5269 from georgerennie/george/pyosys_source_location
pyosys: support trailing defaulted source_location arguments
This commit is contained in:
commit
4230c2712f
2 changed files with 32 additions and 16 deletions
|
@ -71,7 +71,7 @@ keyword_aliases = {
|
||||||
|
|
||||||
#These can be used without any explicit conversion
|
#These can be used without any explicit conversion
|
||||||
primitive_types = ["void", "bool", "int", "double", "size_t", "std::string",
|
primitive_types = ["void", "bool", "int", "double", "size_t", "std::string",
|
||||||
"string", "State", "char_p"]
|
"string", "State", "char_p", "std::source_location", "source_location"]
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
@ -1137,10 +1137,18 @@ class WConstructor:
|
||||||
str_def = str_def[0:found].strip()
|
str_def = str_def[0:found].strip()
|
||||||
if len(str_def) == 0:
|
if len(str_def) == 0:
|
||||||
return con
|
return con
|
||||||
for arg in split_list(str_def, ","):
|
args = split_list(str_def, ",")
|
||||||
|
for i, arg in enumerate(args):
|
||||||
parsed = Attribute.from_string(arg.strip(), containing_file, line_number)
|
parsed = Attribute.from_string(arg.strip(), containing_file, line_number)
|
||||||
if parsed == None:
|
if parsed == None:
|
||||||
return None
|
return None
|
||||||
|
# Only allow std::source_location as defaulted last argument, and
|
||||||
|
# don't append so it takes default value
|
||||||
|
if parsed.wtype.name in ["std::source_location", "source_location"]:
|
||||||
|
if parsed.default_value is None or i != len(args) - 1:
|
||||||
|
debug("std::source_location not defaulted last arg of " + class_.name + " is unsupported", 2)
|
||||||
|
return None
|
||||||
|
continue
|
||||||
con.args.append(parsed)
|
con.args.append(parsed)
|
||||||
return con
|
return con
|
||||||
|
|
||||||
|
@ -1379,12 +1387,20 @@ class WFunction:
|
||||||
str_def = str_def[:found].strip()
|
str_def = str_def[:found].strip()
|
||||||
if(len(str_def) == 0):
|
if(len(str_def) == 0):
|
||||||
return func
|
return func
|
||||||
for arg in split_list(str_def, ","):
|
args = split_list(str_def, ",")
|
||||||
|
for i, arg in enumerate(args):
|
||||||
if arg.strip() == "...":
|
if arg.strip() == "...":
|
||||||
continue
|
continue
|
||||||
parsed = Attribute.from_string(arg.strip(), containing_file, line_number)
|
parsed = Attribute.from_string(arg.strip(), containing_file, line_number)
|
||||||
if parsed == None:
|
if parsed == None:
|
||||||
return None
|
return None
|
||||||
|
# Only allow std::source_location as defaulted last argument, and
|
||||||
|
# don't append so it takes default value
|
||||||
|
if parsed.wtype.name in ["std::source_location", "source_location"]:
|
||||||
|
if parsed.default_value is None or i != len(args) - 1:
|
||||||
|
debug("std::source_location not defaulted last arg of " + func.name + " is unsupported", 2)
|
||||||
|
return None
|
||||||
|
continue
|
||||||
func.args.append(parsed)
|
func.args.append(parsed)
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue