From 029a3c11b44435ca5bfef4e4e5dbb486aafa414c Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sat, 19 Jan 2019 20:28:32 -0800 Subject: [PATCH 1/5] 1. remove some stdmod functions for the latest Go version 2. add .travis.yml --- .travis.yml | 10 +++ compiler/stdlib/math.go | 132 +++++++++++++++++++--------------------- compiler/stdlib/os.go | 19 ------ 3 files changed, 74 insertions(+), 87 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..aff036e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: go + +go: + - 1.9 + +install: + - make dep + +script: + - make test diff --git a/compiler/stdlib/math.go b/compiler/stdlib/math.go index a5b2182..c92dce2 100644 --- a/compiler/stdlib/math.go +++ b/compiler/stdlib/math.go @@ -7,74 +7,70 @@ import ( ) var mathModule = map[string]objects.Object{ - "e": &objects.Float{Value: math.E}, - "pi": &objects.Float{Value: math.Pi}, - "phi": &objects.Float{Value: math.Phi}, - "sqrt2": &objects.Float{Value: math.Sqrt2}, - "sqrtE": &objects.Float{Value: math.SqrtE}, - "sqrtPi": &objects.Float{Value: math.SqrtPi}, - "sqrtPhi": &objects.Float{Value: math.SqrtPhi}, - "ln2": &objects.Float{Value: math.Ln2}, - "log2E": &objects.Float{Value: math.Log2E}, - "ln10": &objects.Float{Value: math.Ln10}, - "log10E": &objects.Float{Value: math.Log10E}, - "abs": FuncAFRF(math.Abs), - "acos": FuncAFRF(math.Acos), - "acosh": FuncAFRF(math.Acosh), - "asin": FuncAFRF(math.Asin), - "asinh": FuncAFRF(math.Asinh), - "atan": FuncAFRF(math.Atan), - "atan2": FuncAFFRF(math.Atan2), - "atanh": FuncAFRF(math.Atanh), - "cbrt": FuncAFRF(math.Cbrt), - "ceil": FuncAFRF(math.Ceil), - "copysign": FuncAFFRF(math.Copysign), - "cos": FuncAFRF(math.Cos), - "cosh": FuncAFRF(math.Cosh), - "dim": FuncAFFRF(math.Dim), - "erf": FuncAFRF(math.Erf), - "erfc": FuncAFRF(math.Erfc), - "erfcinv": FuncAFRF(math.Erfcinv), - "erfinv": FuncAFRF(math.Erfinv), - "exp": FuncAFRF(math.Exp), - "exp2": FuncAFRF(math.Exp2), - "expm1": FuncAFRF(math.Expm1), - "floor": FuncAFRF(math.Floor), - "gamma": FuncAFRF(math.Gamma), - "hypot": FuncAFFRF(math.Hypot), - "ilogb": FuncAFRI(math.Ilogb), - "inf": FuncAIRF(math.Inf), - "is_inf": FuncAFIRB(math.IsInf), - "is_nan": FuncAFRB(math.IsNaN), - "j0": FuncAFRF(math.J0), - "j1": FuncAFRF(math.J1), - "jn": FuncAIFRF(math.Jn), - "ldexp": FuncAFIRF(math.Ldexp), - "log": FuncAFRF(math.Log), - "log10": FuncAFRF(math.Log10), - "log1p": FuncAFRF(math.Log1p), - "log2": FuncAFRF(math.Log2), - "logb": FuncAFRF(math.Logb), - "max": FuncAFFRF(math.Max), - "min": FuncAFFRF(math.Min), - "mod": FuncAFFRF(math.Mod), - "nan": FuncARF(math.NaN), - "nextafter": FuncAFFRF(math.Nextafter), - "pow": FuncAFFRF(math.Pow), - "pow10": FuncAIRF(math.Pow10), - "remainder": FuncAFFRF(math.Remainder), - "round": FuncAFRF(math.Round), - "round_to_even": FuncAFRF(math.RoundToEven), - "signbit": FuncAFRB(math.Signbit), - "sin": FuncAFRF(math.Sin), - "sinh": FuncAFRF(math.Sinh), - "sqrt": FuncAFRF(math.Sqrt), - "tan": FuncAFRF(math.Tan), - "tanh": FuncAFRF(math.Tanh), - "runct": FuncAFRF(math.Trunc), - "y0": FuncAFRF(math.Y0), - "y1": FuncAFRF(math.Y1), - "yn": FuncAIFRF(math.Yn), + "e": &objects.Float{Value: math.E}, + "pi": &objects.Float{Value: math.Pi}, + "phi": &objects.Float{Value: math.Phi}, + "sqrt2": &objects.Float{Value: math.Sqrt2}, + "sqrtE": &objects.Float{Value: math.SqrtE}, + "sqrtPi": &objects.Float{Value: math.SqrtPi}, + "sqrtPhi": &objects.Float{Value: math.SqrtPhi}, + "ln2": &objects.Float{Value: math.Ln2}, + "log2E": &objects.Float{Value: math.Log2E}, + "ln10": &objects.Float{Value: math.Ln10}, + "log10E": &objects.Float{Value: math.Log10E}, + "abs": FuncAFRF(math.Abs), + "acos": FuncAFRF(math.Acos), + "acosh": FuncAFRF(math.Acosh), + "asin": FuncAFRF(math.Asin), + "asinh": FuncAFRF(math.Asinh), + "atan": FuncAFRF(math.Atan), + "atan2": FuncAFFRF(math.Atan2), + "atanh": FuncAFRF(math.Atanh), + "cbrt": FuncAFRF(math.Cbrt), + "ceil": FuncAFRF(math.Ceil), + "copysign": FuncAFFRF(math.Copysign), + "cos": FuncAFRF(math.Cos), + "cosh": FuncAFRF(math.Cosh), + "dim": FuncAFFRF(math.Dim), + "erf": FuncAFRF(math.Erf), + "erfc": FuncAFRF(math.Erfc), + "exp": FuncAFRF(math.Exp), + "exp2": FuncAFRF(math.Exp2), + "expm1": FuncAFRF(math.Expm1), + "floor": FuncAFRF(math.Floor), + "gamma": FuncAFRF(math.Gamma), + "hypot": FuncAFFRF(math.Hypot), + "ilogb": FuncAFRI(math.Ilogb), + "inf": FuncAIRF(math.Inf), + "is_inf": FuncAFIRB(math.IsInf), + "is_nan": FuncAFRB(math.IsNaN), + "j0": FuncAFRF(math.J0), + "j1": FuncAFRF(math.J1), + "jn": FuncAIFRF(math.Jn), + "ldexp": FuncAFIRF(math.Ldexp), + "log": FuncAFRF(math.Log), + "log10": FuncAFRF(math.Log10), + "log1p": FuncAFRF(math.Log1p), + "log2": FuncAFRF(math.Log2), + "logb": FuncAFRF(math.Logb), + "max": FuncAFFRF(math.Max), + "min": FuncAFFRF(math.Min), + "mod": FuncAFFRF(math.Mod), + "nan": FuncARF(math.NaN), + "nextafter": FuncAFFRF(math.Nextafter), + "pow": FuncAFFRF(math.Pow), + "pow10": FuncAIRF(math.Pow10), + "remainder": FuncAFFRF(math.Remainder), + "signbit": FuncAFRB(math.Signbit), + "sin": FuncAFRF(math.Sin), + "sinh": FuncAFRF(math.Sinh), + "sqrt": FuncAFRF(math.Sqrt), + "tan": FuncAFRF(math.Tan), + "tanh": FuncAFRF(math.Tanh), + "runct": FuncAFRF(math.Trunc), + "y0": FuncAFRF(math.Y0), + "y1": FuncAFRF(math.Y1), + "yn": FuncAIFRF(math.Yn), // TODO: functions that have multiple returns // Should these be tuple assignment? Or Map return? //"frexp": nil, diff --git a/compiler/stdlib/os.go b/compiler/stdlib/os.go index 660594d..d2e75de 100644 --- a/compiler/stdlib/os.go +++ b/compiler/stdlib/os.go @@ -48,8 +48,6 @@ var osModule = map[string]objects.Object{ "clearenv": FuncAR(os.Clearenv), // environ() => array(string) "environ": FuncARSs(os.Environ), - // executable() => string/error - "executable": &objects.UserFunction{Value: osExecutable}, // exit(code int) "exit": FuncAIR(os.Exit), // expand_env(s string) => string @@ -104,8 +102,6 @@ var osModule = map[string]objects.Object{ "truncate": FuncASI64RE(os.Truncate), // unsetenv(key string) => error "unsetenv": FuncASRE(os.Unsetenv), - // user_cache_dir() => string/error - "user_cache_dir": FuncARSE(os.UserCacheDir), // create(name string) => imap(file)/error "create": &objects.UserFunction{Value: osCreate}, // open(name string) => imap(file)/error @@ -116,21 +112,6 @@ var osModule = map[string]objects.Object{ "find_process": &objects.UserFunction{Value: osFindProcess}, // start_process(name string, argv array(string), dir string, env array(string)) => imap(process)/error "start_process": &objects.UserFunction{Value: osStartProcess}, - - // TODO: implemented more functions - //"stdin": nil, - //"stdout": nil, - //"stderr": nil, - //"chtimes": nil, - //"expand": nil, - //"is_exists": nil, - //"is_not_exist": nil, - //"is_path_separator": nil, - //"is_permission": nil, - //"is_timeout": nil, - //"new_syscall_error": nil, - //"pipe": nil, - //"same_file": nil, } func osArgs(args ...objects.Object) (objects.Object, error) { From e909415c7cf1ab621ca1245b2f3dcae12103a609 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sat, 19 Jan 2019 20:30:38 -0800 Subject: [PATCH 2/5] fix travis setup --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index aff036e..7f1678e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,5 @@ language: go go: - 1.9 -install: - - make dep - script: - make test From ff725f3609bbf037b50d18904e4ecf5778442a03 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sat, 19 Jan 2019 20:34:52 -0800 Subject: [PATCH 3/5] install golint in travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7f1678e..295caf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,8 @@ language: go go: - 1.9 +install: + - go get -u golang.org/x/lint/golint + script: - make test From 81fdf10f8cfe8970c5f345d5a9a3c3fc66949457 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sat, 19 Jan 2019 20:38:01 -0800 Subject: [PATCH 4/5] remove 'mode_irregular' from 'os' module --- compiler/stdlib/os.go | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/stdlib/os.go b/compiler/stdlib/os.go index d2e75de..826d582 100644 --- a/compiler/stdlib/os.go +++ b/compiler/stdlib/os.go @@ -27,7 +27,6 @@ var osModule = map[string]objects.Object{ "mode_setgui": &objects.Int{Value: int64(os.ModeSetgid)}, "mode_char_device": &objects.Int{Value: int64(os.ModeCharDevice)}, "mode_sticky": &objects.Int{Value: int64(os.ModeSticky)}, - "mode_irregular": &objects.Int{Value: int64(os.ModeIrregular)}, "mode_type": &objects.Int{Value: int64(os.ModeType)}, "mode_perm": &objects.Int{Value: int64(os.ModePerm)}, "path_separator": &objects.Char{Value: os.PathSeparator}, From 57700aceb146c2e33a74e880be035d1e00be3230 Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Sat, 19 Jan 2019 20:46:32 -0800 Subject: [PATCH 5/5] add build status to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 53e1f7c..02bbcd9 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![GoDoc](https://godoc.org/github.com/d5/tengo?status.svg)](https://godoc.org/github.com/d5/tengo/script) [![Go Report Card](https://goreportcard.com/badge/github.com/d5/tengo)](https://goreportcard.com/report/github.com/d5/tengo) +[![Build Status](https://travis-ci.org/d5/tengo.svg?branch=master)](https://travis-ci.org/d5/tengo) Tengo is an embeddable script language for Go.