Skip to content

Commit

Permalink
Merge branch 'macrofixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
CuppoJava committed Dec 6, 2022
2 parents 642e9c7 + 0c7ff24 commit ac1a17b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
27 changes: 11 additions & 16 deletions compiler/macroexpander.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -76,33 +76,28 @@ public defn StanzaMacroexpander () -> StanzaMacroexpander :
;Main algorithm
label<MacroPlugin|False|MissingPackages> 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.")
Expand Down
2 changes: 1 addition & 1 deletion compiler/params.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = List()
Expand Down
23 changes: 15 additions & 8 deletions compiler/proj-utils.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 ----------------------
Expand Down Expand Up @@ -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 ==========================
;============================================================
Expand Down Expand Up @@ -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 :
Expand Down
2 changes: 0 additions & 2 deletions compiler/repl.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ defn prompter (style:TerminalStyle, prompt:String, continue:String) -> Prompter
;============================================================
public val REPL-INITIAL-SYNTAX-PACKAGES = Vector<Symbol>()
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)

;============================================================
Expand Down

0 comments on commit ac1a17b

Please sign in to comment.