DIRECTORY BcdDefs USING [VersionStamp], Rope USING [ROPE], SafeStorage USING [Type], WorldVM USING [World]; AMModel: DEFINITIONS = { OPEN BcdDefs, Rope, SafeStorage, WorldVM; Class: TYPE = {world, model, prog, interface, proc, statement}; -- objects of concern herein Source: TYPE = REF SourceObj; -- range in a source file SourceObj: TYPE = RECORD[ fileName: ROPE _ NIL, -- without path, e.g. foo.mesa class: Class, versionStamp: VersionStamp, sourceRange: SELECT tag: * FROM entire => [], field => [firstCharIndex: CharIndex _ 0, lastCharIndex: CharIndex _ 0] ENDCASE ]; CharIndex: TYPE = INT; -- into a source file. The first char has index = 0. IRIndex: TYPE = INT; -- into an interface instance. Section: TYPE = REF SectionObj; SectionObj: TYPE; -- opaque Context: TYPE = REF ANY; -- Context should be opaque, but convenient this way for now PartialInterfaceInstance: TYPE = RECORD[ir: --interface--Context, usingList: LIST OF IRIndex]; RootContext: PROC [world: World _ NIL] RETURNS [Context]; FileSource: PROC [fileName: ROPE, class: --model, prog, interface--Class] RETURNS [Source]; SourceFileName: PROC [source: Source] RETURNS [ROPE] = INLINE { RETURN[source.fileName]}; SourceClass: PROC [source: Source] RETURNS [Class] = INLINE { RETURN[source.class]}; SourceVersion: PROC [source: Source] RETURNS [VersionStamp] = INLINE { RETURN[source.versionStamp]}; SourceSection: PROC [source: Source, context: --worldRoot or model--Context] RETURNS [section: Section, contexts: LIST OF --prog--Context]; SectionClass: PROC [section: Section] RETURNS [Class]; SectionName: PROC [section: Section] RETURNS [ROPE]; SectionType: PROC [section: Section] RETURNS [--procedure--Type]; SectionVersion: PROC [section: Section] RETURNS [VersionStamp]; SectionSource: PROC [section: Section] RETURNS [Source]; SectionParams: PROC [section: Section] RETURNS [LIST OF --interface-- Type]; SectionChildren: PROC [section: Section, proc: PROC [Section] RETURNS [stop: BOOL]] RETURNS [ans: Section _ NIL--NIL if not stopped--]; ParentSection: PROC [section: Section] RETURNS [Section]; ContextClass: PROC [context: Context] RETURNS [Class]; ContextWorld: PROC [context: Context] RETURNS [World]; ContextName: PROC [context: Context] RETURNS [ROPE]; MostRecentNamedContext: PROC [name: ROPE, context: --world or model--Context] RETURNS [Context]; NamedContexts: PROC [name: ROPE, context: --worldRoot or model--Context, proc: PROC [Context] RETURNS [stop: BOOL]] RETURNS [Context--NIL if not stopped--]; ContextSection: PROC [context: Context] RETURNS [Section]; ParentContext: PROC [context: Context] RETURNS [Context]; ContextChildren: PROC [context: Context, proc: PROC [Context] RETURNS [stop: BOOL]] RETURNS [Context--NIL if not stopped--]; InterfaceRecords: PROC [world: Context] RETURNS [LIST OF --interface--Context]; Imports: PROC [context: Context] RETURNS [LIST OF PartialInterfaceInstance]; Exports: PROC [context: Context] RETURNS [LIST OF PartialInterfaceInstance]; }. HAMModel.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Rovner, July 6, 1983 6:44 pm Russ Atkinson (RRA) February 11, 1985 11:49:14 pm PST HOLES: nested procedures. nested configs. multiple sections of the same source. TYPEs lastCharIndex < firstCharIndex means empty range The first item has index = 1 (AMTypes convention). A Section represents one of: binder output bundle for a config [class = model] (someday modeller output bundle for a model) compiler output bundle for a prog module [class = prog] compiler output bundle for a DEFs module [class = interface] compiler output bundle for a proc [class = proc] compiler output bundle for a statement [class = statement] A Context represents one of: world [class = world] loadstate entry [class = model] global frame [class = prog] interface record [class = interface] local frame [class = proc] local frame and PC [class = statement] PROCs ... a "rootContext" represents a "loadstate" model of an entire running Cedar world (world = NIL => use WorldVM.LocalWorld[]). Immediate children are its top-level Contexts: loadstate entries for individually loaded program modules and bound configs (someday models). Truth: ContextClass[RootContext] = world. ... dealing with Source Use SourceSection to figure out (given a proc or statement source location) where to place a breakpoint (and in which world). The list of prog Contexts returned by SourceSection is meaningful for prog, proc and statement sources. It will be ordered "most-recently-loaded first". Strictly speaking, a source can have multiple sections: one for each set of "SectionParams". Someday we'll accommodate this, but not this week. ... dealing with Sections e.g. config name, prog or interface module name, proc name; for statements: procName. Implemented only for proc sections param to creator of section. ditto (e.g. DIRECTORY entries) Will be implemented only for model, prog and interface sections. an enumerator. children: modules of a model, procs of a module, statements of a proc container: prog module for a proc proc for a statement ... dealing with Contexts Entry to this stuff: a tv for a global frame (TypeClass = globalFrame) has class = prog a tv for a local frame (TypeClass = localFrame) has class = proc world => worldName model => :ConfigIndex# prog => :gfh# interface => proc => :fh# statement => :FGT# EXAMPLE USAGE: given a module name and a world context, this returns a Context for the most recently loaded global frame for a program with that name. name must identify a model or prog (someday interface) if context identifies a world, or a prog (someday interface) if context identifies a model. The format of the name should be the same as that produced by ContextName, with elided fields meaning "don't care". The result will be either a model or prog (someday interface) context. an enumerator. Like MostRecentNamedContext, but gets 'em all. param to creator of context world => NIL model => world prog => model proc => prog statement => proc an enumerator world -> models or progs (TVs for global frames), model -> progs, proc -> statement (proc will be called only once) ... dealing with interfaces Implemented only for model and prog contexts Implemented only for model and prog contexts Κ€˜codešœ ™ Kšœ Οmœ1™