Skip to content

Commit

Permalink
some cleanup of unneccesary noise in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Stevan Little committed Feb 25, 2013
1 parent e5b39f9 commit 80834de
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 129 deletions.
128 changes: 46 additions & 82 deletions src/main/scala/org/moe/runtime/builtins/IntClass.scala
Expand Up @@ -26,12 +26,10 @@ object IntClass {
"infix:<+>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getInt(e.getCurrentInvocant.get.unboxToInt.get + i.unboxToInt.get)
case f: MoeNumObject => getNum(e.getCurrentInvocant.get.unboxToDouble.get + f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getInt(e.getCurrentInvocant.get.unboxToInt.get + i.unboxToInt.get)
case f: MoeNumObject => getNum(e.getCurrentInvocant.get.unboxToDouble.get + f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -41,12 +39,10 @@ object IntClass {
"infix:<->",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getInt(e.getCurrentInvocant.get.unboxToInt.get - i.unboxToInt.get)
case f: MoeNumObject => getNum(e.getCurrentInvocant.get.unboxToDouble.get - f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getInt(e.getCurrentInvocant.get.unboxToInt.get - i.unboxToInt.get)
case f: MoeNumObject => getNum(e.getCurrentInvocant.get.unboxToDouble.get - f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -56,12 +52,10 @@ object IntClass {
"infix:<*>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getInt(e.getCurrentInvocant.get.unboxToInt.get * i.unboxToInt.get)
case f: MoeNumObject => getNum(e.getCurrentInvocant.get.unboxToDouble.get * f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getInt(e.getCurrentInvocant.get.unboxToInt.get * i.unboxToInt.get)
case f: MoeNumObject => getNum(e.getCurrentInvocant.get.unboxToDouble.get * f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -71,9 +65,7 @@ object IntClass {
"infix:</>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getNum(e.getCurrentInvocant.get.unboxToInt.get / e.get("$other").get.unboxToDouble.get)
}
(e) => getNum(e.getCurrentInvocant.get.unboxToInt.get / e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -82,9 +74,7 @@ object IntClass {
"infix:<%>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getInt(perlModuloOp(e.getCurrentInvocant.get.unboxToInt.get, e.get("$other").get.unboxToInt.get))
}
(e) => getInt(perlModuloOp(e.getCurrentInvocant.get.unboxToInt.get, e.get("$other").get.unboxToInt.get))
)
)

Expand All @@ -93,12 +83,10 @@ object IntClass {
"infix:<**>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getInt(Math.pow(e.getCurrentInvocant.get.unboxToInt.get, i.unboxToInt.get).toInt)
case f: MoeNumObject => getNum(Math.pow(e.getCurrentInvocant.get.unboxToInt.get, f.unboxToDouble.get))
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getInt(Math.pow(e.getCurrentInvocant.get.unboxToInt.get, i.unboxToInt.get).toInt)
case f: MoeNumObject => getNum(Math.pow(e.getCurrentInvocant.get.unboxToInt.get, f.unboxToDouble.get))
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -110,12 +98,10 @@ object IntClass {
"infix:<<>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get < i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get < f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get < i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get < f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -125,12 +111,10 @@ object IntClass {
"infix:<<>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get < i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get < f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get < i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get < f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -140,12 +124,10 @@ object IntClass {
"infix:<>>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get > i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get > f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get > i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get > f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -155,12 +137,10 @@ object IntClass {
"infix:<<=>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get <= i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get <= f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get <= i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get <= f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -170,12 +150,10 @@ object IntClass {
"infix:<>=>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get >= i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get >= f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get >= i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get >= f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -185,12 +163,10 @@ object IntClass {
"infix:<==>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get == i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get == f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get == i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get == f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)
Expand All @@ -200,33 +176,21 @@ object IntClass {
"infix:<!=>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get != i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get != f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
(e) => e.get("$other").get match {
case i: MoeIntObject => getBool(e.getCurrentInvocant.get.unboxToInt.get != i.unboxToInt.get)
case f: MoeNumObject => getBool(e.getCurrentInvocant.get.unboxToDouble.get != f.unboxToDouble.get)
case _ => throw new MoeErrors.UnexpectedType(e.get("$other").get.toString)
}
)
)

/**
* List of Operators to support:
* - infix:<->
* - infix:</>
* - infix:<%>
* - prefix:<++>
* - postfix:<++>
* - prefix:<-->
* - postfix:<-->
* - prefix:<->
* - infix:<**>
* - infix:<==>
* - infix:<!=>
* - infix:<<>
* - infix:<>>
* - infix:<<=>
* - infix:<>=>
* - infix:<<=>>
* NOTE: probably need the bitwise stuff too
*
Expand Down
59 changes: 12 additions & 47 deletions src/main/scala/org/moe/runtime/builtins/NumClass.scala
Expand Up @@ -23,9 +23,7 @@ object NumClass {
"infix:<+>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getNum(e.getCurrentInvocant.get.unboxToDouble.get + e.get("$other").get.unboxToDouble.get)
}
(e) => getNum(e.getCurrentInvocant.get.unboxToDouble.get + e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -34,9 +32,7 @@ object NumClass {
"infix:<->",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getNum(e.getCurrentInvocant.get.unboxToDouble.get - e.get("$other").get.unboxToDouble.get)
}
(e) => getNum(e.getCurrentInvocant.get.unboxToDouble.get - e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -45,9 +41,7 @@ object NumClass {
"infix:<*>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getNum(e.getCurrentInvocant.get.unboxToDouble.get * e.get("$other").get.unboxToDouble.get)
}
(e) => getNum(e.getCurrentInvocant.get.unboxToDouble.get * e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -56,9 +50,7 @@ object NumClass {
"infix:</>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getNum(e.getCurrentInvocant.get.unboxToDouble.get / e.get("$other").get.unboxToDouble.get)
}
(e) => getNum(e.getCurrentInvocant.get.unboxToDouble.get / e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -67,9 +59,7 @@ object NumClass {
"infix:<%>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getInt(perlModuloOp(e.getCurrentInvocant.get.unboxToInt.get, e.get("$other").get.unboxToInt.get))
}
(e) => getInt(perlModuloOp(e.getCurrentInvocant.get.unboxToInt.get, e.get("$other").get.unboxToInt.get))
)
)

Expand All @@ -78,9 +68,7 @@ object NumClass {
"infix:<**>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getNum(Math.pow(e.getCurrentInvocant.get.unboxToDouble.get, e.get("$other").get.unboxToDouble.get))
}
(e) => getNum(Math.pow(e.getCurrentInvocant.get.unboxToDouble.get, e.get("$other").get.unboxToDouble.get))
)
)

Expand All @@ -91,9 +79,7 @@ object NumClass {
"infix:<<>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getBool(e.getCurrentInvocant.get.unboxToDouble.get < e.get("$other").get.unboxToDouble.get)
}
(e) => getBool(e.getCurrentInvocant.get.unboxToDouble.get < e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -102,9 +88,7 @@ object NumClass {
"infix:<>>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getBool(e.getCurrentInvocant.get.unboxToDouble.get > e.get("$other").get.unboxToDouble.get)
}
(e) => getBool(e.getCurrentInvocant.get.unboxToDouble.get > e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -113,9 +97,7 @@ object NumClass {
"infix:<<=>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getBool(e.getCurrentInvocant.get.unboxToDouble.get <= e.get("$other").get.unboxToDouble.get)
}
(e) => getBool(e.getCurrentInvocant.get.unboxToDouble.get <= e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -124,9 +106,7 @@ object NumClass {
"infix:<>=>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getBool(e.getCurrentInvocant.get.unboxToDouble.get >= e.get("$other").get.unboxToDouble.get)
}
(e) => getBool(e.getCurrentInvocant.get.unboxToDouble.get >= e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -135,9 +115,7 @@ object NumClass {
"infix:<==>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getBool(e.getCurrentInvocant.get.unboxToDouble.get == e.get("$other").get.unboxToDouble.get)
}
(e) => getBool(e.getCurrentInvocant.get.unboxToDouble.get == e.get("$other").get.unboxToDouble.get)
)
)

Expand All @@ -146,30 +124,17 @@ object NumClass {
"infix:<!=>",
new MoeSignature(List(new MoeParameter("$other"))),
env,
{ (e) =>
getBool(e.getCurrentInvocant.get.unboxToDouble.get != e.get("$other").get.unboxToDouble.get)
}
(e) => getBool(e.getCurrentInvocant.get.unboxToDouble.get != e.get("$other").get.unboxToDouble.get)
)
)

/**
* List of Operators to support:
* - infix:<*>
* - infix:<->
* - infix:</>
* - infix:<%>
* - prefix:<++>
* - postfix:<++>
* - prefix:<-->
* - postfix:<-->
* - prefix:<->
* - infix:<**>
* - infix:<==>
* - infix:<!=>
* - infix:<<>
* - infix:<>>
* - infix:<<=>
* - infix:<>=>
* - infix:<<=>>
* NOTE: probably need the bitwise stuff too
*
Expand Down

0 comments on commit 80834de

Please sign in to comment.