Skip to content

Commit

Permalink
Work around enums now starting at '1' by default, that broke bootstra…
Browse files Browse the repository at this point in the history
…p btw, shame on me.
  • Loading branch information
nddrylliog committed Dec 30, 2012
1 parent 078d98a commit 05e5291
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
10 changes: 7 additions & 3 deletions source/rock/middle/BinaryOp.ooc
Expand Up @@ -98,7 +98,11 @@ BinaryOp: class extends Expression {
getRight: func -> Expression { right }

toString: func -> String {
return left toString() + " " + opTypeRepr[type] + " " + right toString()
return left toString() + " " + repr() + " " + right toString()
}

repr: func -> String {
opTypeRepr[type as Int - OpType add]
}

unwrapAssign: func (trail: Trail, res: Resolver) -> Bool {
Expand Down Expand Up @@ -321,7 +325,7 @@ BinaryOp: class extends Expression {
if(!isLegal(res)) {
if(res fatal) {
res throwError(InvalidOperatorUse new(token, "Invalid use of operator %s between operands of type %s and %s\n" format(
opTypeRepr[type], left getType() toString(), right getType() toString())))
repr(), left getType() toString(), right getType() toString())))
return Response OK
}
res wholeAgain(this, "Illegal use, looping in hope.")
Expand Down Expand Up @@ -472,7 +476,7 @@ BinaryOp: class extends Expression {

getScore: func (op: OperatorDecl, reqType: Type) -> Int {

symbol := opTypeRepr[type]
symbol := repr()

half := false

Expand Down
8 changes: 6 additions & 2 deletions source/rock/middle/Comparison.ooc
Expand Up @@ -45,8 +45,12 @@ Comparison: class extends Expression {

getType: func -> Type { This type }

repr: func -> String {
opTypeRepr[type as Int - CompType equal]
}

toString: func -> String {
return left toString() + " " + compTypeRepr[compType] + " " + right toString()
return left toString() + " " + repr() + " " + right toString()
}

resolve: func (trail: Trail, res: Resolver) -> Response {
Expand Down Expand Up @@ -192,7 +196,7 @@ Comparison: class extends Expression {

getScore: func (op: OperatorDecl, reqType: Type) -> Int {

symbol := compTypeRepr[compType]
symbol := repr()

half := false

Expand Down
10 changes: 7 additions & 3 deletions source/rock/middle/UnaryOp.ooc
Expand Up @@ -10,7 +10,7 @@ UnaryOpType: enum {
}

unaryOpRepr := [
"~",
"~",
"!",
"-"]

Expand Down Expand Up @@ -38,8 +38,12 @@ UnaryOp: class extends Expression {
inner getType()
}

repr: func -> String {
unaryOpRepr[type as Int - UnaryOpType binaryNot]
}

toString: func -> String {
return unaryOpRepr[type] + inner toString()
return repr() + inner toString()
}

resolve: func (trail: Trail, res: Resolver) -> Response {
Expand Down Expand Up @@ -116,7 +120,7 @@ UnaryOp: class extends Expression {

getScore: func (op: OperatorDecl, reqType: Type) -> Int {

symbol := unaryOpRepr[type]
symbol := repr()

if(!(op getSymbol() equals?(symbol))) {
return 0 // not the right overload type - skip
Expand Down

0 comments on commit 05e5291

Please sign in to comment.