Permalink
Browse files

Attempt... messed up, apparently doesn't check anything anymore, but …

…some of the right code is there
  • Loading branch information...
1 parent 02bf900 commit d3cca56864e8fa53ec09ff412ba747630b0c7776 Amos Wenger committed May 19, 2011
@@ -19,7 +19,8 @@ SecurityAttributes: cover from SECURITY_ATTRIBUTES {
PipeWin32: class extends Pipe {
- readFD = 0, writeFD = 0 : Handle
+ readFD := null as Handle
+ writeFD := null as Handle
init: func ~twos {
saAttr: SecurityAttributes
View
@@ -121,7 +121,7 @@ murmurHash: func <K> (keyTagazok: K) -> SizeT {
ac_X31_hash: func <K> (key: K) -> SizeT {
assert(key != null)
s : Char* = (K == String) ? (key as String) toCString() as Char* : key as Char*
- h = s@ : SizeT
+ h := s@ as SizeT
if (h) {
s += 1
while (s@) {
@@ -250,8 +250,30 @@ BaseType: class extends Type {
return scoreSeed / 2
}
- if(other instanceOf?(BaseType)) {
+ if(other instanceOf?(BaseType)) {
if(ourRef == hisRef) {
+ lType := this
+ rType := other as BaseType
+ if(lType typeArgs != null && rType typeArgs) {
+ for(i in 0..lType typeArgs size) {
+ lta := lType typeArgs[i]
+ rta := rType typeArgs[i]
+
+ if(lta getRef() instanceOf?(TypeDecl) && rta getRef() instanceOf?(TypeDecl)) {
+ if(!(
+ (lta getType() equals?(rta getType())) ||
+ (lta getRef() as TypeDecl inheritsFrom?(rta getRef() as TypeDecl))
+ )) {
+ "No luck between %s and %s" printfln(lta getRef() toString(), rta getRef() toString())
+ " ie. between %s and %s" printfln(lta getType() toString(), rta getType() toString())
+ return This NOLUCK_SCORE
+ }
+ } else {
+ break
+ }
+ }
+ }
+
// perfect match
return scoreSeed
}
@@ -1,7 +1,7 @@
import ../frontend/[Token, BuildParams]
import ../backend/cnaughty/AwesomeWriter
import Literal, Visitor, Type, Expression, Node, TypeList, Tuple,
- Declaration, FunctionCall, VariableAccess
+ Declaration, FunctionCall, VariableAccess, ClassDecl
import tinker/[Response, Resolver, Trail]
import structs/[List, ArrayList]
@@ -32,7 +32,7 @@ AnonymousStructType: class extends Type {
pointerLevel: func -> Int { 0 }
getName: func -> String { "<anon struct>" }
- getRef: func -> Declaration { null }
+ getRef: func -> Declaration { ClassDecl new(getName(), token) }
setRef: func (d: Declaration) { raise("Setting ref of an anonymous struct type!") }
realTypize: func (call: FunctionCall) -> Type { this }
@@ -307,11 +307,52 @@ VariableDecl: class extends Declaration {
res wholeAgain(this, "just set expr to gc_malloc cause generic!")
}
+ /*
+ if(!isLegal(res)) {
+ res throwError(InvalidOperatorUse new(token, "Incompatible type for declaration between %s and %s (which is a %s, ie. a %s)\n" format(
+ type toString(), expr getType() toString(), expr class name, expr toString())))
+ }
+ */
+
if(debugCondition()) "Done resolving!" println()
return Response OK
}
+
+
+ isLegal: func (res: Resolver) -> Bool {
+ if(!expr) return true
+
+ (lType, rType) := (type, expr getType())
+
+ if(lType == null || lType getRef() == null || rType == null || rType getRef() == null) {
+ // must resolve first
+ res wholeAgain(this, "Unresolved types in decl because of types, looping to determine legitness")
+ /*
+ res wholeAgain(this, "Unresolved types in decl because of types (%s, %s), looping to determine legitness %d %d %d %d" format(
+ lType == null ? "(nil)" : lType toString(),
+ rType == null ? "(nil)" : rType toString(),
+ lType == null,
+ lType == null || lType getRef() == null,
+ rType == null,
+ rType == null || rType getRef() == null
+ ))
+ */
+ return true
+ }
+
+ (lRef, rRef) := (lType getRef(), rType getRef())
+
+ score := lType getScore(rType)
+ if(score == -1) {
+ // must resolve first
+ res wholeAgain(this, "Unresolved types in decl because of score, looping to determine legitness")
+ return true
+ }
+
+ score >= 0
+ }
replace: func (oldie, kiddo: Node) -> Bool {
match oldie {

0 comments on commit d3cca56

Please sign in to comment.