From 718a4272074121ed1adb90626076dcc5e9217b2c Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 1 Dec 2017 19:21:19 -0400 Subject: - Made it so that module annotations can only be set once now. --- new-luxc/source/luxc/lang/module.lux | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'new-luxc/source') 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 - [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)) -- cgit v1.2.3