Skip to content
This repository has been archived by the owner on Dec 20, 2018. It is now read-only.

Commit

Permalink
Modify some of the modules' Inspect() value.
Browse files Browse the repository at this point in the history
  • Loading branch information
haifenghuang committed Jan 13, 2018
1 parent e74a434 commit 938d279
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 39 deletions.
10 changes: 3 additions & 7 deletions examples/demo.my
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,9 @@ filepath.walk(".", walkf)
println(filelist)

//filepath.walk(".", fn(path, fileinfo) {
// if (filepath.ext(path) == ".my") {
// if (filepath.base(path) == "db.my") {
// println("============skipping eval.my============")
// return "SKIP_DIR"
// } else {
// println(path)
// }
// if (filepath.dir(path) =="examples") {
// println("============skipping examples dir============")
// return filepath.SKIP_DIR
// }
// else {
// println(path)
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CsvObj struct {
Writer *csv.Writer
}

func (c *CsvObj) Inspect() string { return csv_name }
func (c *CsvObj) Inspect() string { return "<" + csv_name + ">"}
func (c *CsvObj) Type() ObjectType { return CSV_OBJ }

func (c *CsvObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
4 changes: 2 additions & 2 deletions src/monkey/eval/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewIOUtilObj() Object {
return ret
}

func (i *IOUtilObj) Inspect() string { return ioutil_name }
func (i *IOUtilObj) Inspect() string { return "<" + ioutil_name + ">" }
func (i *IOUtilObj) Type() ObjectType { return IOUTIL_OBJ }
func (i *IOUtilObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down Expand Up @@ -185,7 +185,7 @@ type FileObject struct {
}

func (f *FileObject) IOWriter() io.Writer { return f.File }
func (f *FileObject) Inspect() string { return f.Name }
func (f *FileObject) Inspect() string { return "<file object: " + f.Name + ">" }
func (f *FileObject) Type() ObjectType { return FILE_OBJ }
func (f *FileObject) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down
10 changes: 5 additions & 5 deletions src/monkey/eval/filepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ func NewFilePathObj() *FilePathObj {
ret := &FilePathObj{}
SetGlobalObj(filepath_name, ret)

SetGlobalObj(filepath_name+".SKIP_DIR", NewString("SKIP_DIR"))
SetGlobalObj(filepath_name+".SKIP_DIR", NewInteger(SKIP_DIR))
SetGlobalObj(filepath_name+".SEPARATOR", NewString(string(filepath.Separator)))
SetGlobalObj(filepath_name+".LISTSEPARATOR", NewString(string(filepath.ListSeparator)))

return ret
}

const (
SKIP_DIR = 1
FILEPATH_OBJ = "FILEPATH_OBJ"
filepath_name = "filepath"
)

type FilePathObj struct{}

func (f *FilePathObj) Inspect() string { return filepath_name }
func (f *FilePathObj) Inspect() string { return "<" + filepath_name + ">" }
func (f *FilePathObj) Type() ObjectType { return FILEPATH_OBJ }

func (f *FilePathObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down Expand Up @@ -424,10 +425,9 @@ func walkFunc(scope *Scope, f *Function, path string, info os.FileInfo) error {
}

//check for return value, is it a skipDir?
str, ok := r.(*String)
iObj, ok := r.(*Integer)
if ok {
skipDir, _ := GetGlobalObj("SKIP_DIR")
if skipDir.(*String).String == str.String {
if iObj.Int64 == SKIP_DIR {
return filepath.SkipDir
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type FlagObj struct {
arguments map[Object]interface{}
}

func (f *FlagObj) Inspect() string { return flag_name }
func (f *FlagObj) Inspect() string { return "<" + flag_name + ">" }
func (f *FlagObj) Type() ObjectType { return FLAG_OBJ }

func (f *FlagObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
type FmtObj struct {
}

func (f *FmtObj) Inspect() string { return fmt_name }
func (f *FmtObj) Inspect() string { return "<" + fmt_name + ">" }
func (f *FmtObj) Type() ObjectType { return FMT_OBJ }

func (f *FmtObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
14 changes: 7 additions & 7 deletions src/monkey/eval/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func NewHTTPObj() Object {
return ret
}

func (h *HttpObj) Inspect() string { return http_name }
func (h *HttpObj) Inspect() string { return "<" + http_name + ">" }
func (h *HttpObj) Type() ObjectType { return HTTP_OBJ }

func (h *HttpObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down Expand Up @@ -415,7 +415,7 @@ type HttpClient struct {
Client *http.Client
}

func (h *HttpClient) Inspect() string { return "httpclient" }
func (h *HttpClient) Inspect() string { return "<httpclient>" }
func (h *HttpClient) Type() ObjectType { return HTTPCLIENT_OBJ }
func (h *HttpClient) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down Expand Up @@ -544,7 +544,7 @@ type HttpResponse struct {
Response *http.Response
}

func (h *HttpResponse) Inspect() string { return "httpresponse" }
func (h *HttpResponse) Inspect() string { return "<httpresponse>" }
func (h *HttpResponse) Type() ObjectType { return HTTPRESPONSE_OBJ }
func (h *HttpResponse) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down Expand Up @@ -593,7 +593,7 @@ type HttpRequest struct {
Request *http.Request
}

func (h *HttpRequest) Inspect() string { return "httprequest" }
func (h *HttpRequest) Inspect() string { return "<httprequest>" }
func (h *HttpRequest) Type() ObjectType { return HTTPREQUEST_OBJ }
func (h *HttpRequest) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down Expand Up @@ -655,7 +655,7 @@ type HttpResponseWriter struct {
}

func (h *HttpResponseWriter) IOWriter() io.Writer { return h.Writer }
func (h *HttpResponseWriter) Inspect() string { return "http responsewriter" }
func (h *HttpResponseWriter) Inspect() string { return "<httpresponsewriter>" }
func (h *HttpResponseWriter) Type() ObjectType { return HTTPRESPONSEWRITER_OBJ }
func (h *HttpResponseWriter) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down Expand Up @@ -715,7 +715,7 @@ type HttpServer struct {
Server *http.Server
}

func (h *HttpServer) Inspect() string { return "httpserver" }
func (h *HttpServer) Inspect() string { return "<httpserver>" }
func (h *HttpServer) Type() ObjectType { return HTTPSERVER_OBJ }
func (h *HttpServer) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down Expand Up @@ -827,7 +827,7 @@ type HttpHeader struct {
Header http.Header
}

func (h *HttpHeader) Inspect() string { return "httpheader" }
func (h *HttpHeader) Inspect() string { return "<httpheader>" }
func (h *HttpHeader) Type() ObjectType { return HTTPHEADER_OBJ }
func (h *HttpHeader) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewJsonObj() Object {
return ret
}

func (j *Json) Inspect() string { return json_name }
func (j *Json) Inspect() string { return "<" + json_name + ">" }
func (j *Json) Type() ObjectType { return JSON_OBJ }

func (j *Json) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ListObject struct {
List *list.List
}

func (l *ListObject) Inspect() string { return LIST_OBJ }
func (l *ListObject) Inspect() string { return "<list>" }
func (l *ListObject) Type() ObjectType { return LIST_OBJ }
func (l *ListObject) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
switch method {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type LoggerObj struct {
Logger *log.Logger
}

func (l *LoggerObj) Inspect() string { return logger_name }
func (l *LoggerObj) Inspect() string { return "<" + logger_name + ">" }
func (l *LoggerObj) Type() ObjectType { return LOGGER_OBJ }

func (l *LoggerObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewMathObj() Object {
return ret
}

func (m *Math) Inspect() string { return math_name }
func (m *Math) Inspect() string { return "<" + math_name + ">" }
func (m *Math) Type() ObjectType { return MATH_OBJ }

func (m *Math) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewNetObj() Object {
return ret
}

func (n *NetObj) Inspect() string { return net_name }
func (n *NetObj) Inspect() string { return "<" + net_name + ">" }
func (n *NetObj) Type() ObjectType { return NET_OBJ }

func (n *NetObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (e *Enum) GetName(line string, args ...Object) Object {
return NIL
}

func (b *Builtin) Inspect() string { return "builtin function" }
func (b *Builtin) Inspect() string { return "<builtin function>" }
func (b *Builtin) Type() ObjectType { return BUILTIN_OBJ }
func (b *Builtin) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
panic(NewError(line, NOMETHODERROR, method, b.Type()))
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewOsObj() Object {
return ret
}

func (o *Os) Inspect() string { return os_name }
func (o *Os) Inspect() string { return "<" + os_name + ">" }
func (o *Os) Type() ObjectType { return OS_OBJ }

func (o *Os) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewSortObj() Object {

type SortObj struct{}

func (s *SortObj) Inspect() string { return sort_name }
func (s *SortObj) Inspect() string { return "<" + sort_name + ">" }
func (s *SortObj) Type() ObjectType { return SORT_OBJ }

func (s *SortObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
type SqlsObject struct {
}

func (s *SqlsObject) Inspect() string { return sql_name }
func (s *SqlsObject) Inspect() string { return "<" + sql_name + ">" }
func (s *SqlsObject) Type() ObjectType { return SQL_OBJ }
func (s *SqlsObject) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
panic(NewError(line, NOMETHODERROR, method, s.Type()))
Expand Down
10 changes: 5 additions & 5 deletions src/monkey/eval/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type SyncCondObj struct {
Cond *sync.Cond
}

func (c *SyncCondObj) Inspect() string { return SYNCCOND_OBJ }
func (c *SyncCondObj) Inspect() string { return "<" + SYNCCOND_OBJ + ">" }
func (c *SyncCondObj) Type() ObjectType { return SYNCCOND_OBJ }

func (c *SyncCondObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down Expand Up @@ -65,7 +65,7 @@ type SyncOnceObj struct {
Once *sync.Once
}

func (o *SyncOnceObj) Inspect() string { return SYNCONCE_OBJ }
func (o *SyncOnceObj) Inspect() string { return "<" + SYNCONCE_OBJ + ">" }
func (o *SyncOnceObj) Type() ObjectType { return SYNCONCE_OBJ }

func (o *SyncOnceObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down Expand Up @@ -110,7 +110,7 @@ type SyncMutexObj struct {
Mutex *sync.Mutex
}

func (m *SyncMutexObj) Inspect() string { return SYNCMUTEX_OBJ }
func (m *SyncMutexObj) Inspect() string { return "<" + SYNCMUTEX_OBJ + ">" }
func (m *SyncMutexObj) Type() ObjectType { return SYNCMUTEX_OBJ }

func (m *SyncMutexObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down Expand Up @@ -146,7 +146,7 @@ type SyncRWMutexObj struct {
RWMutex *sync.RWMutex
}

func (rwm *SyncRWMutexObj) Inspect() string { return SYNCRWMUTEX_OBJ }
func (rwm *SyncRWMutexObj) Inspect() string { return "<" + SYNCRWMUTEX_OBJ + ">" }
func (rwm *SyncRWMutexObj) Type() ObjectType { return SYNCRWMUTEX_OBJ }

func (rwm *SyncRWMutexObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down Expand Up @@ -204,7 +204,7 @@ type SyncWaitGroupObj struct {
WaitGroup *sync.WaitGroup
}

func (wg *SyncWaitGroupObj) Inspect() string { return SYNCWAITGROUP_OBJ }
func (wg *SyncWaitGroupObj) Inspect() string { return "<" + SYNCWAITGROUP_OBJ + ">" }
func (wg *SyncWaitGroupObj) Type() ObjectType { return SYNCWAITGROUP_OBJ }

func (wg *SyncWaitGroupObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down
2 changes: 1 addition & 1 deletion src/monkey/eval/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewTemplateObj() Object {
return ret
}

func (t *TemplateObj) Inspect() string { return template_name }
func (t *TemplateObj) Inspect() string { return "<" + template_name +">" }
func (t *TemplateObj) Type() ObjectType { return TEMPLATE_OBJ }

func (t *TemplateObj) CallMethod(line string, scope *Scope, method string, args ...Object) Object {
Expand Down

0 comments on commit 938d279

Please sign in to comment.