implement JScript; include "common.m"; include "ecmascript.m"; ES: Ecmascript; Exec, Obj, Call, Prop, Val, Ref, RefVal, Builtin, ReadOnly: import ES; me: ESHostobj; # local copies from CU sys: Sys; CU: CharonUtils; D: Draw; S: String; T: StringIntTab; C: Ctype; B: Build; Item: import B; CH: Charon; L: Layout; Frame: import L; U: Url; ParsedUrl: import U; E: Events; Event, ScriptEvent: import E; JScript: module { # First, conform to Script interface defaultStatus: string; jevchan: chan of ref ScriptEvent; init: fn(cu: CharonUtils); frametreechanged: fn(top: ref Layout->Frame); havenewdoc: fn(f: ref Layout->Frame); evalscript: fn(f: ref Layout->Frame, s: string, donebuild: int) : (string, string); # # implement the host object interface, too # get: fn(ex: ref Exec, o: ref Obj, property: string): ref Val; put: fn(ex: ref Exec, o: ref Obj, property: string, val: ref Val); canput: fn(ex: ref Exec, o: ref Obj, property: string): ref Val; hasproperty: fn(ex: ref Exec, o: ref Obj, property: string): ref Val; delete: fn(ex: ref Exec, o: ref Obj, property: string); defaultval: fn(ex: ref Exec, o: ref Obj, tyhint: int): ref Val; call: fn(ex: ref Exec, func, this: ref Obj, args: array of ref Val): ref Ref; construct: fn(ex: ref Exec, func: ref Obj, args: array of ref Val): ref Obj; }; # Call init() before calling anything else. # It makes a global object (a Window) for the browser's top level frame, # and also puts a navaigator object in it. The document can't be filled # in until the first document gets loaded. # # This module keeps track of the correspondence between the Script Window # objects and the corresponding Layout Frames, using the ScriptWin adt to # build a tree mirroring the structure. The root of the tree never changes # after first being set (but changing its document essentially resets all of the # other data structures). After charon has built its top-level window, it # should call frametreechanged(top). # # When a frame gets reset or gets some frame children added, call frametreechanged(f), # where f is the changed frame. This module will update its ScriptWin tree as needed. # # Whenever the document in a (Layout) Frame f changes, call havenewdoc(f) # after the frame's doc field is set. This causes this module to initialize the document # object in the corresponding window object. # # From within the build process, call evalscript(containing frame, script) to evaluate # global code fragments as needed. The return value is two strings: a possible error # description, and HTML that is the result of a document.write (so it should be spliced # in at the point where the