This is the first change of many to merge the MuPack/MuIL formats into the heart of the "compiler". In fact, the entire meaning of the compiler has changed, from something that took metadata and produced CloudFormation, into something that takes MuPack/MuIL as input, and produces a MuGL graph as output. Although this process is distinctly different, there are several aspects we can reuse, like workspace management, dependency resolution, and some amount of name binding and symbol resolution, just as a few examples. An overview of the compilation process is available as a comment inside of the compiler.Compile function, although it is currently unimplemented. The relationship between Workspace and Compiler has been semi- inverted, such that all Compiler instances require a Workspace object. This is more natural anyway and moves some of the detection logic "outside" of the Compiler. Similarly, Options has moved to a top-level package, so that Workspace and Compiler may share access to it without causing package import cycles. Finally, all that templating crap is gone. This alone is cause for mass celebration!
23 lines
645 B
Go
23 lines
645 B
Go
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
package contract
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const requireMsg = "A precondition has failed for %v"
|
|
|
|
// Require checks a precondition condition pertaining to a function parameter, and Fails if it is false.
|
|
func Require(cond bool, param string) {
|
|
if !cond {
|
|
failfast(fmt.Sprintf(requireMsg, param))
|
|
}
|
|
}
|
|
|
|
// Requiref checks a precondition condition pertaining to a function parameter, and Failfs if it is false.
|
|
func Requiref(cond bool, param string, msg string, args ...interface{}) {
|
|
if !cond {
|
|
failfast(fmt.Sprintf("%v: %v", fmt.Sprintf(requireMsg, param), fmt.Sprintf(msg, args...)))
|
|
}
|
|
}
|