Skip to content

Commit

Permalink
Merge branch 'rename' into 'master'
Browse files Browse the repository at this point in the history
Rename ExternalProc to ExternalSymbol

See merge request lfortran/lfortran!728
  • Loading branch information
certik committed Mar 17, 2021
2 parents f1c2e25 + 53daeda commit a9a80a6
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion grammar/ASR.asdl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ symbol
expr return_var, abi abi, access access)
| GenericProcedure(symbol_table parent_symtab, identifier name,
symbol* procs, access access)
| ExternalProc(symbol_table parent_symtab, identifier name,
| ExternalSymbol(symbol_table parent_symtab, identifier name,
symbol external, access acess)
| DerivedType(symbol_table symtab, identifier name, abi abi, access access)
| Variable(symbol_table parent_symtab, identifier name, intent intent,
Expand Down
8 changes: 4 additions & 4 deletions src/lfortran/asr_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ static inline char *symbol_name(const ASR::symbol_t *f)
case ASR::symbolType::Variable: {
return ASR::down_cast<ASR::Variable_t>(f)->m_name;
}
case ASR::symbolType::ExternalProc: {
return ASR::down_cast<ASR::ExternalProc_t>(f)->m_name;
case ASR::symbolType::ExternalSymbol: {
return ASR::down_cast<ASR::ExternalSymbol_t>(f)->m_name;
}
default : throw LFortranException("Not implemented");
}
Expand Down Expand Up @@ -109,8 +109,8 @@ static inline SymbolTable *symbol_parent_symtab(const ASR::symbol_t *f)
case ASR::symbolType::Variable: {
return ASR::down_cast<ASR::Variable_t>(f)->m_parent_symtab;
}
case ASR::symbolType::ExternalProc: {
return ASR::down_cast<ASR::ExternalProc_t>(f)->m_parent_symtab;
case ASR::symbolType::ExternalSymbol: {
return ASR::down_cast<ASR::ExternalSymbol_t>(f)->m_parent_symtab;
}
default : throw LFortranException("Not implemented");
}
Expand Down
4 changes: 2 additions & 2 deletions src/lfortran/semantics/asr_scopes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ uint32_t SymbolTable::get_hash_uint32() {
hash = murmur_hash_str(v->m_name, hash);
break;
}
case (ASR::symbolType::ExternalProc) : {
ASR::ExternalProc_t *v = ASR::down_cast<ASR::ExternalProc_t>(a.second);
case (ASR::symbolType::ExternalSymbol) : {
ASR::ExternalSymbol_t *v = ASR::down_cast<ASR::ExternalSymbol_t>(a.second);
hash = murmur_hash_str(v->m_name, hash);
break;
}
Expand Down
18 changes: 9 additions & 9 deletions src/lfortran/semantics/ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ class SymbolTableVisitor : public AST::BaseVisitor<SymbolTableVisitor>
// TODO: only import "public" symbols from the module
if (ASR::is_a<ASR::Subroutine_t>(*item.second)) {
ASR::Subroutine_t *msub = ASR::down_cast<ASR::Subroutine_t>(item.second);
ASR::asr_t *sub = ASR::make_ExternalProc_t(
ASR::asr_t *sub = ASR::make_ExternalSymbol_t(
al, msub->base.base.loc,
/* a_symtab */ current_scope,
/* a_name */ msub->m_name,
Expand All @@ -560,7 +560,7 @@ class SymbolTableVisitor : public AST::BaseVisitor<SymbolTableVisitor>
current_scope->scope[sym] = ASR::down_cast<ASR::symbol_t>(sub);
} else if (ASR::is_a<ASR::Function_t>(*item.second)) {
ASR::Function_t *mfn = ASR::down_cast<ASR::Function_t>(item.second);
ASR::asr_t *fn = ASR::make_ExternalProc_t(
ASR::asr_t *fn = ASR::make_ExternalSymbol_t(
al, mfn->base.base.loc,
/* a_symtab */ current_scope,
/* a_name */ mfn->m_name,
Expand Down Expand Up @@ -600,7 +600,7 @@ class SymbolTableVisitor : public AST::BaseVisitor<SymbolTableVisitor>
// `msub` via the `external` field.
Str name;
name.from_str(al, local_sym);
ASR::asr_t *sub = ASR::make_ExternalProc_t(
ASR::asr_t *sub = ASR::make_ExternalSymbol_t(
al, msub->base.base.loc,
/* a_symtab */ current_scope,
/* a_name */ name.c_str(al),
Expand All @@ -615,7 +615,7 @@ class SymbolTableVisitor : public AST::BaseVisitor<SymbolTableVisitor>
}
Str name;
name.from_str(al, local_sym);
ASR::asr_t *ep = ASR::make_ExternalProc_t(
ASR::asr_t *ep = ASR::make_ExternalSymbol_t(
al, t->base.loc,
current_scope,
/* a_name */ name.c_str(al),
Expand All @@ -634,7 +634,7 @@ class SymbolTableVisitor : public AST::BaseVisitor<SymbolTableVisitor>
// `mfn` via the `external` field.
Str name;
name.from_str(al, local_sym);
ASR::asr_t *fn = ASR::make_ExternalProc_t(
ASR::asr_t *fn = ASR::make_ExternalSymbol_t(
al, mfn->base.base.loc,
/* a_symtab */ current_scope,
/* a_name */ name.c_str(al),
Expand Down Expand Up @@ -1344,8 +1344,8 @@ class BodyVisitor : public AST::BaseVisitor<BodyVisitor>
return sub;
break;
}
case (ASR::symbolType::ExternalProc) : {
ASR::ExternalProc_t *p = ASR::down_cast<ASR::ExternalProc_t>(sub);
case (ASR::symbolType::ExternalSymbol) : {
ASR::ExternalSymbol_t *p = ASR::down_cast<ASR::ExternalSymbol_t>(sub);
ASR::symbol_t *s = p->m_external;
switch (s->type) {
case (ASR::symbolType::Subroutine) : {
Expand Down Expand Up @@ -1522,10 +1522,10 @@ class BodyVisitor : public AST::BaseVisitor<BodyVisitor>
v, args.p, args.size(), nullptr, 0, type);
break;
}
case (ASR::symbolType::ExternalProc) : {
case (ASR::symbolType::ExternalSymbol) : {
Vec<ASR::expr_t*> args = visit_expr_list(x.m_args, x.n_args);
ASR::ttype_t *type;
ASR::symbol_t *f2 = ASR::down_cast<ASR::ExternalProc_t>(v)->m_external;
ASR::symbol_t *f2 = ASR::down_cast<ASR::ExternalSymbol_t>(v)->m_external;
LFORTRAN_ASSERT(f2);
type = EXPR2VAR(ASR::down_cast<ASR::Function_t>(f2)->m_return_var)->m_type;
tmp = ASR::make_FuncCall_t(al, x.base.base.loc,
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-interface_01-9dc98da.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-interface_01-9dc98da.stdout",
"stdout_hash": "22660229436595a8294c0f5f68286babc0f7fd9c866361096a9701dd",
"stdout_hash": "274afcfac4fb357ae45c1c9abec6519fad55400b83f863ea85387df9",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-interface_01-9dc98da.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {interface_01: (Program (SymbolTable 5 {a: (ExternalProc 5 a 2 a Public), i: (Variable 5 i Local () Default (Integer 4 []) Source Public), r: (Variable 5 r Local () Default (Real 4 []) Source Public)}) interface_01 [(= (Var 5 i) (ConstantInteger 5 (Integer 4 []))) (SubroutineCall 2 a1 [(Var 5 i)]) (If (Compare (Var 5 i) NotEq (ConstantInteger 6 (Integer 4 [])) (Logical 4 [])) [(ErrorStop ())] []) (= (Var 5 r) (ImplicitCast (ConstantInteger 6 (Integer 4 [])) IntegerToReal (Real 4 []))) (SubroutineCall 2 a2 [(Var 5 r)]) (If (Compare (Var 5 r) NotEq (ImplicitCast (ConstantInteger 7 (Integer 4 [])) IntegerToReal (Real 4 [])) (Logical 4 [])) [(ErrorStop ())] [])]), interface_01_mod: (Module (SymbolTable 2 {a: (GenericProcedure 2 a [2 a1 2 a2] Public), a1: (Subroutine (SymbolTable 3 {a: (Variable 3 a InOut () Default (Integer 4 []) Source Public)}) a1 [(Var 3 a)] [(= (Var 3 a) (BinOp (Var 3 a) Add (ConstantInteger 1 (Integer 4 [])) (Integer 4 [])))] Source Public), a2: (Subroutine (SymbolTable 4 {a: (Variable 4 a InOut () Default (Real 4 []) Source Public)}) a2 [(Var 4 a)] [(= (Var 4 a) (BinOp (Var 4 a) Add (ImplicitCast (ConstantInteger 1 (Integer 4 [])) IntegerToReal (Real 4 [])) (Real 4 [])))] Source Public)}) interface_01_mod)}) [])
(TranslationUnit (SymbolTable 1 {interface_01: (Program (SymbolTable 5 {a: (ExternalSymbol 5 a 2 a Public), i: (Variable 5 i Local () Default (Integer 4 []) Source Public), r: (Variable 5 r Local () Default (Real 4 []) Source Public)}) interface_01 [(= (Var 5 i) (ConstantInteger 5 (Integer 4 []))) (SubroutineCall 2 a1 [(Var 5 i)]) (If (Compare (Var 5 i) NotEq (ConstantInteger 6 (Integer 4 [])) (Logical 4 [])) [(ErrorStop ())] []) (= (Var 5 r) (ImplicitCast (ConstantInteger 6 (Integer 4 [])) IntegerToReal (Real 4 []))) (SubroutineCall 2 a2 [(Var 5 r)]) (If (Compare (Var 5 r) NotEq (ImplicitCast (ConstantInteger 7 (Integer 4 [])) IntegerToReal (Real 4 [])) (Logical 4 [])) [(ErrorStop ())] [])]), interface_01_mod: (Module (SymbolTable 2 {a: (GenericProcedure 2 a [2 a1 2 a2] Public), a1: (Subroutine (SymbolTable 3 {a: (Variable 3 a InOut () Default (Integer 4 []) Source Public)}) a1 [(Var 3 a)] [(= (Var 3 a) (BinOp (Var 3 a) Add (ConstantInteger 1 (Integer 4 [])) (Integer 4 [])))] Source Public), a2: (Subroutine (SymbolTable 4 {a: (Variable 4 a InOut () Default (Real 4 []) Source Public)}) a2 [(Var 4 a)] [(= (Var 4 a) (BinOp (Var 4 a) Add (ImplicitCast (ConstantInteger 1 (Integer 4 [])) IntegerToReal (Real 4 [])) (Real 4 [])))] Source Public)}) interface_01_mod)}) [])
2 changes: 1 addition & 1 deletion tests/reference/asr-modules_01-3535389.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-modules_01-3535389.stdout",
"stdout_hash": "1a5c119ee35bf2faa8bda17804630314741dfc4fd1fb89b129c435e0",
"stdout_hash": "39f1fd0d71df9c199c0f9347d0b989893532daf8bc08af12498c55ff",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-modules_01-3535389.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {a: (Module (SymbolTable 2 {b: (Subroutine (SymbolTable 3 {}) b [] [(Print () [(Str "b()" (Character 8 []))])] Source Public)}) a), modules_01: (Program (SymbolTable 4 {b: (ExternalProc 4 b 2 b Public)}) modules_01 [(SubroutineCall 2 b [])])}) [])
(TranslationUnit (SymbolTable 1 {a: (Module (SymbolTable 2 {b: (Subroutine (SymbolTable 3 {}) b [] [(Print () [(Str "b()" (Character 8 []))])] Source Public)}) a), modules_01: (Program (SymbolTable 4 {b: (ExternalSymbol 4 b 2 b Public)}) modules_01 [(SubroutineCall 2 b [])])}) [])
2 changes: 1 addition & 1 deletion tests/reference/asr-modules_02-74be421.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-modules_02-74be421.stdout",
"stdout_hash": "9fd1db283c8d46eed3ebd530e6424414eb2d326371d6635988d27cac",
"stdout_hash": "f6563af62052eb5ecb2d3d8dbb25aea463fb79ab637b2dcfe1a4a87f",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-modules_02-74be421.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {a: (Module (SymbolTable 2 {b: (Subroutine (SymbolTable 3 {}) b [] [(Print () [(Str "b()" (Character 8 []))])] Source Public)}) a), c: (Module (SymbolTable 4 {d: (Subroutine (SymbolTable 5 {}) d [] [(Print () [(Str "d()" (Character 8 []))])] Source Public)}) c), modules_02: (Program (SymbolTable 6 {b: (ExternalProc 6 b 2 b Public), x: (ExternalProc 6 x 4 d Public)}) modules_02 [(SubroutineCall 2 b []) (SubroutineCall 4 d [])])}) [])
(TranslationUnit (SymbolTable 1 {a: (Module (SymbolTable 2 {b: (Subroutine (SymbolTable 3 {}) b [] [(Print () [(Str "b()" (Character 8 []))])] Source Public)}) a), c: (Module (SymbolTable 4 {d: (Subroutine (SymbolTable 5 {}) d [] [(Print () [(Str "d()" (Character 8 []))])] Source Public)}) c), modules_02: (Program (SymbolTable 6 {b: (ExternalSymbol 6 b 2 b Public), x: (ExternalSymbol 6 x 4 d Public)}) modules_02 [(SubroutineCall 2 b []) (SubroutineCall 4 d [])])}) [])
2 changes: 1 addition & 1 deletion tests/reference/asr-modules_06-609dd30.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-modules_06-609dd30.stdout",
"stdout_hash": "da470b6bea1be6902a7f6d4b013f36e99b7369aaca8ca0673e37c123",
"stdout_hash": "f04252220dd72b903179d098949d8724860e7b297af4292dac8bf594",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-modules_06-609dd30.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {a: (Module (SymbolTable 2 {b: (Function (SymbolTable 3 {r: (Variable 3 r ReturnVar () Default (Integer 4 []) Source Public)}) b [] [(Print () [(Str "b()" (Character 8 []))]) (= (Var 3 r) (ConstantInteger 5 (Integer 4 [])))] (Var 3 r) Source Public)}) a), modules_06: (Program (SymbolTable 4 {b: (ExternalProc 4 b 2 b Public), i: (Variable 4 i Local () Default (Integer 4 []) Source Public)}) modules_06 [(= (Var 4 i) (FuncCall 2 b [] [] (Integer 4 []))) (Print () [(Var 4 i)])])}) [])
(TranslationUnit (SymbolTable 1 {a: (Module (SymbolTable 2 {b: (Function (SymbolTable 3 {r: (Variable 3 r ReturnVar () Default (Integer 4 []) Source Public)}) b [] [(Print () [(Str "b()" (Character 8 []))]) (= (Var 3 r) (ConstantInteger 5 (Integer 4 [])))] (Var 3 r) Source Public)}) a), modules_06: (Program (SymbolTable 4 {b: (ExternalSymbol 4 b 2 b Public), i: (Variable 4 i Local () Default (Integer 4 []) Source Public)}) modules_06 [(= (Var 4 i) (FuncCall 2 b [] [] (Integer 4 []))) (Print () [(Var 4 i)])])}) [])

0 comments on commit a9a80a6

Please sign in to comment.