use System.Reflection class Module inherits Node is abstract, partial # TODO: Seems that much of Module's guts should be moved down to CobraModule var _fileName as String var _docString as String? cue init(fileName as String, verbosity as int, docString as String) require fileName.length base.init _fileName = fileName _docString = docString # TODO: what's going on with verbosity? get docString from var get fileName from var get isCobraLibrary as bool return _fileName.endsWith('CobraLang.cobra') or _fileName.endsWith('CobraLang.cs') or _ _fileName.endsWith('SystemInterfaces.cobra') or _fileName.endsWith('Cobra.Lang.dll') def addMinFields base.addMinFields .addField('fileName', _fileName) # Would be better named LibModule or similar class AssemblyModule inherits Module is partial """ An assembly module represents a .dll, jarfile or libraryish thing Basically a holder for a filename (location) and a namespace for its contents """ var _topNameSpace as NameSpace var _mustBindInhList = List() cue init(location as String, globalNS as NameSpace) .init(location, 0, globalNS) cue init(location as String, verbosity as int, globalNS as NameSpace) base.init(location, verbosity, '') _topNameSpace = NameSpace(globalNS, '(top namespace for assemblyModule at [location])') def addMustBindInh(what as INameSpaceMember) require .compiler.curModule is this _mustBindInhList.add(what) get topNameSpace from var """ Returns the top namespace for this module. This is an implicit namespace that is not unified (its unified namespace is the global namespace). """ def _bindInh base._bindInh # .topNameSpace.bindInh - It's too expensive to scan all types in a DLL. Do them as needed. (See Box._prepIfNeeded) for item in _mustBindInhList, item.bindInh def _bindInt base._bindInt # .topNameSpace.bindInt - It's too expensive to scan all types in a DLL. Do them as needed. (See Box._prepIfNeeded) class CobraModule inherits Module is partial """ Module for a cobra source File. Holds name, docString and the topLevelNamespace as the root of the parsed AST nodes. Also handles binding by passing bind invocation onto its namespace to action. """ pro isMainWrapper from var = false cue init(fileName as String, verbosity as int, docString as String, globalNS as NameSpace) base.init(fileName, verbosity, docString) _topNameSpace = NameSpace(globalNS, '(top namespace for module [fileName])') get topNameSpace from var as NameSpace """ Returns the top namespace for this module. This is an implicit namespace that is not unified (its unified namespace is the global namespace). """ def addSubFields base.addSubFields .addField('topNameSpace', .topNameSpace) def _bindInh base._bindInh .topNameSpace.bindInh def _bindInt base._bindInt .topNameSpace.bindInt def _computeMatchingBaseMembers base._computeMatchingBaseMembers .topNameSpace.computeMatchingBaseMembers def _bindImp base._bindImp assert .didBindInt .topNameSpace.bindImp class NativeModule inherits Module is abstract """ The abstract base class for so-called "native" modules such as SharpModule. """ cue init(fileName as String, verbosity as int, docString as String) base.init(fileName, verbosity, docString)