From 8cb50d0b85282e47cbdf6f8a88efa827027d7251 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Thu, 16 Nov 2017 15:35:36 -0600 Subject: [PATCH] common/compiler: delete abstraction layer Signed-off-by: VoR0220 --- common/compiler/compiler.go | 36 ------------------------------------ common/compiler/solidity.go | 8 ++++---- 2 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 common/compiler/compiler.go diff --git a/common/compiler/compiler.go b/common/compiler/compiler.go deleted file mode 100644 index 96276ccde0..0000000000 --- a/common/compiler/compiler.go +++ /dev/null @@ -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 -) diff --git a/common/compiler/solidity.go b/common/compiler/solidity.go index d829a92b2e..dc56d187e2 100644 --- a/common/compiler/solidity.go +++ b/common/compiler/solidity.go @@ -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 }