From df86e0c16e849995c3bed0af7e38ee6ced4434d7 Mon Sep 17 00:00:00 2001
From: greg <greg.shuflin@protonmail.com>
Date: Sat, 24 Feb 2018 14:39:45 -0800
Subject: [PATCH] Make sigil field private

---
 src/schala_lang/builtin.rs | 10 ++++++++--
 src/schala_lang/eval.rs    | 10 +++++-----
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/schala_lang/builtin.rs b/src/schala_lang/builtin.rs
index c9288f3..c2d5df0 100644
--- a/src/schala_lang/builtin.rs
+++ b/src/schala_lang/builtin.rs
@@ -2,18 +2,21 @@ use std::rc::Rc;
 
 #[derive(Debug, PartialEq, Clone)]
 pub struct BinOp {
-  pub sigil: Rc<String>
+  sigil: Rc<String>
 }
 
 #[derive(Debug, PartialEq, Clone)]
 pub struct PrefixOp {
-  pub sigil: Rc<String>
+  sigil: Rc<String>
 }
 
 impl BinOp {
   pub fn from_sigil(sigil: Rc<String>) -> BinOp {
     BinOp { sigil }
   }
+  pub fn sigil(&self) -> &Rc<String> {
+    &self.sigil
+  }
   pub fn min_precedence() -> i32 {
     i32::min_value()
   }
@@ -31,6 +34,9 @@ impl PrefixOp {
   pub fn from_sigil(sigil: Rc<String>) -> PrefixOp {
     PrefixOp { sigil }
   }
+  pub fn sigil(&self) -> &Rc<String> {
+    &self.sigil
+  }
   pub fn is_prefix(op: &str) -> bool {
     match op {
       "+" | "-" | "!" | "~" => true,
diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs
index a7c0586..19e0f42 100644
--- a/src/schala_lang/eval.rs
+++ b/src/schala_lang/eval.rs
@@ -176,8 +176,9 @@ impl<'a> State<'a> {
     use self::FullyEvaluatedExpr::*;
     let evaled_lhs = self.eval_expr(*lhs)?;
     let evaled_rhs = self.eval_expr(*rhs)?;
-    let sigil: &str = op.sigil.as_ref().as_str();
-    Ok(match (sigil, evaled_lhs, evaled_rhs) {
+    let sigil = op.sigil();
+    //let sigil: &str = op.sigil().as_ref().as_str();
+    Ok(match (sigil.as_str(), evaled_lhs, evaled_rhs) {
       ("+", UnsignedInt(l), UnsignedInt(r)) => UnsignedInt(l + r),
       ("++", Str(s1), Str(s2)) => Str(format!("{}{}", s1, s2)),
       ("-", UnsignedInt(l), UnsignedInt(r)) => UnsignedInt(l - r),
@@ -191,10 +192,9 @@ impl<'a> State<'a> {
   fn eval_prefix_exp(&mut self, op: PrefixOp, expr: Box<Expression>) -> EvalResult<FullyEvaluatedExpr> {
     use self::FullyEvaluatedExpr::*;
     let evaled_expr = self.eval_expr(*expr)?;
+    let sigil = op.sigil();
 
-    let sigil: &str = op.sigil.as_ref().as_str();
-
-    Ok(match (sigil, evaled_expr) {
+    Ok(match (sigil.as_str(), evaled_expr) {
       ("!", Bool(true)) => Bool(false),
       ("!", Bool(false)) => Bool(true),
       ("-", UnsignedInt(n)) => SignedInt(-1*(n as i64)),