Skip to content

Commit

Permalink
Fixed two bugs with encapsulated. Removed old cache implementation. M…
Browse files Browse the repository at this point in the history
…ade new external cacheimpl, not working yet (gc problems)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@993 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Jul 2, 2003
1 parent 2e45a82 commit aa64674
Show file tree
Hide file tree
Showing 10 changed files with 820 additions and 554 deletions.
3 changes: 1 addition & 2 deletions modeq/Makefile.in
Expand Up @@ -24,12 +24,11 @@ LDFLAGS = -L$(RMLHOME)/lib/plain $(ANTLR_LIBP) -lrml -lm -lantlr $(LIBSOCKET)

PROG = modeq
AST = absyn_builder/absyn_builder.a
RTOBJ = runtime/systemimpl.o ../c_runtime/libc_runtime.a runtime/rtopts.o runtime/socketimpl.o runtime/printimpl.o
RTOBJ = runtime/systemimpl.o ../c_runtime/libc_runtime.a runtime/rtopts.o runtime/socketimpl.o runtime/printimpl.o runtime/cacheimpl.o

SRCRML= absyn.rml \
algorithm.rml \
builtin.rml \
cache.rml \
classinf.rml \
classloader.rml \
codegen.rml \
Expand Down
11 changes: 11 additions & 0 deletions modeq/absyn.rml
Expand Up @@ -326,6 +326,7 @@ module Absyn:
relation cref_to_path : ComponentRef => Path
relation path_to_cref : Path => ComponentRef
relation path_string : Path => string
relation opt_path_string: Path option => string
relation path_string2 : (Path, string) => string
relation path_last_ident : Path => Ident
relation get_cref_from_exp : ( Exp ) => ComponentRef list
Expand Down Expand Up @@ -376,6 +377,16 @@ relation path_string: Path => string =
path_string path => s
end

relation opt_path_string: Path option => string =

axiom opt_path_string(NONE) => ""

rule path_string(p) => str
-----------------
opt_path_string(SOME(p)) => str
end


relation path_string2: (Path, string) => string =

axiom path_string2(IDENT(s),_) => s
Expand Down
43 changes: 12 additions & 31 deletions modeq/cache.rml
Expand Up @@ -44,51 +44,32 @@ module Cache:

type Ident = string

datatype Cache = CACHE of PathItem list * EnvItem list

(** A cache consists of a list of PathItems, for lookup of classes from inside other
** classes and an EnvItem list, for lookup of classnames from the top scope.
(** A cache has a handle, the rest is implemented in C++
**)

datatype PathItem = PATHITEM of Ident *
PathItem list *
EnvItem list

(** The PathItem datatype corresponds to one level in the absolute path where lookup is performed
** from. I.e. a node in the list of partially instanitated partents of a class
**)

datatype EnvItem = ENVITEM of Ident * (* The class/type/variable name *)
Env.Item option * (* The cached item, if present *)
EnvItem list (* A list of subclasses *)
(** The EnvItem datatype holds the actual cached items. Togehter with the PathItem datatype it
** forms a two-level tree, where the first level is built up from nodes of PathItem types, and
** the second level is built from nodes of type EnvItem. Lookup in the cache then become a simple
** traversal of the tree. An alternative implementation to this would be to use a hash-table, but
** this data structure is not available in RML.
**)

relation add_class : (Cache, SCode.Class, Env.Env, Absyn.Path option, Absyn.Path) => Cache
relation add_class : (SCode.Class, Env.Env, string, string) => ()

relation add_variable: (Cache,Types.Var, Absyn.Path option, Absyn.Path) => Cache
relation add_variable: (Types.Var, string, string) => ()

relation add_type: (Cache, Types.Type, Absyn.Path option, Absyn.Path) => Cache
relation add_type: (Types.Type, string, string) => ()

relation get_class: (Cache, Absyn.Path option, Absyn.Path) => (SCode.Class, Env.Env)
relation get_class: (string, string) => (SCode.Class, Env.Env)

relation get_variable: (Cache, Absyn.Path option, Absyn.Path) => Types.Var
relation get_variable: (string, string) => Types.Var

relation get_type: (Cache, Absyn.Path option, Absyn.Path) => Types.Type
relation get_type: (string, string) => Types.Type

relation print_cache: (Cache) => ()
relation init_cache: () => ()

val empty_cache : Cache
relation clear_cache: () => ()

end
relation print_cache: () => ()

end

with "dump.rml"
val empty_cache = CACHE([],[])



(** - Relations *)
Expand Down

0 comments on commit aa64674

Please sign in to comment.