Lines Matching refs:comp

51 	comp := &compiler{
69 comp.typedefs[name] = n
70 comp.usedTypedefs[name] = true
73 comp.strFlags[name] = n
75 comp.typecheck()
79 if comp.errors != 0 {
83 fileConsts := comp.extractConsts()
84 if comp.errors != 0 {
89 if comp.target.SyscallNumbers {
90 comp.assignSyscallNumbers(consts)
92 comp.patchConsts(consts)
93 comp.check()
94 if comp.errors != 0 {
97 for _, w := range comp.warnings {
100 syscalls := comp.genSyscalls()
102 Resources: comp.genResources(),
104 StructDescs: comp.genStructDescs(syscalls),
105 Unsupported: comp.unsupported,
107 if comp.errors != 0 {
140 func (comp *compiler) error(pos ast.Pos, msg string, args ...interface{}) {
141 comp.errors++
142 comp.eh(pos, fmt.Sprintf(msg, args...))
145 func (comp *compiler) warning(pos ast.Pos, msg string, args ...interface{}) {
146 comp.warnings = append(comp.warnings, warn{pos, fmt.Sprintf(msg, args...)})
149 func (comp *compiler) structIsVarlen(name string) bool {
150 if varlen, ok := comp.structVarlen[name]; ok {
153 s := comp.structs[name]
155 if varlen, _ := comp.parseUnionAttrs(s); varlen {
156 comp.structVarlen[name] = true
160 comp.structVarlen[name] = false // to not hang on recursive types
163 if comp.isVarlen(fld.Type) {
168 comp.structVarlen[name] = varlen
172 func (comp *compiler) parseUnionAttrs(n *ast.Struct) (varlen bool, size uint64) {
178 comp.error(attr.Pos, "%v attribute has args", attr.Ident)
182 size = comp.parseSizeAttr(attr)
184 comp.error(attr.Pos, "unknown union %v attribute %v",
191 func (comp *compiler) parseStructAttrs(n *ast.Struct) (packed bool, size, align uint64) {
197 comp.error(attr.Pos, "%v attribute has args", attr.Ident)
202 comp.error(attr.Pos, "%v attribute has args", attr.Ident)
204 align = comp.ptrSize
207 comp.error(attr.Pos, "%v attribute has args", attr.Ident)
211 comp.error(attr.Pos, "bad struct %v alignment %v",
216 comp.error(attr.Pos, "bad struct %v alignment %v (must be a sane power of 2)",
221 size = comp.parseSizeAttr(attr)
223 comp.error(attr.Pos, "unknown struct %v attribute %v",
230 func (comp *compiler) parseSizeAttr(attr *ast.Type) uint64 {
232 comp.error(attr.Pos, "%v attribute is expected to have 1 argument", attr.Ident)
237 comp.error(sz.Pos, "unexpected %v, expect int", unexpected)
241 comp.error(sz.Pos, "size attribute has colon or args")
247 func (comp *compiler) getTypeDesc(t *ast.Type) *typeDesc {
251 if comp.resources[t.Ident] != nil {
254 if comp.structs[t.Ident] != nil {
257 if comp.typedefs[t.Ident] != nil {
263 func (comp *compiler) getArgsBase(t *ast.Type, field string, dir prog.Dir, isArg bool) (
265 desc := comp.getTypeDesc(t)
273 base.TypeSize = comp.ptrSize
277 base = typeInt.Gen(comp, baseType, nil, base).(*prog.IntType).IntTypeCommon
283 func (comp *compiler) foreachType(n0 ast.Node,
288 comp.foreachSubType(arg.Type, true, cb)
291 comp.foreachSubType(n.Ret, true, cb)
294 comp.foreachSubType(n.Base, false, cb)
297 comp.foreachSubType(f.Type, false, cb)
301 comp.foreachSubType(n.Type, false, cb)
308 func (comp *compiler) foreachSubType(t *ast.Type, isArg bool,
310 desc, args, base := comp.getArgsBase(t, "", prog.DirIn, isArg)
314 comp.foreachSubType(arg, desc.Args[i].IsArg, cb)
327 func (comp *compiler) parseIntType(name string) (size uint64, bigEndian bool) {
332 size = comp.ptrSize