Skip to content

Commit

Permalink
Remove redundant checks for package imports during parsing.
Browse files Browse the repository at this point in the history
The find_* and symbol_search functions now handle this.
  • Loading branch information
martinwhitaker committed Sep 27, 2019
1 parent 5521977 commit 269ec2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 56 deletions.
57 changes: 4 additions & 53 deletions pform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -663,19 +663,11 @@ PBlock* pform_push_block_scope(char*name, PBlock::BL_TYPE bt)
}

/*
* Create a new identifier. Check if this is an imported name.
* Create a new identifier.
*/
PEIdent* pform_new_ident(const pform_name_t&name)
{
LexicalScope*scope = pform_peek_scope();
map<perm_string,PPackage*>::const_iterator pkg = scope->imports.find(name.front().name);
if (pkg == scope->imports.end())
return new PEIdent(name);

// XXXX For now, do not support indexed imported names.
assert(name.back().index.size() == 0);

return new PEIdent(pkg->second, name);
return new PEIdent(name);
}

PGenerate* pform_parent_generate(void)
Expand Down Expand Up @@ -841,29 +833,7 @@ PECallFunction* pform_make_call_function(const struct vlltype&loc,
const pform_name_t&name,
const list<PExpr*>&parms)
{
PECallFunction*tmp = 0;

// First try to get the function name from a package. Check
// the imports, and if the name is there, make the function as
// a package member.
do {
if (name.size() != 1)
break;

perm_string use_name = peek_tail_name(name);

map<perm_string,PPackage*>::iterator cur_pkg;
cur_pkg = lexical_scope->imports.find(use_name);
if (cur_pkg == lexical_scope->imports.end())
break;

tmp = new PECallFunction(cur_pkg->second, use_name, parms);
} while(0);

if (tmp == 0) {
tmp = new PECallFunction(name, parms);
}

PECallFunction*tmp = new PECallFunction(name, parms);
FILE_NAME(tmp, loc);
return tmp;
}
Expand All @@ -872,26 +842,7 @@ PCallTask* pform_make_call_task(const struct vlltype&loc,
const pform_name_t&name,
const list<PExpr*>&parms)
{
PCallTask*tmp = 0;

do {
if (name.size() != 1)
break;

perm_string use_name = peek_tail_name(name);

map<perm_string,PPackage*>::iterator cur_pkg;
cur_pkg = lexical_scope->imports.find(use_name);
if (cur_pkg == lexical_scope->imports.end())
break;

tmp = new PCallTask(cur_pkg->second, name, parms);
} while (0);

if (tmp == 0) {
tmp = new PCallTask(name, parms);
}

PCallTask*tmp = new PCallTask(name, parms);
FILE_NAME(tmp, loc);
return tmp;
}
Expand Down
5 changes: 2 additions & 3 deletions pform.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IVL_pform_H
#define IVL_pform_H
/*
* Copyright (c) 1998-2017 Stephen Williams ([email protected])
* Copyright (c) 1998-2019 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -312,8 +312,7 @@ extern void pform_set_typedef(perm_string name, data_type_t*data_type,
std::list<pform_range_t>*unp_ranges);

/*
* This function makes a PECallFunction of the named function. Decide
* if this function is in the scope or is imported from a package.
* This function makes a PECallFunction of the named function.
*/
extern PECallFunction* pform_make_call_function(const struct vlltype&loc,
const pform_name_t&name,
Expand Down

0 comments on commit 269ec2f

Please sign in to comment.