Skip to content

Commit

Permalink
Added exponent operator. Closes ooc-lang#232
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnask committed Nov 29, 2011
1 parent 60ec586 commit 5c7c81e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 13 additions & 1 deletion source/rock/frontend/AstBuilder.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,13 @@ AstBuilder: class {
onFunctionCallCombo: unmangled(nq_onFunctionCallCombo) func (call: FunctionCall, expr: Expression) {
name := call generateTempName("comboRoot")
call setName(name)
vDecl := VariableDecl new(null, name, expr, expr token)

vDecl := VariableDecl new(null, name, expr, true, expr token)
vDecl isGlobal = true // well, that's not true, but at least this way it won't be marked for partialing...
onStatement(vDecl)

call inBinOrTern = true // We don't know that, but we assume it :D
call botRight = expr
}

onFunctionCallChain: unmangled(nq_onFunctionCallChain) func (expr: Expression, call: FunctionCall) -> CallChain {
Expand Down Expand Up @@ -1053,6 +1057,10 @@ AstBuilder: class {
BinaryOp new(left, right, OpType mulAss, token())
}

onAssignExp: unmangled(nq_onAssignExp) func (left, right: Expression) -> BinaryOp {
BinaryOp new(left, right, OpType expAss, token())
}

onAssignDiv: unmangled(nq_onAssignDiv) func (left, right: Expression) -> BinaryOp {
BinaryOp new(left, right, OpType divAss, token())
}
Expand Down Expand Up @@ -1097,6 +1105,10 @@ AstBuilder: class {
BinaryOp new(left, right, OpType mul, token())
}

onExp: unmangled(nq_onExp) func (left, right: Expression) -> BinaryOp {
BinaryOp new(left, right, OpType exp, token())
}

onDiv: unmangled(nq_onDiv) func (left, right: Expression) -> BinaryOp {
BinaryOp new(left, right, OpType div, token())
}
Expand Down
4 changes: 4 additions & 0 deletions source/rock/middle/BinaryOp.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ OpType: enum {
add /* + */
sub /* - */
mul /* * */
exp /*..**.*/
div /* / */
mod /* % */
rshift /* >> */
Expand All @@ -22,6 +23,7 @@ OpType: enum {
addAss /* += */
subAss /* -= */
mulAss /* *= */
expAss /*.**=.*/
divAss /* /= */
rshiftAss /* >>= */
lshiftAss /* <<= */
Expand All @@ -37,6 +39,7 @@ opTypeRepr := [
"+",
"-",
"*",
"**",
"/",
"%",
">>",
Expand All @@ -49,6 +52,7 @@ opTypeRepr := [
"+=",
"-=",
"*=",
"**=",
"/=",
">>=",
"<<=",
Expand Down
2 changes: 2 additions & 0 deletions source/rock/middle/OperatorDecl.ooc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ OperatorDecl: class extends Expression {
case "+" => "ADD"
case "-" => "SUB"
case "*" => "MUL"
case "**" => "EXP"
case "/" => "DIV"
case "<<" => "B_LSHIFT"
case ">>" => "B_RSHIFT"
Expand All @@ -101,6 +102,7 @@ OperatorDecl: class extends Expression {
case "+=" => "ADD_ASS"
case "-=" => "SUB_ASS"
case "*=" => "MUL_ASS"
case "**=" => "EXP_ASS"
case "/=" => "DIV_ASS"
case "<<=" => "B_LSHIFT_ASS"
case ">>=" => "B_RSHIFT_ASS"
Expand Down

0 comments on commit 5c7c81e

Please sign in to comment.