Merge pull request #938 from larsclausen/unit-scope-possible-imports
Handle implicit task/function imports in the unit scope
This commit is contained in:
commit
75cd1a19f0
|
|
@ -0,0 +1,28 @@
|
|||
// Check that implicit imports of functions and tasks works if the wildcard
|
||||
// import statement is in the unit scope.
|
||||
|
||||
package P;
|
||||
|
||||
function integer f(integer x);
|
||||
return x * 2;
|
||||
endfunction
|
||||
|
||||
task t(bit failed);
|
||||
if (failed) begin
|
||||
$display("FAILED");
|
||||
end else begin
|
||||
$display("PASSED");
|
||||
end
|
||||
endtask
|
||||
|
||||
endpackage
|
||||
|
||||
import P::*;
|
||||
|
||||
module test;
|
||||
|
||||
initial begin
|
||||
t(f(10) !== 20);
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -46,6 +46,7 @@ sv_array_cassign6 vvp_tests/sv_array_cassign6.json
|
|||
sv_array_cassign7 vvp_tests/sv_array_cassign7.json
|
||||
sv_foreach9 vvp_tests/sv_foreach9.json
|
||||
sv_foreach10 vvp_tests/sv_foreach10.json
|
||||
sv_wildcard_import8 vvp_tests/sv_wildcard_import8.json
|
||||
sdf_header vvp_tests/sdf_header.json
|
||||
task_return1 vvp_tests/task_return1.json
|
||||
task_return2 vvp_tests/task_return2.json
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_wildcard_import8.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ]
|
||||
}
|
||||
2
main.cc
2
main.cc
|
|
@ -1126,6 +1126,8 @@ int main(int argc, char*argv[])
|
|||
rc += pform_parse(source_files[idx]);
|
||||
}
|
||||
|
||||
pform_finish();
|
||||
|
||||
if (pf_path) {
|
||||
ofstream out (pf_path);
|
||||
out << "PFORM DUMP NATURES:" << endl;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ extern void pform_dump(std::ostream&out, const PTaskFunc*tf);
|
|||
*/
|
||||
extern int pform_parse(const char*path);
|
||||
|
||||
extern void pform_finish();
|
||||
|
||||
extern std::string vl_file;
|
||||
|
||||
extern void pform_set_timescale(int units, int prec, const char*file,
|
||||
|
|
|
|||
21
pform.cc
21
pform.cc
|
|
@ -405,17 +405,22 @@ LexicalScope* pform_peek_scope(void)
|
|||
return lexical_scope;
|
||||
}
|
||||
|
||||
void pform_pop_scope()
|
||||
static void pform_check_possible_imports(LexicalScope *scope)
|
||||
{
|
||||
LexicalScope*scope = lexical_scope;
|
||||
assert(scope);
|
||||
|
||||
map<perm_string,PPackage*>::const_iterator cur;
|
||||
for (cur = scope->possible_imports.begin(); cur != scope->possible_imports.end(); ++cur) {
|
||||
if (scope->local_symbols.find(cur->first) == scope->local_symbols.end())
|
||||
scope->explicit_imports[cur->first] = cur->second;
|
||||
}
|
||||
scope->possible_imports.clear();
|
||||
}
|
||||
|
||||
void pform_pop_scope()
|
||||
{
|
||||
LexicalScope*scope = lexical_scope;
|
||||
assert(scope);
|
||||
|
||||
pform_check_possible_imports(scope);
|
||||
|
||||
lexical_scope = scope->parent_scope();
|
||||
assert(lexical_scope);
|
||||
|
|
@ -3406,3 +3411,11 @@ int pform_parse(const char*path)
|
|||
destroy_lexor();
|
||||
return error_count;
|
||||
}
|
||||
|
||||
void pform_finish()
|
||||
{
|
||||
// Wait until all parsing is done and all symbols in the unit scope are
|
||||
// known before importing possible imports.
|
||||
for (auto unit : pform_units)
|
||||
pform_check_possible_imports(unit);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue