Skip to content

Commit

Permalink
solve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin8105 committed Oct 30, 2017
1 parent ddc65f8 commit 0aa4566
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 37 deletions.
21 changes: 0 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,11 @@ func Start(args ProgramArgs) (err error) {
}

// 1. Compile it first (checking for errors)
//<<<<<<< multiplyFiles
for _, in := range args.inputFiles {
_, err := os.Stat(in)
if err != nil {
return fmt.Errorf("Input file %s is not found", in)
}
//=======
_, err = os.Stat(args.inputFile)
if err != nil {
return fmt.Errorf("Input file is not found")
//>>>>>>> master
}

// 2. Preprocess
Expand Down Expand Up @@ -252,18 +246,6 @@ func Start(args ProgramArgs) (err error) {
p.AddMessage(p.GenerateWarningMessage(errors.New(message), fErr.Node))
}

//<<<<<<< multiplyFiles
//=======
// transpile ast tree
if args.verbose {
fmt.Println("Transpiling tree...")
}
err = transpiler.TranspileAST(args.inputFile, args.packageName, p, tree[0].(ast.Node))
if err != nil {
return fmt.Errorf("cannot transpile AST : %v", err)
}

//>>>>>>> master
outputFilePath := args.outputFile

if outputFilePath == "" {
Expand All @@ -274,7 +256,6 @@ func Start(args ProgramArgs) (err error) {
outputFilePath = cleanFileName[0:len(cleanFileName)-len(extension)] + ".go"
}

//<<<<<<< multiplyFiles
// transpile ast tree
if args.verbose {
fmt.Println("Transpiling tree...")
Expand All @@ -285,8 +266,6 @@ func Start(args ProgramArgs) (err error) {
return fmt.Errorf("cannot transpile AST : %v", err)
}

//=======
//>>>>>>> master
// write the output Go code
if args.verbose {
fmt.Println("Writing the output Go code...")
Expand Down
13 changes: 1 addition & 12 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ func TestIntegrationScripts(t *testing.T) {
mainFileName = "main_test.go"

programArgs := DefaultProgramArgs()
//<<<<<<< multiplyFiles
programArgs.inputFiles = []string{file}
//=======
programArgs.inputFile = file
//>>>>>>> master
programArgs.outputFile = subFolder + mainFileName
// This appends a TestApp function to the output source so we
// can run "go test" against the produced binary.
Expand Down Expand Up @@ -268,21 +264,13 @@ func TestStartPreprocess(t *testing.T) {
}
defer os.RemoveAll(dir) // clean up

//<<<<<<< multiplyFiles
name := "preprocess.c"
filename := path.Join(dir, name)
//=======
filename := path.Join(dir, "preprocess.c")
//>>>>>>> master
body := ([]byte)("#include <AbsoluteWrongInclude.h>\nint main(void){\nwrong();\n}")
err = ioutil.WriteFile(filename, body, 0644)

args := DefaultProgramArgs()
//<<<<<<< multiplyFiles
args.inputFiles = []string{dir + name}
//=======
args.inputFile = filename
//>>>>>>> master

err = Start(args)
if err == nil {
Expand Down Expand Up @@ -330,6 +318,7 @@ func TestMultifileTranspilation(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir) // clean up
args.outputFile = path.Join(dir, "multi.go")
args.packageName = "main"
args.outputAsTest = true
Expand Down
5 changes: 3 additions & 2 deletions tests/multi/four.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include<stdio.h>

#ifdef USE_STDIO
#include <stdio.h>
#endif
void say_four(){
printf("4");
}
3 changes: 3 additions & 0 deletions tests/multi/head.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#ifdef USE_STDIO
#include <stdio.h>
#endif
void say_four();
void say_two();
1 change: 1 addition & 0 deletions tests/multi/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include"head.h"

int main(){
say_four();
say_two();
Expand Down
5 changes: 3 additions & 2 deletions tests/multi/two.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include<stdio.h>

#ifdef USE_STDIO
#include <stdio.h>
#endif
void say_two(){
printf("2");
}
1 change: 1 addition & 0 deletions transpiler/transpiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TranspileAST(fileName, packageName string, p *program.Program, root ast.Nod
if p.OutputAsTest {
p.AddImport("testing")
p.AddImport("io/ioutil")
p.AddImport("os")

// TODO: There should be a cleaner way to add a function to the program.
// This code was taken from the end of transpileFunctionDecl.
Expand Down

0 comments on commit 0aa4566

Please sign in to comment.