Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
grumpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
grumpy
Commits
c39ad6ca
Commit
c39ad6ca
authored
Dec 29, 2016
by
Dylan Trotter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add make lint command. Make Go code golint clean.
parent
4aa5110d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
Makefile
Makefile
+7
-1
runtime/code.go
runtime/code.go
+8
-1
No files found.
Makefile
View file @
c39ad6ca
...
...
@@ -81,7 +81,7 @@ watch:
-
@
$(MAKE)
test
@
while
inotifywait
-q
-e
modify
--exclude
'^\./(build|\.git)/'
--recursive
.
;
do
sleep
0.2
;
$(MAKE)
test
;
done
.PHONY
:
all benchmarks clean cover run test watch
.PHONY
:
all benchmarks clean cover
lint
run test watch
# ------------------------------------------------------------------------------
# grumpc compiler
...
...
@@ -140,6 +140,12 @@ $(RUNTIME_COVER_FILE): $(RUNTIME) $(filter %_test.go,$(RUNTIME_SRCS))
cover
:
$(RUNTIME_COVER_FILE) $(TOOL_BINS)
@
bash
-c
'comm -12 <(coverparse $< | sed "s/^grumpy/runtime/" | sort) <(git diff --dst-prefix=
$(DIFF_COMMIT)
| diffrange | sort)'
|
sort
-t
':'
-k1
,1
-k2n
,2 |
sed
's/$$/: missing coverage/'
|
tee
errors.err
build/bin/golint
:
@
go get
-u
github.com/golang/lint/golint
lint
:
build/bin/golint
@
golint runtime
# ------------------------------------------------------------------------------
# Standard library
# ------------------------------------------------------------------------------
...
...
runtime/code.go
View file @
c39ad6ca
...
...
@@ -8,13 +8,17 @@ import (
// CodeType is the object representing the Python 'code' type.
var
CodeType
=
newBasisType
(
"code"
,
reflect
.
TypeOf
(
Code
{}),
toCodeUnsafe
,
ObjectType
)
// CodeFlag is a switch controlling the behavior of a Code object.
type
CodeFlag
int
const
(
// CodeFlagVarArg means a Code object accepts *arg parameters.
CodeFlagVarArg
CodeFlag
=
4
CodeFlagKWArg
CodeFlag
=
8
// CodeFlagKWArg means a Code object accepts **kwarg parameters.
CodeFlagKWArg
CodeFlag
=
8
)
// Code represents Python 'code' objects.
type
Code
struct
{
Object
name
string
`attr:"co_name"`
...
...
@@ -29,6 +33,7 @@ type Code struct {
fn
func
(
*
Frame
,
[]
*
Object
)
(
*
Object
,
*
BaseException
)
}
// NewCode creates a new Code object that executes the given fn.
func
NewCode
(
name
,
filename
string
,
args
[]
FunctionArg
,
flags
CodeFlag
,
fn
func
(
*
Frame
,
[]
*
Object
)
(
*
Object
,
*
BaseException
))
*
Code
{
argc
:=
len
(
args
)
minArgc
:=
0
...
...
@@ -50,7 +55,9 @@ func toCodeUnsafe(o *Object) *Code {
return
(
*
Code
)(
o
.
toPointer
())
}
// Eval runs the code object c in the context of the given globals.
func
(
c
*
Code
)
Eval
(
f
*
Frame
,
globals
*
Dict
,
args
Args
,
kwargs
KWArgs
)
(
*
Object
,
*
BaseException
)
{
// Validate parameters.
argc
:=
len
(
args
)
if
argc
>
c
.
argc
&&
c
.
flags
&
CodeFlagVarArg
==
0
{
format
:=
"%s() takes %d arguments (%d given)"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment