Hi folks,
I'd like to get some feedback before I go ahead and start submitting CL's.
I keep putting this off, so apologies for the slight brain dump.
I want to get some of the basic stuff out of the way so I can focus on the
more significant issues of type checking. So below are the changes I'm proposing.
types.go
======
Complete functionality for the Type structs, and make them all Stringers for debugging.
- Basic: add a Kind field of a new type BasicTypeKind with underlying type reflect.Kind.
- Struct: add a FieldIndices field which maps field names to indices, including anonymous fields.
- Name: add a Methods field which contains an ObjList of methods.
const.go
======
I haven't done a lot here, but here's what I'd like to change:
- Expose Const.val as Const.Val, so external packages can access the values. I'd just
change it to "type Const interface{}" but I think we may want to revisit the type, so I'd
rather not spend too much time on it right now.
- Implement unary operators for all types, and binary shift operators for big.Int.
- Add a case for "nil" in the Const.String method.
universe.go
========
Nothing much to see here.
- Fill in the Type field for builtin types (defType will take a BasicTypeKind),
and fill in Data where it makes sense (e.g. true/false).
gcimporter.go
==========
- Record method signature (Func) as the object's Type.
- Sort and record methods against receiver types.
This one is obviously the most lacking, and will take several CL's. Here's my plan:
1. Fixes for issues in existing code:
- address the TODO in *ast.SelectorExpr case of makeType.
- compute array length in *ast.ArrayType of makeType.
- obtain isVariadic from params rather than results in *ast.FuncType of makeType.
- change last parameter type in variadic functions to a Slice of the declared type.
Presumably this won't cause anyone grief since functions were never properly
identified as being variadic anyway (see above point).
2. Add in more code for checking objects:
- Address TODO's in checkObj.
- Record struct field indices.
- Record type methods, and associate receivers with corresponding Type.
3. Implement expression and statement checking. I've just begun this, so it's a ways off.
Regards,
Andrew