diff options
author | Eduardo Julian | 2017-12-01 19:21:19 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-12-01 19:21:19 -0400 |
commit | 718a4272074121ed1adb90626076dcc5e9217b2c (patch) | |
tree | 41bb5e76fb3383161b32384afe16af7eaffa240e /new-luxc/source | |
parent | bfffa9678ead15439e4156635dfb9180e6222d32 (diff) |
- Made it so that module annotations can only be set once now.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/module.lux | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/new-luxc/source/luxc/lang/module.lux b/new-luxc/source/luxc/lang/module.lux index 62e20fa9a..58bf94571 100644 --- a/new-luxc/source/luxc/lang/module.lux +++ b/new-luxc/source/luxc/lang/module.lux @@ -19,6 +19,7 @@ (exception: #export Cannot-Define-More-Than-Once) (exception: #export Cannot-Define-In-Unknown-Module) (exception: #export Can-Only-Change-State-Of-Active-Module) +(exception: #export Cannot-Set-Module-Annotations-More-Than-Once) (def: (new-module hash) (-> Nat Module) @@ -28,18 +29,27 @@ #.imports (list) #.tags (list) #.types (list) - #.module-annotations (' {}) + #.module-annotations #.None #.module-state #.Active}) (def: #export (set-annotations annotations) (-> Code (Meta Unit)) (do macro.Monad<Meta> - [self macro.current-module-name] - (function [compiler] - (#e.Success [(update@ #.modules - (&.pl-update self (set@ #.module-annotations annotations)) - compiler) - []])))) + [self-name macro.current-module-name + self macro.current-module] + (case (get@ #.module-annotations self) + #.None + (function [compiler] + (#e.Success [(update@ #.modules + (&.pl-put self-name (set@ #.module-annotations (#.Some annotations) self)) + compiler) + []])) + + (#.Some old) + (macro.fail (Cannot-Set-Module-Annotations-More-Than-Once + (format " Module: " self-name "\n" + "Old annotations: " (%code old) "\n" + "New annotations: " (%code annotations) "\n")))))) (def: #export (import module) (-> Text (Meta Unit)) |