diff --git a/compiler/macroexpander.stanza b/compiler/macroexpander.stanza index 35abc0391..0e2cde426 100644 --- a/compiler/macroexpander.stanza +++ b/compiler/macroexpander.stanza @@ -76,33 +76,28 @@ public defn StanzaMacroexpander () -> StanzaMacroexpander : ;Main algorithm label return : - ;Find the loaded macro - val lm = find-loaded-macro() - - ;Return the loaded macro if one was found, and - ;it was from a file. - match(lm:LoadedMacros) : - if source(lm) == LoadedFromFile : - return(plugin(lm)) - - ;Check whether the root expander supports it. - if supported-by-root?() : - return(false) - - ;Now check whether a loaded already supports it. - match(lm:LoadedMacros) : - return(plugin(lm)) + ;Find an already loaded macro. + match(find-loaded-macro()) : + (lm:LoadedMacros) : return(plugin(lm)) + (f:False) : false ;Now see whether a plugin can be found via the proj file. match(find-using-proj()) : (p:MacroPlugin) : return(p) (f:False) : false + + ;Check whether the root expander supports it. + if supported-by-root?() : + return(false) ;Failed to find an appropriate support, return an error. compute-error() ;Convenience: Use the names as the overlays. ;Assume that the base is `core. + ;Returns MacroPlugin if the packages are found in a plugin. + ;Returns False if the packages have built-in support. + ;Returns MissingPackages if the packages are not found. defn find-plugin (overlays:Overlays) -> MacroPlugin|False|MissingPackages : if base(overlays) != `core : fatal("Expected base package is core.") diff --git a/compiler/params.stanza b/compiler/params.stanza index 5c6f28f94..329799d33 100644 --- a/compiler/params.stanza +++ b/compiler/params.stanza @@ -18,7 +18,7 @@ public defn compiler-flags () : to-tuple(COMPILE-FLAGS) ;========= Stanza Configuration ======== -public val STANZA-VERSION = [0 17 44] +public val STANZA-VERSION = [0 17 45] public var STANZA-INSTALL-DIR:String = "" public var OUTPUT-PLATFORM:Symbol = `platform public var STANZA-PKG-DIRS:List = List() diff --git a/compiler/proj-utils.stanza b/compiler/proj-utils.stanza index 47a00ce27..46f8f6462 100644 --- a/compiler/proj-utils.stanza +++ b/compiler/proj-utils.stanza @@ -123,12 +123,11 @@ defn main-items (return:ProjItem -> ?, s:ProjStmt) -> ? : (s:ImportWhenStmt) : return(main-item(s)) for d in dependencies(s) do : return(PackageItem(d)) - ;Build statements are never relevant. - (s:BuildStmt) : - false + ;Never relevant + (s:BuildStmt) : false + (s:SyntaxPackagesDefinedInStmt) : false ;All other statements only have one main item. - (s:ProjStmt) : - return(main-item(s)) + (s:ProjStmt) : return(main-item(s)) ;The main-item of a statement is used to match one ;statement against another when comparing isolates. @@ -137,11 +136,11 @@ defn main-item (s:ProjStmt) -> ProjItem : (s:DefinedInStmt) : PackageItem(package(s)) (s:RequiresStmt) : PackageItem(package(s)) (s:ImportWhenStmt) : PackageItem(package(s)) - (s:CompileStmt) : + (s:CompileStmt) : if file?(s) : CCFileItem(name(s) as String) else : CCFlagItem(name(s)) - (s:ForeignPackageParamsStmt) : - PackageManagerItem(package-manager(s)) + (s:ForeignPackageParamsStmt) : PackageManagerItem(package-manager(s)) + (s:PackagesDefinedInStmt) : PackagePrefixItem(packages(s)) ;------------------------------------------------------------ ;-------------------- ProjItem Utility ---------------------- @@ -179,6 +178,13 @@ with: equalable => true hashable => true +;Represents the prefix used by a PackagesDefinedInStmt. +defstruct PackagePrefixItem <: ProjItem : + packages:Symbol|False +with: + equalable => true + hashable => true + ;============================================================ ;==================== Package Tree ========================== ;============================================================ @@ -240,6 +246,7 @@ defn type-tag (s:ProjStmt) -> Int : (s:ImportWhenStmt) : 2 (s:CompileStmt) : 3 (s:ForeignPackageParamsStmt) : 4 + (s:PackagesDefinedInStmt) : 5 ;Return true if two extracted isolates are equal to each other. public defn isomorphic? (a:ProjIsolate, b:ProjIsolate) -> True|False : diff --git a/compiler/repl.stanza b/compiler/repl.stanza index 8da99fabb..c5c90fbac 100644 --- a/compiler/repl.stanza +++ b/compiler/repl.stanza @@ -245,8 +245,6 @@ defn prompter (style:TerminalStyle, prompt:String, continue:String) -> Prompter ;============================================================ public val REPL-INITIAL-SYNTAX-PACKAGES = Vector() public defn register-initial-repl-syntax (name:Symbol) : - if not syntax-package-exists?(name) : - fatal("No syntax package called %_." % [name]) add(REPL-INITIAL-SYNTAX-PACKAGES, name) ;============================================================