Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added exponent operator. Closes #232

  • Loading branch information...
commit 5c7c81e56bfd95520f6325a05132c37b55be223f 1 parent 60ec586
@shamanas authored
View
14 source/rock/frontend/AstBuilder.ooc
@@ -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 {
@@ -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())
}
@@ -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())
}
View
4 source/rock/middle/BinaryOp.ooc
@@ -10,6 +10,7 @@ OpType: enum {
add /* + */
sub /* - */
mul /* * */
+ exp /*..**.*/
div /* / */
mod /* % */
rshift /* >> */
@@ -22,6 +23,7 @@ OpType: enum {
addAss /* += */
subAss /* -= */
mulAss /* *= */
+ expAss /*.**=.*/
divAss /* /= */
rshiftAss /* >>= */
lshiftAss /* <<= */
@@ -37,6 +39,7 @@ opTypeRepr := [
"+",
"-",
"*",
+ "**",
"/",
"%",
">>",
@@ -49,6 +52,7 @@ opTypeRepr := [
"+=",
"-=",
"*=",
+ "**=",
"/=",
">>=",
"<<=",
View
2  source/rock/middle/OperatorDecl.ooc
@@ -90,6 +90,7 @@ OperatorDecl: class extends Expression {
case "+" => "ADD"
case "-" => "SUB"
case "*" => "MUL"
+ case "**" => "EXP"
case "/" => "DIV"
case "<<" => "B_LSHIFT"
case ">>" => "B_RSHIFT"
@@ -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"
Please sign in to comment.
Something went wrong with that request. Please try again.