Skip to content

Commit 681c797

Browse files
author
Peter Aronsson
committed
Added annotation to external decl, needed for Library and Include annotation. Still need to do the implementation though.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1943 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent d02a019 commit 681c797

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

Compiler/Codegen.rml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ relation generate_function : DAE.Element => CFunction list =
590590
rule generate_function_name fpath => fn_name_str &
591591
string_append("_",fn_name_str) => fn_name_str &
592592
Debug.fprintl ("cgtr", ["generating external function ", fn_name_str, "\n"]) &
593-
let DAE.EXTERNALDECL(extfnname,extargs,extretarg,lang) = extdecl &
593+
let DAE.EXTERNALDECL(extfnname,extargs,extretarg,lang,ann) = extdecl &
594594

595595
Debug.fprintln ("cgtrdumpdae1", "Dumping DAE:") &
596596
Debug.fcall ("cgtrdumpdae1", DAE.dump2, DAE.DAE(orgdae)) &
@@ -1358,7 +1358,7 @@ relation generate_alloc_outvars_ext : (DAE.Element list, string,int, DAE.Externa
13581358
axiom generate_alloc_outvars_ext([],rv,tnr,extdecl) => (c_empty_function,tnr)
13591359

13601360

1361-
rule let DAE.EXTERNALDECL(_,_,_,"C") = extdecl &
1361+
rule let DAE.EXTERNALDECL(_,_,_,"C",_) = extdecl &
13621362
generate_alloc_outvar(var,rv,tnr) => (cfn1,tnr1) &
13631363
generate_alloc_outvars_ext(r,rv,tnr1,extdecl) => (cfn2,tnr2) &
13641364
c_merge_fn(cfn1,cfn2) => cfn
@@ -1368,7 +1368,7 @@ relation generate_alloc_outvars_ext : (DAE.Element list, string,int, DAE.Externa
13681368
rv,tnr,extdecl)
13691369
=> (cfn,tnr2)
13701370

1371-
rule let DAE.EXTERNALDECL(_,_,_,"FORTRAN 77") = extdecl &
1371+
rule let DAE.EXTERNALDECL(_,_,_,"FORTRAN 77",_) = extdecl &
13721372
generate_alloc_outvar_f77(var,rv,tnr) => (cfn1,tnr1) &
13731373
generate_alloc_outvars_ext(r,rv,tnr1,extdecl) => (cfn2,tnr2) &
13741374
c_merge_fn(cfn1,cfn2) => cfn
@@ -3436,7 +3436,7 @@ end
34363436
c_add_cleanups(cfn', ["return out;"]) => cfn
34373437
------------------------------------------------------
34383438
generate_external_wrapper_call(fnname,outvars,retstr,invars,
3439-
extdecl as DAE.EXTERNALDECL(extfnname,extargs,extretarg,lang),bivars,(Types.T_FUNCTION(args,restype),_)) => cfn
3439+
extdecl as DAE.EXTERNALDECL(extfnname,extargs,extretarg,lang,ann),bivars,(Types.T_FUNCTION(args,restype),_)) => cfn
34403440

34413441
rule Print.print_buf "#-- generate_external_wrapper_call failed\n"
34423442
----------------------------------------------------------------
@@ -3542,7 +3542,7 @@ relation generate_ext_call : (DAE.Element list, DAE.ExternalDecl, int) => (CFunc
35423542
generate_extcall_varcopy (outbiarglist, retarg, lang, tnr') => (argcopies,tnr'') &
35433543
c_merge_fns([argdecls,fcall,argcopies]) => extcall
35443544
-------------------------------------------------------------
3545-
generate_ext_call (vars, extdecl as DAE.EXTERNALDECL(n,arglist,retarg,lang), tnr) => (extcall,tnr'')
3545+
generate_ext_call (vars, extdecl as DAE.EXTERNALDECL(n,arglist,retarg,lang,ann), tnr) => (extcall,tnr'')
35463546

35473547
rule Print.print_buf "#-- generate_ext_call failed\n"
35483548
------------------------------------------------

Compiler/DAE.rml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ module DAE:
151151
datatype ExternalDecl = EXTERNALDECL of Ident * (* external function name *)
152152
ExtArg list * (* parameters *)
153153
ExtArg * (* return type *)
154-
string (* language *)
154+
string * (* language *)
155+
Absyn.Annotation option (*e.g. Library *)
155156

156157
(** A DAElist is a list of Elements. Variables, equations, functions,
157158
** algorithms, etc. are all found in this list.
@@ -384,7 +385,7 @@ relation dump_ext_decl_str : ExternalDecl => string =
384385
Util.string_append_list(["EXTERNALDECL(",id,", (",extargsstr,"), ",
385386
rettystr,", \"",lang,"\")"]) => str
386387
-----------------------------------------------------------------------
387-
dump_ext_decl_str EXTERNALDECL(id,extargs,retty,lang) => str
388+
dump_ext_decl_str EXTERNALDECL(id,extargs,retty,lang,ann) => str
388389
end
389390

390391
(** relation: dump_ext_arg_str
@@ -2660,7 +2661,7 @@ relation get_all_exps_element : Element => Exp.Exp list =
26602661
Util.list_flatten(expslist) => exps
26612662
------------------------------------
26622663
get_all_exps_element EXTFUNCTION(path, DAE(elements), ty,
2663-
EXTERNALDECL(fname, args, retarg, lang)) => exps
2664+
EXTERNALDECL(fname, args, retarg, lang,ann)) => exps
26642665

26652666
axiom get_all_exps_element ASSERT(exp) => [exp]
26662667

Compiler/Inst.rml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,7 +3665,8 @@ relation inst_ext_decl: (Env.Env, Ident, SCode.ClassDef, bool (*impl*) ) => DAE.
36653665
inst_ext_get_fargs (env, extdecl,impl) => fargs &
36663666
inst_ext_get_rettype (env, extdecl,impl) => rettype &
36673667
inst_ext_get_lang (extdecl) => lang &
3668-
let daeextdecl = DAE.EXTERNALDECL(fname,fargs,rettype,lang)
3668+
inst_ext_get_annotation(extdecl) => ann &
3669+
let daeextdecl = DAE.EXTERNALDECL(fname,fargs,rettype,lang,ann)
36693670
-------------------------------------
36703671
inst_ext_decl (env, n, SCode.PARTS(_,_,_,_,_,SOME(extdecl)),impl) => daeextdecl
36713672

@@ -3675,7 +3676,8 @@ relation inst_ext_decl: (Env.Env, Ident, SCode.ClassDef, bool (*impl*) ) => DAE.
36753676
inst_ext_get_fargs (env, extdecl,impl) => fargs &
36763677
inst_ext_get_rettype (env, extdecl, impl) => rettype &
36773678
inst_ext_get_lang (extdecl) => lang &
3678-
let daeextdecl = DAE.EXTERNALDECL(fname,fargs,rettype,lang)
3679+
inst_ext_get_annotation(orgextdecl) => ann &
3680+
let daeextdecl = DAE.EXTERNALDECL(fname,fargs,rettype,lang,ann)
36793681
-------------------------------------
36803682
inst_ext_decl (env, n, SCode.PARTS(els,_,_,_,_,SOME(orgextdecl)),impl) => daeextdecl
36813683

@@ -3825,6 +3827,19 @@ relation inst_ext_get_fname : (Absyn.ExternalDecl, Ident) => Ident =
38253827

38263828
end
38273829

3830+
(** relation: inst_ext_get_annotation
3831+
** author: PA
3832+
**
3833+
** Return the annotation associated with an external function declaration.
3834+
**)
3835+
3836+
relation inst_ext_get_annotation: Absyn.ExternalDecl
3837+
=> Absyn.Annotation option =
3838+
3839+
axiom inst_ext_get_annotation(Absyn.EXTERNALDECL(_,_,_,_,ann)) => ann
3840+
3841+
end
3842+
38283843

38293844
(** relation: inst_ext_get_lang
38303845
**

0 commit comments

Comments
 (0)