Skip to content

Commit

Permalink
Correctly clone FuncTypes, fixes lotsa problems with specialization :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amos Wenger committed Jun 8, 2012
1 parent bf0e3e6 commit 6a62950
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion source/rock/middle/Block.ooc
Expand Up @@ -11,7 +11,7 @@ Block: class extends ControlStatement {

clone: func -> This {
copy := new(token)
body list each(|e| copy body add(e clone()))
body list each(|stat| copy body add(stat clone()))
copy
}

Expand Down
2 changes: 1 addition & 1 deletion source/rock/middle/CommaSequence.ooc
Expand Up @@ -13,7 +13,7 @@ CommaSequence: class extends Expression {

clone: func -> This {
copy := new(token)
body each(|e| copy body add(e clone()))
body each(|stat| copy body add(stat clone()))
copy
}

Expand Down
2 changes: 1 addition & 1 deletion source/rock/middle/Foreach.ooc
Expand Up @@ -17,7 +17,7 @@ Foreach: class extends ControlStatement {

clone: func -> This {
copy := new(variable clone(), collection clone(), token)
body list each(|e| copy body add(e clone()))
body list each(|stat| copy body add(stat clone()))
copy
}

Expand Down
8 changes: 4 additions & 4 deletions source/rock/middle/FuncType.ooc
Expand Up @@ -57,16 +57,16 @@ FuncType: class extends Type {
for(argType in argTypes) {
copy argTypes add(argType realTypize(call))
}
copy returnType = returnType realTypize
copy returnType = returnType ? returnType realTypize(call) : null
copy varArg = varArg
copy
}

clone: func -> This {
copy := This new(token)
if(typeArgs) typeArgs each(|typeArg| copy addTypeArg(typeArg))
copy argTypes addAll(argTypes)
copy returnType = returnType
if(typeArgs) typeArgs each(|typeArg| copy addTypeArg(typeArg clone()))
argTypes each(|argType| copy argTypes add(argType clone()))
copy returnType = returnType ? returnType clone() : null
copy varArg = varArg
copy
}
Expand Down
10 changes: 8 additions & 2 deletions source/rock/middle/FunctionCall.ooc
Expand Up @@ -120,7 +120,7 @@ FunctionCall: class extends Expression {
clone: func -> This {
copy := new(expr, name, token)
copy suffix = suffix
args each(|e| copy args add(e clone()))
args each(|arg| copy args add(arg clone()))
copy
}

Expand All @@ -145,7 +145,7 @@ FunctionCall: class extends Expression {
* a return expression, when it's being used.
*/
debugCondition: func -> Bool {
false
name == "falafel"
}

/**
Expand Down Expand Up @@ -234,6 +234,12 @@ FunctionCall: class extends Expression {

resolve: func (trail: Trail, res: Resolver) -> Response {

// DEBUG code
if (name == "bbtrap") {
"Trail from trap = " println()
trail toString() println()
}

if(debugCondition() || res params veryVerbose) {
"===============================================================" println()
" - Resolving call to %s (ref = %s)" printfln(name, ref ? ref toString(): "(nil)")
Expand Down
12 changes: 6 additions & 6 deletions source/rock/middle/Scope.ooc
Expand Up @@ -6,11 +6,11 @@ import ../frontend/[BuildParams, Token]

Scope: class extends Node {

size: SSizeT {
get {
list getSize()
}
}
size: SSizeT {
get {
list getSize()
}
}

list : ArrayList<Statement> { get set }

Expand All @@ -20,7 +20,7 @@ Scope: class extends Node {

clone: func -> This {
copy := new()
list each(|e| copy list add(e clone()))
list each(|stat| copy list add(stat clone()))
copy
}

Expand Down
2 changes: 1 addition & 1 deletion source/rock/middle/tinker/Trail.ooc
Expand Up @@ -165,7 +165,7 @@ Trail: class extends Stack<Node> {
for(j in 0..i) {
sb append(" ")
}
sb append("\\_, "). append(get(i) toString()). append('\n')
sb append("\\_, "). append(get(i) class name). append(" | "). append(get(i) toString()). append('\n')
}

sb toString()
Expand Down

0 comments on commit 6a62950

Please sign in to comment.