mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
common/compiler: delete abstraction layer
Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
parent
a036cb9c64
commit
8cb50d0b85
2 changed files with 4 additions and 40 deletions
|
|
@ -1,36 +0,0 @@
|
|||
package compiler
|
||||
|
||||
// An interface to denote a version specific compiler.
|
||||
// The function version() is instantiated upon the creation of the compiler to
|
||||
// fill the compiler's struct with version details. It fails if there is an error in the parsing.
|
||||
type Compiler interface {
|
||||
Compile(flags FlagOpts, files ...string) (Return, error)
|
||||
version() error
|
||||
}
|
||||
|
||||
// This struct via embedding gives us access to all types of returns.
|
||||
// This is written to be extendable to other compilers.
|
||||
type Return struct {
|
||||
Typ CompilerType
|
||||
SolcReturn
|
||||
//Enter your return struct here...e.g.
|
||||
//SerpentReturn
|
||||
//BambooReturn
|
||||
//ViperReturn
|
||||
}
|
||||
|
||||
// This struct allows us to easily create a simple interface for
|
||||
// interacting with our potentially various compilers.
|
||||
type FlagOpts struct {
|
||||
SolcFlagOpts
|
||||
//Enter your FlagOpts struct here...
|
||||
}
|
||||
|
||||
type CompilerType byte
|
||||
|
||||
const (
|
||||
Solc CompilerType = iota
|
||||
// Serpent
|
||||
// Bamboo
|
||||
// Viper
|
||||
)
|
||||
|
|
@ -34,7 +34,7 @@ import (
|
|||
var versionRegexp = regexp.MustCompile(`([0-9]+)\.([0-9]+)\.([0-9]+)`)
|
||||
|
||||
// Initialize a versioned Solc compiler.
|
||||
func InitSolc(command string) (Compiler, error) {
|
||||
func InitSolc(command string) (*Solidity, error) {
|
||||
if command == "" {
|
||||
command = "solc"
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ func (s *Solidity) version() error {
|
|||
}
|
||||
|
||||
// Compiles a series of files using the solidity compiler
|
||||
func (s *Solidity) Compile(flags FlagOpts, files ...string) (Return, error) {
|
||||
func (s *Solidity) Compile(flags SolcFlagOpts, files ...string) (Return, error) {
|
||||
|
||||
if reflect.DeepEqual(flags.SolcFlagOpts, (SolcFlagOpts{})) {
|
||||
flags.defaultSolcFlagOpts(s)
|
||||
|
|
@ -204,7 +204,7 @@ func (f *SolcFlagOpts) defaultSolcFlagOpts(s *Solidity) {
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Solidity) execute(flagsAndFiles ...string) (Return, error) {
|
||||
func (s *Solidity) execute(flagsAndFiles ...string) (SolcReturn, error) {
|
||||
var stderr, stdout bytes.Buffer
|
||||
var output SolcReturn
|
||||
|
||||
|
|
@ -224,5 +224,5 @@ func (s *Solidity) execute(flagsAndFiles ...string) (Return, error) {
|
|||
|
||||
output.Warning = string(stderr.Bytes())
|
||||
|
||||
return Return{Solc, output}, nil
|
||||
return output, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue