@@ -9,25 +9,25 @@ import (
9
9
// Code object
10
10
type Code struct {
11
11
// Object_HEAD
12
- argcount int32 // #arguments, except *args
13
- kwonlyargcount int32 // #keyword only arguments
14
- nlocals int32 // #local variables
15
- stacksize int32 // #entries needed for evaluation stack
16
- flags int32 // CO_..., see below
17
- code Object // instruction opcodes
18
- consts Object // list (constants used)
19
- names Object // list of strings (names used)
20
- varnames Object // tuple of strings (local variable names)
21
- freevars Object // tuple of strings (free variable names)
22
- cellvars Object // tuple of strings (cell variable names)
12
+ Argcount int32 // #arguments, except *args
13
+ Kwonlyargcount int32 // #keyword only arguments
14
+ Nlocals int32 // #local variables
15
+ Stacksize int32 // #entries needed for evaluation stack
16
+ Flags int32 // CO_..., see below
17
+ Code String // instruction opcodes
18
+ Consts Tuple // list (constants used)
19
+ Names Tuple // list of strings (names used)
20
+ Varnames Tuple // tuple of strings (local variable names)
21
+ Freevars Tuple // tuple of strings (free variable names)
22
+ Cellvars Tuple // tuple of strings (cell variable names)
23
23
// The rest doesn't count for hash or comparisons
24
- cell2arg * byte // Maps cell vars which are arguments.
25
- filename Object // unicode (where it was loaded from)
26
- name Object // unicode (name, for reference)
27
- firstlineno int32 // first source line number
28
- lnotab Object // string (encoding addr<->lineno mapping) See Objects/lnotab_notes.txt for details.
24
+ Cell2arg * byte // Maps cell vars which are arguments.
25
+ Filename String // unicode (where it was loaded from)
26
+ Name String // unicode (name, for reference)
27
+ Firstlineno int32 // first source line number
28
+ Lnotab String // string (encoding addr<->lineno mapping) See Objects/lnotab_notes.txt for details.
29
29
30
- weakreflist Object // to support weakrefs to code objects
30
+ Weakreflist List // to support weakrefs to code objects
31
31
}
32
32
33
33
var CodeType = NewType ("code" )
@@ -95,7 +95,7 @@ func all_name_chars(s String) bool {
95
95
// Make a new code object
96
96
func NewCode (argcount int32 , kwonlyargcount int32 ,
97
97
nlocals int32 , stacksize int32 , flags int32 ,
98
- code Object , consts_ Object , names_ Object ,
98
+ code_ Object , consts_ Object , names_ Object ,
99
99
varnames_ Object , freevars_ Object , cellvars_ Object ,
100
100
filename_ Object , name_ Object , firstlineno int32 ,
101
101
lnotab_ Object ) * Code {
@@ -111,6 +111,7 @@ func NewCode(argcount int32, kwonlyargcount int32,
111
111
name := name_ .(String )
112
112
filename := filename_ .(String )
113
113
lnotab := lnotab_ .(String )
114
+ code := code_ .(String )
114
115
115
116
// Check argument types
116
117
if argcount < 0 || kwonlyargcount < 0 || nlocals < 0 {
@@ -167,22 +168,22 @@ func NewCode(argcount int32, kwonlyargcount int32,
167
168
}
168
169
169
170
return & Code {
170
- argcount : argcount ,
171
- kwonlyargcount : kwonlyargcount ,
172
- nlocals : nlocals ,
173
- stacksize : stacksize ,
174
- flags : flags ,
175
- code : code ,
176
- consts : consts ,
177
- names : names ,
178
- varnames : varnames ,
179
- freevars : freevars ,
180
- cellvars : cellvars ,
181
- cell2arg : cell2arg ,
182
- filename : filename ,
183
- name : name ,
184
- firstlineno : firstlineno ,
185
- lnotab : lnotab ,
186
- weakreflist : nil ,
171
+ Argcount : argcount ,
172
+ Kwonlyargcount : kwonlyargcount ,
173
+ Nlocals : nlocals ,
174
+ Stacksize : stacksize ,
175
+ Flags : flags ,
176
+ Code : code ,
177
+ Consts : consts ,
178
+ Names : names ,
179
+ Varnames : varnames ,
180
+ Freevars : freevars ,
181
+ Cellvars : cellvars ,
182
+ Cell2arg : cell2arg ,
183
+ Filename : filename ,
184
+ Name : name ,
185
+ Firstlineno : firstlineno ,
186
+ Lnotab : lnotab ,
187
+ Weakreflist : nil ,
187
188
}
188
189
}
0 commit comments