candidate f64 support
This commit is contained in:
@@ -8,7 +8,7 @@ use parser::{lex, parse, Expr, Stmt, FnDef};
|
||||
use fn_register::FnRegister;
|
||||
|
||||
use std::ops::{Add, Sub, Mul, Div};
|
||||
use std::cmp::{Ord, Eq};
|
||||
use std::cmp::{PartialOrd, PartialEq};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum EvalAltResult {
|
||||
@@ -913,6 +913,7 @@ impl Engine {
|
||||
fn eval_expr(&self, scope: &mut Scope, expr: &Expr) -> Result<Box<Any>, EvalAltResult> {
|
||||
match *expr {
|
||||
Expr::IntConst(i) => Ok(Box::new(i)),
|
||||
Expr::FloatConst(i) => Ok(Box::new(i)),
|
||||
Expr::StringConst(ref s) => Ok(Box::new(s.clone())),
|
||||
Expr::CharConst(ref c) => Ok(Box::new(*c)),
|
||||
Expr::Identifier(ref id) => {
|
||||
@@ -1329,12 +1330,12 @@ impl Engine {
|
||||
fn sub<T: Sub>(x: T, y: T) -> <T as Sub>::Output { x - y }
|
||||
fn mul<T: Mul>(x: T, y: T) -> <T as Mul>::Output { x * y }
|
||||
fn div<T: Div>(x: T, y: T) -> <T as Div>::Output { x / y }
|
||||
fn lt<T: Ord>(x: T, y: T) -> bool { x < y }
|
||||
fn lte<T: Ord>(x: T, y: T) -> bool { x <= y }
|
||||
fn gt<T: Ord>(x: T, y: T) -> bool { x > y }
|
||||
fn gte<T: Ord>(x: T, y: T) -> bool { x >= y }
|
||||
fn eq<T: Eq>(x: T, y: T) -> bool { x == y }
|
||||
fn ne<T: Eq>(x: T, y: T) -> bool { x != y }
|
||||
fn lt<T: PartialOrd>(x: T, y: T) -> bool { x < y }
|
||||
fn lte<T: PartialOrd>(x: T, y: T) -> bool { x <= y }
|
||||
fn gt<T: PartialOrd>(x: T, y: T) -> bool { x > y }
|
||||
fn gte<T: PartialOrd>(x: T, y: T) -> bool { x >= y }
|
||||
fn eq<T: PartialEq>(x: T, y: T) -> bool { x == y }
|
||||
fn ne<T: PartialEq>(x: T, y: T) -> bool { x != y }
|
||||
fn and(x: bool, y: bool) -> bool { x && y }
|
||||
fn or(x: bool, y: bool) -> bool { x || y }
|
||||
fn concat(x: String, y: String) -> String { x + &y }
|
||||
@@ -1344,12 +1345,12 @@ impl Engine {
|
||||
reg_op!(engine, "*", mul, i32, i64, u32, u64, f32, f64);
|
||||
reg_op!(engine, "/", div, i32, i64, u32, u64, f32, f64);
|
||||
|
||||
reg_cmp!(engine, "<", lt, i32, i64, u32, u64, String);
|
||||
reg_cmp!(engine, "<=", lte, i32, i64, u32, u64, String);
|
||||
reg_cmp!(engine, ">", gt, i32, i64, u32, u64, String);
|
||||
reg_cmp!(engine, ">=", gte, i32, i64, u32, u64, String);
|
||||
reg_cmp!(engine, "==", eq, i32, i64, u32, u64, bool, String);
|
||||
reg_cmp!(engine, "!=", ne, i32, i64, u32, u64, bool, String);
|
||||
reg_cmp!(engine, "<", lt, i32, i64, u32, u64, String, f64);
|
||||
reg_cmp!(engine, "<=", lte, i32, i64, u32, u64, String, f64);
|
||||
reg_cmp!(engine, ">", gt, i32, i64, u32, u64, String, f64);
|
||||
reg_cmp!(engine, ">=", gte, i32, i64, u32, u64, String, f64);
|
||||
reg_cmp!(engine, "==", eq, i32, i64, u32, u64, bool, String, f64);
|
||||
reg_cmp!(engine, "!=", ne, i32, i64, u32, u64, bool, String, f64);
|
||||
|
||||
reg_op!(engine, "||", or, bool);
|
||||
reg_op!(engine, "&&", and, bool);
|
||||
|
Reference in New Issue
Block a user