Skip to content

Commit

Permalink
Adrian Pop, adrpo@ida.liu.se, 2006-02-24
Browse files Browse the repository at this point in the history
- changed/added API functions
  + have a look at Compiler/interactive_api.txt or: 
    - testsuite/mosfiles/interactive_api_attributes.mos
    - testsuite/mosfiles/loadFileInteractiveQualified.mos
  + changed getClassInformation API in Compiler/Interactive.rml
  + added getClassAttributes API in Compiler/Interactive.rml



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2162 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Feb 24, 2006
1 parent b36552f commit 0abdf22
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 18 deletions.
103 changes: 85 additions & 18 deletions Compiler/Interactive.rml
Expand Up @@ -1445,7 +1445,7 @@ relation evaluate_graphical_api: (InteractiveStmts, InteractiveSymbolTable)
Absyn.FUNCTIONARGS([Absyn.STRING(str)],_)))],_
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => ("true",st)

rule get_class_information(cr,p) => resstr
-----------------------
evaluate_graphical_api(
Expand Down Expand Up @@ -1652,16 +1652,24 @@ relation evaluate_graphical_api: (InteractiveStmts, InteractiveSymbolTable)
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (res_str,SYMBOLTABLE(p',s,[],[],[]))



(* adrpo added 2005-11-03 *)
rule get_cref_info(cr,p) => resstr
-----------------------
evaluate_graphical_api(
ISTMTS([IEXP(Absyn.CALL(
Absyn.CREF_IDENT("getCrefInfo",_),Absyn.FUNCTIONARGS([Absyn.CREF(cr)],_)))],_
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (resstr,st)
(* adrpo added 2005-11-03 *)
rule get_cref_info(cr,p) => resstr
-----------------------
evaluate_graphical_api(
ISTMTS([IEXP(Absyn.CALL(
Absyn.CREF_IDENT("getCrefInfo",_),Absyn.FUNCTIONARGS([Absyn.CREF(cr)],_)))],_
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (resstr,st)

(* added by adrpo, 2006-02-24 *)
rule get_class_attributes(cr,p) => resstr
-----------------------
evaluate_graphical_api(
ISTMTS([IEXP(Absyn.CALL(
Absyn.CREF_IDENT("getClassAttributes",_),
Absyn.FUNCTIONARGS([Absyn.CREF(cr)],_)))],_
),
st as SYMBOLTABLE(p,s,ic,iv,cf)) => (resstr,st)

end

Expand Down Expand Up @@ -6242,18 +6250,77 @@ end
(**relation: get_class_information
** author: PA
**
** Returns the class restriction, class comment and source file of a class.
** Returns all the possible class information.
** changed by adrpo 2006-02-24 to return more info and in a different format:
** {"restriction","name","comment","filename.mo",{bool,bool,bool},{"readonly|writable",int,int,int,int}}
** if you like more named attributes, use getClassAttributes API which uses get_class_attributes relation
**)
relation get_class_information:(Absyn.ComponentRef,
Absyn.Program) => string =

rule Absyn.cref_to_path(cr) => path &
get_pathed_class_in_program(path,p) => Absyn.CLASS(_,_,_,_,restr,cdef,Absyn.INFO(file,_,_,_,_,_)) &
Dump.unparse_restriction_str(restr) => res &
get_class_comment(cdef) => cmt &
Util.string_append_list(["{\"",res,"\", ",cmt,", \"",file,"\"}"]) => res'
----------------------------
get_class_information(cr,p) => res'
get_pathed_class_in_program(path,p) =>
Absyn.CLASS(name,partial,final,encapsulated,restr,cdef,Absyn.INFO(file,isReadOnly,sl,sc,el,ec)) &
(* handling boolean attributes of the class *)
Util.bool_string(partial) => strPartial &
Util.bool_string(final) => strFinal &
Util.bool_string(encapsulated) => strEncapsulated &
(* handling restriction *)
Dump.unparse_restriction_str(restr) => res &
(* handling class comment from the definition *)
get_class_comment(cdef) => cmt &
(* handling positional information *)
select_string(isReadOnly,"readonly","writable") => str_readonly &
int_string(sl) => str_sline &
int_string(sc) => str_scol &
int_string(el) => str_eline &
int_string(ec) => str_ecol &
(* composing the final returned string *)
Util.string_append_list(["{\"",res,"\",\"",name,"\",",cmt,",\"", file,
"\",{", strPartial,",",strFinal,",",strEncapsulated,"},{\"",
str_readonly,"\",",str_sline,",",str_scol,",",str_eline,",",str_ecol,"}}"]) => res'
----------------------------
get_class_information(cr,p) => res'
end


(**relation: get_class_attributes
** author: Adrian Pop, 2006-02-24
**
** Returns all the possible class information in this format:
** { name="Ident", partial=(true|false), final=(true|false),
** encapsulated=(true|false), restriction="PACKAGE|CLASS|..",
** comment="comment", file="filename.mo", readonly="(readonly|writable)",
** startLine=number, startColumn=number,
** endLine=number, endColumn=number }
**)
relation get_class_attributes:(Absyn.ComponentRef, Absyn.Program) => string =

rule Absyn.cref_to_path(cr) => path &
get_pathed_class_in_program(path,p) =>
Absyn.CLASS(name,partial,final,encapsulated,restr,cdef,Absyn.INFO(file,isReadOnly,sl,sc,el,ec)) &
(* handling boolean attributes of the class *)
Util.bool_string(partial) => strPartial &
Util.bool_string(final) => strFinal &
Util.bool_string(encapsulated) => strEncapsulated &
(* handling restriction *)
Absyn.restr_string restr => res &
(* handling class comment from the definition *)
get_class_comment(cdef) => cmt &
(* handling positional information *)
select_string(isReadOnly,"readonly","writable") => str_readonly &
int_string(sl) => str_sline &
int_string(sc) => str_scol &
int_string(el) => str_eline &
int_string(ec) => str_ecol &
(* composing the final returned string *)
Util.string_append_list(["{name=\"",name, "\", partial=",strPartial,", final=",strFinal,
", encapsulated=", strEncapsulated, ", restriction=", res, ", comment=", cmt,
", file=\"", file, "\", readonly=\"", str_readonly,
"\", startLine=", str_sline, ", startColumn=", str_scol,
", endLine=", str_eline, ", endColumn=", str_ecol, "}"]) => res'
----------------------------
get_class_attributes(cr,p) => res'
end

(**relation: get_class_comment
Expand Down
16 changes: 16 additions & 0 deletions Compiler/interactive_api.txt
Expand Up @@ -256,6 +256,22 @@ getElementsInfo(cref) Returns all the elements in a class wi
variability="unspecified"|"discrete"|"parameter"|"constant",
direction="input"|"output"|"unspecified"
now for classes with no parts returns "{ }" instead of "Error"
getClassInformation(cref) returns all known class information using this format:
{"restriction","name","comment","file.mo",
{partial,final,encapsulated},
{"(readonly|writable)",startLine,startColumn,endLine,endColumn}}
with the following type for the components:
{"string","string","string","string",{bool,bool,bool},{"string",int,int,int,int}}
Example: look into testsuite/mosfiles/loadFileInteractiveQualified.mos
{"class","Stuff","Stuff Comment","loadFileInteractiveQualified.mo",{false,false,false},{"writable",10,1,15,10}}


getClassAttributes(cref) returns all known class information using this format:

Example: look into testsuite/mosfiles/loadFileInteractiveQualified.mos
{name="Stuff", partial=false, final=false, encapsulated=false, restriction=CLASS, comment="Stuff Comment",
file="loadFileInteractiveQualified.mo", readonly="writable", startLine=10, startColumn=1, endLine=15, endColumn=10}


getEnvironmentVar("varname") returns the contents of the "varname" environment variable
or error if the variable does not exist
Expand Down

0 comments on commit 0abdf22

Please sign in to comment.