semantic: Cleanup and separation of concern
mewmew opened this issue · 5 comments
The semantic analysis and type-checker packages are in need of love and could use a refactoring to clear up their separation of concern. Currently semcheck.Check
is empty, and typecheck.Check
does all the work, even pure semantic-checking. We should separate concern and clean up this part of the code.
I agree. Was trying to separate things, but didn't separate enough. Let's
go through this tomorrow.
Med Vänliga Hälsningar
Alexander Andersson
On 29 Apr 2016 02:16, "Robin Eklind" notifications@github.com wrote:
The semantic analysis and type-checker packages are in need of love and
could use a refactoring to clear up their separation of concern. Currently
semcheck.Check is empty, and typecheck.Check does all the work, even pure
semantic-checking. We should separate concern and clean up this part of the
code.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#57
When we do the cleanup (which may happen after v0.3) we should definitely address the issue of resolving identifiers of the universe scope. A temporary workaround was added with commit 12c9719.
In the assignment it says
"Hints
You need to design data structures for the representation of the types of variables and functions."
Can we say this is fulfilled with the code in current state?
Can we say this is fulfilled with the code in current state?
Definitely, it is what the types package does, through the following structure definitions.
// A Basic represents a basic type.
//
// Examples.
//
// char
// int
type Basic struct {
// Kind of basic type.
Kind BasicKind
}
// An Array represents an array type.
//
// Examples.
//
// int[]
// char[128]
type Array struct {
// Element type.
Elem Type
// Array length.
Len int
}
// A Func represents a function signature.
//
// Examples.
//
// int(void)
// int(int a, int b)
type Func struct {
// Return type.
Result Type
// Function parameter types; or nil if void parameter.
Params []*Field
}