Unverified Commit 73b44a18 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: CompileTimeDefineValue numbers and regex (#90934)

- Number(f64) instead of Number(RcStr)
- Add BigInt
- Add Regex
parent 60a847b0
...@@ -9968,6 +9968,7 @@ dependencies = [ ...@@ -9968,6 +9968,7 @@ dependencies = [
"data-encoding", "data-encoding",
"either", "either",
"indexmap 2.13.0", "indexmap 2.13.0",
"num-bigint",
"once_cell", "once_cell",
"patricia_tree", "patricia_tree",
"petgraph 0.8.3", "petgraph 0.8.3",
......
...@@ -834,9 +834,9 @@ async fn parse_config_value( ...@@ -834,9 +834,9 @@ async fn parse_config_value(
}; };
match value { match value {
JsValue::Constant(ConstantValue::Num(ConstantNumber(val))) if val >= 0.0 => { JsValue::Constant(ConstantValue::Num(ConstantNumber(val))) if *val >= 0.0 => {
config.revalidate = Some(NextRevalidate::Frequency { config.revalidate = Some(NextRevalidate::Frequency {
seconds: val as u32, seconds: *val as u32,
}); });
} }
JsValue::Constant(ConstantValue::False) => { JsValue::Constant(ConstantValue::False) => {
......
...@@ -24,6 +24,7 @@ const_format = { workspace = true } ...@@ -24,6 +24,7 @@ const_format = { workspace = true }
data-encoding = { workspace = true } data-encoding = { workspace = true }
either = { workspace = true } either = { workspace = true }
indexmap = { workspace = true } indexmap = { workspace = true }
num-bigint = "0.4"
once_cell = { workspace = true } once_cell = { workspace = true }
patricia_tree = { version = "0.10.1", features = ["serde"] } patricia_tree = { version = "0.10.1", features = ["serde"] }
petgraph = { workspace = true, features = ["serde-1"] } petgraph = { workspace = true, features = ["serde-1"] }
......
use std::{
fmt::Display,
hash::{Hash, Hasher},
ops::Deref,
};
use anyhow::Result; use anyhow::Result;
use bincode::{Decode, Encode}; use bincode::{Decode, Encode};
use indexmap::Equivalent; use indexmap::Equivalent;
use num_bigint::BigInt;
use rustc_hash::FxHashSet; use rustc_hash::FxHashSet;
use smallvec::SmallVec; use smallvec::SmallVec;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
...@@ -108,12 +115,49 @@ macro_rules! free_var_references { ...@@ -108,12 +115,49 @@ macro_rules! free_var_references {
pub enum CompileTimeDefineValue { pub enum CompileTimeDefineValue {
Null, Null,
Bool(bool), Bool(bool),
Number(RcStr), Number(TotalOrderF64),
String(RcStr), String(RcStr),
BigInt(
#[bincode(with_serde)]
#[turbo_tasks(trace_ignore)]
Box<BigInt>,
),
Array(Vec<CompileTimeDefineValue>), Array(Vec<CompileTimeDefineValue>),
Object(Vec<(RcStr, CompileTimeDefineValue)>), Object(Vec<(RcStr, CompileTimeDefineValue)>),
Undefined, Undefined,
Evaluate(RcStr), Evaluate(RcStr),
Regex(RcStr, RcStr),
}
/// Wrapper around f64 that implements total Eq and Hash, based on total ordering.
#[derive(Debug, Copy, Clone, TraceRawVcs, NonLocalValue, Encode, Decode)]
pub struct TotalOrderF64(f64);
impl PartialEq for TotalOrderF64 {
fn eq(&self, other: &Self) -> bool {
self.0.total_cmp(&other.0) == std::cmp::Ordering::Equal
}
}
impl Eq for TotalOrderF64 {}
impl Hash for TotalOrderF64 {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.to_le_bytes().hash(state);
}
}
impl From<f64> for TotalOrderF64 {
fn from(value: f64) -> Self {
Self(value)
}
}
impl Deref for TotalOrderF64 {
type Target = f64;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl Display for TotalOrderF64 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
} }
impl From<bool> for CompileTimeDefineValue { impl From<bool> for CompileTimeDefineValue {
...@@ -145,7 +189,11 @@ impl From<serde_json::Value> for CompileTimeDefineValue { ...@@ -145,7 +189,11 @@ impl From<serde_json::Value> for CompileTimeDefineValue {
match value { match value {
serde_json::Value::Null => Self::Null, serde_json::Value::Null => Self::Null,
serde_json::Value::Bool(b) => Self::Bool(b), serde_json::Value::Bool(b) => Self::Bool(b),
serde_json::Value::Number(n) => Self::Number(n.to_string().into()), serde_json::Value::Number(n) => Self::Number(
n.as_f64()
.expect("unreachable: serde-json has arbitrary_precision disabled")
.into(),
),
serde_json::Value::String(s) => Self::String(s.into()), serde_json::Value::String(s) => Self::String(s.into()),
serde_json::Value::Array(a) => Self::Array(a.into_iter().map(|i| i.into()).collect()), serde_json::Value::Array(a) => Self::Array(a.into_iter().map(|i| i.into()).collect()),
serde_json::Value::Object(m) => { serde_json::Value::Object(m) => {
......
...@@ -102,9 +102,9 @@ pub fn replace_builtin(value: &mut JsValue) -> bool { ...@@ -102,9 +102,9 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
let JsValue::Constant(ConstantValue::Num(num)) = arg else { let JsValue::Constant(ConstantValue::Num(num)) = arg else {
return false; return false;
}; };
sum += num.0; sum += *num.0;
} }
*value = JsValue::Constant(ConstantValue::Num(ConstantNumber(sum))); *value = JsValue::Constant(ConstantValue::Num(sum.into()));
true true
} }
...@@ -403,7 +403,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool { ...@@ -403,7 +403,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
vec![ vec![
item, item,
JsValue::Constant(ConstantValue::Num( JsValue::Constant(ConstantValue::Num(
ConstantNumber(i as f64), (i as f64).into(),
)), )),
], ],
) )
......
...@@ -26,8 +26,7 @@ use turbo_tasks::ResolvedVc; ...@@ -26,8 +26,7 @@ use turbo_tasks::ResolvedVc;
use turbopack_core::{resolve::ExportUsage, source::Source}; use turbopack_core::{resolve::ExportUsage, source::Source};
use super::{ use super::{
ConstantNumber, ConstantValue, ImportMap, JsValue, ObjectPart, WellKnownFunctionKind, ConstantValue, ImportMap, JsValue, ObjectPart, WellKnownFunctionKind, is_unresolved_id,
is_unresolved_id,
}; };
use crate::{ use crate::{
AnalyzeMode, SpecifiedModuleType, AnalyzeMode, SpecifiedModuleType,
...@@ -519,8 +518,8 @@ impl EvalContext { ...@@ -519,8 +518,8 @@ impl EvalContext {
// model their values mostly useful for truthy/falsy checks. // model their values mostly useful for truthy/falsy checks.
match i.sym.as_str() { match i.sym.as_str() {
"undefined" => JsValue::Constant(ConstantValue::Undefined), "undefined" => JsValue::Constant(ConstantValue::Undefined),
"NaN" => JsValue::Constant(ConstantValue::Num(ConstantNumber(f64::NAN))), "NaN" => JsValue::Constant(ConstantValue::Num(f64::NAN.into())),
"Infinity" => JsValue::Constant(ConstantValue::Num(ConstantNumber(f64::INFINITY))), "Infinity" => JsValue::Constant(ConstantValue::Num(f64::INFINITY.into())),
_ => JsValue::FreeVar(i.sym.clone()), _ => JsValue::FreeVar(i.sym.clone()),
} }
} else { } else {
...@@ -868,7 +867,7 @@ impl EvalContext { ...@@ -868,7 +867,7 @@ impl EvalContext {
} }
} }
pub fn eval_single_expr_lit(expr_lit: RcStr) -> Result<JsValue> { pub fn eval_single_expr_lit(expr_lit: &RcStr) -> Result<JsValue> {
let cm = Lrc::new(SourceMap::default()); let cm = Lrc::new(SourceMap::default());
let js_value = try_with_handler(cm, Default::default(), |_| { let js_value = try_with_handler(cm, Default::default(), |_| {
...@@ -3181,9 +3180,7 @@ impl Analyzer<'_> { ...@@ -3181,9 +3180,7 @@ impl Analyzer<'_> {
for (idx, elem) in arr.elems.iter().enumerate() { for (idx, elem) in arr.elems.iter().enumerate() {
let pat_value = Some(JsValue::member( let pat_value = Some(JsValue::member(
Box::new(value.clone()), Box::new(value.clone()),
Box::new(JsValue::Constant(ConstantValue::Num(ConstantNumber( Box::new(JsValue::Constant(ConstantValue::Num((idx as f64).into()))),
idx as f64,
)))),
)); ));
self.with_pat_value(pat_value, |this| { self.with_pat_value(pat_value, |this| {
let mut ast_path = ast_path let mut ast_path = ast_path
......
...@@ -27,6 +27,7 @@ use turbo_rcstr::RcStr; ...@@ -27,6 +27,7 @@ use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, FxIndexSet, Vc}; use turbo_tasks::{FxIndexMap, FxIndexSet, Vc};
use turbopack_core::compile_time_info::{ use turbopack_core::compile_time_info::{
CompileTimeDefineValue, DefinableNameSegmentRef, DefinableNameSegmentRefs, FreeVarReference, CompileTimeDefineValue, DefinableNameSegmentRef, DefinableNameSegmentRefs, FreeVarReference,
TotalOrderF64,
}; };
use self::imports::ImportAnnotations; use self::imports::ImportAnnotations;
...@@ -57,44 +58,21 @@ impl Default for ObjectPart { ...@@ -57,44 +58,21 @@ impl Default for ObjectPart {
} }
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct ConstantNumber(pub f64); pub struct ConstantNumber(pub TotalOrderF64);
fn integer_decode(val: f64) -> (u64, i16, i8) {
let bits: u64 = val.to_bits();
let sign: i8 = if bits >> 63 == 0 { 1 } else { -1 };
let mut exponent: i16 = ((bits >> 52) & 0x7ff) as i16;
let mantissa = if exponent == 0 {
(bits & 0xfffffffffffff) << 1
} else {
(bits & 0xfffffffffffff) | 0x10000000000000
};
exponent -= 1023 + 52;
(mantissa, exponent, sign)
}
impl ConstantNumber { impl ConstantNumber {
pub fn as_u32_index(&self) -> Option<usize> { pub fn as_u32_index(&self) -> Option<usize> {
let index: u32 = self.0 as u32; let index: u32 = *self.0 as u32;
(index as f64 == self.0).then_some(index as usize) (index as f64 == *self.0).then_some(index as usize)
} }
} }
impl From<f64> for ConstantNumber {
impl Hash for ConstantNumber { fn from(value: f64) -> Self {
fn hash<H: Hasher>(&self, state: &mut H) { ConstantNumber(value.into())
integer_decode(self.0).hash(state);
}
}
impl PartialEq for ConstantNumber {
fn eq(&self, other: &Self) -> bool {
integer_decode(self.0) == integer_decode(other.0)
} }
} }
impl Eq for ConstantNumber {}
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum ConstantString { pub enum ConstantString {
Atom(Atom), Atom(Atom),
...@@ -206,7 +184,7 @@ impl ConstantValue { ...@@ -206,7 +184,7 @@ impl ConstantValue {
Self::Undefined | Self::False | Self::Null => false, Self::Undefined | Self::False | Self::Null => false,
Self::True | Self::Regex(..) => true, Self::True | Self::Regex(..) => true,
Self::Str(s) => !s.is_empty(), Self::Str(s) => !s.is_empty(),
Self::Num(ConstantNumber(n)) => *n != 0.0, Self::Num(ConstantNumber(n)) => **n != 0.0,
Self::BigInt(n) => !n.is_zero(), Self::BigInt(n) => !n.is_zero(),
} }
} }
...@@ -264,7 +242,7 @@ impl From<Lit> for ConstantValue { ...@@ -264,7 +242,7 @@ impl From<Lit> for ConstantValue {
} }
} }
Lit::Null(_) => ConstantValue::Null, Lit::Null(_) => ConstantValue::Null,
Lit::Num(v) => ConstantValue::Num(ConstantNumber(v.value)), Lit::Num(v) => ConstantValue::Num(ConstantNumber(v.value.into())),
Lit::BigInt(v) => ConstantValue::BigInt(v.value), Lit::BigInt(v) => ConstantValue::BigInt(v.value),
Lit::Regex(v) => ConstantValue::Regex(Box::new((v.exp, v.flags))), Lit::Regex(v) => ConstantValue::Regex(Box::new((v.exp, v.flags))),
Lit::JSXText(v) => ConstantValue::Str(ConstantString::Atom(v.value)), Lit::JSXText(v) => ConstantValue::Str(ConstantString::Atom(v.value)),
...@@ -553,7 +531,7 @@ impl From<Box<BigInt>> for JsValue { ...@@ -553,7 +531,7 @@ impl From<Box<BigInt>> for JsValue {
impl From<f64> for JsValue { impl From<f64> for JsValue {
fn from(v: f64) -> Self { fn from(v: f64) -> Self {
ConstantValue::Num(ConstantNumber(v)).into() ConstantValue::Num(ConstantNumber(v.into())).into()
} }
} }
...@@ -585,13 +563,16 @@ impl TryFrom<&CompileTimeDefineValue> for JsValue { ...@@ -585,13 +563,16 @@ impl TryFrom<&CompileTimeDefineValue> for JsValue {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(value: &CompileTimeDefineValue) -> Result<Self> { fn try_from(value: &CompileTimeDefineValue) -> Result<Self> {
match value { Ok(JsValue::Constant(match value {
CompileTimeDefineValue::Null => Ok(JsValue::Constant(ConstantValue::Null)), CompileTimeDefineValue::Undefined => ConstantValue::Undefined,
CompileTimeDefineValue::Bool(b) => Ok(JsValue::Constant((*b).into())), CompileTimeDefineValue::Null => ConstantValue::Null,
CompileTimeDefineValue::Number(n) => Ok(JsValue::Constant(ConstantValue::Num( CompileTimeDefineValue::Bool(b) => (*b).into(),
ConstantNumber(n.as_str().parse::<f64>()?), CompileTimeDefineValue::Number(n) => ConstantValue::Num(ConstantNumber(*n)),
))), CompileTimeDefineValue::BigInt(n) => ConstantValue::BigInt(n.clone()),
CompileTimeDefineValue::String(s) => Ok(JsValue::Constant(s.as_str().into())), CompileTimeDefineValue::String(s) => s.as_str().into(),
CompileTimeDefineValue::Regex(pattern, flags) => {
ConstantValue::Regex(Box::new((pattern.as_str().into(), flags.as_str().into())))
}
CompileTimeDefineValue::Array(a) => { CompileTimeDefineValue::Array(a) => {
let mut js_value = JsValue::Array { let mut js_value = JsValue::Array {
total_nodes: a.len() as u32, total_nodes: a.len() as u32,
...@@ -599,7 +580,7 @@ impl TryFrom<&CompileTimeDefineValue> for JsValue { ...@@ -599,7 +580,7 @@ impl TryFrom<&CompileTimeDefineValue> for JsValue {
mutable: false, mutable: false,
}; };
js_value.update_total_nodes(); js_value.update_total_nodes();
Ok(js_value) return Ok(js_value);
} }
CompileTimeDefineValue::Object(m) => { CompileTimeDefineValue::Object(m) => {
let mut js_value = JsValue::Object { let mut js_value = JsValue::Object {
...@@ -616,11 +597,32 @@ impl TryFrom<&CompileTimeDefineValue> for JsValue { ...@@ -616,11 +597,32 @@ impl TryFrom<&CompileTimeDefineValue> for JsValue {
mutable: false, mutable: false,
}; };
js_value.update_total_nodes(); js_value.update_total_nodes();
Ok(js_value) return Ok(js_value);
} }
CompileTimeDefineValue::Undefined => Ok(JsValue::Constant(ConstantValue::Undefined)), CompileTimeDefineValue::Evaluate(s) => {
CompileTimeDefineValue::Evaluate(s) => EvalContext::eval_single_expr_lit(s.clone()), return EvalContext::eval_single_expr_lit(s);
} }
}))
}
}
impl TryFrom<&ConstantValue> for CompileTimeDefineValue {
type Error = anyhow::Error;
fn try_from(value: &ConstantValue) -> Result<Self> {
Ok(match value {
ConstantValue::Undefined => CompileTimeDefineValue::Undefined,
ConstantValue::Null => CompileTimeDefineValue::Null,
ConstantValue::True => CompileTimeDefineValue::Bool(true),
ConstantValue::False => CompileTimeDefineValue::Bool(false),
ConstantValue::Num(n) => CompileTimeDefineValue::Number(n.0),
ConstantValue::Str(s) => CompileTimeDefineValue::String(s.as_rcstr()),
ConstantValue::BigInt(n) => CompileTimeDefineValue::BigInt(n.clone()),
ConstantValue::Regex(regex) => CompileTimeDefineValue::Regex(
RcStr::from(regex.0.as_str()),
RcStr::from(regex.1.as_str()),
),
})
} }
} }
......
...@@ -3,7 +3,9 @@ use bincode::{Decode, Encode}; ...@@ -3,7 +3,9 @@ use bincode::{Decode, Encode};
use swc_core::{ use swc_core::{
common::{DUMMY_SP, FileName, SourceMap, sync::Lrc}, common::{DUMMY_SP, FileName, SourceMap, sync::Lrc},
ecma::{ ecma::{
ast::{ArrayLit, EsVersion, Expr, KeyValueProp, ObjectLit, Prop, PropName, Str}, ast::{
ArrayLit, EsVersion, Expr, KeyValueProp, Lit, ObjectLit, Prop, PropName, Regex, Str,
},
parser::{Syntax, parse_file_as_expr}, parser::{Syntax, parse_file_as_expr},
}, },
quote, quote,
...@@ -37,8 +39,7 @@ impl ConstantValueCodeGen { ...@@ -37,8 +39,7 @@ impl ConstantValueCodeGen {
let value = self.value.clone(); let value = self.value.clone();
let visitor = create_visitor!(self.path, visit_mut_expr, |expr: &mut Expr| { let visitor = create_visitor!(self.path, visit_mut_expr, |expr: &mut Expr| {
// TODO: avoid this clone *expr = value_to_expr(&value);
*expr = define_env_to_expr((value).clone());
}); });
Ok(CodeGeneration::visitors(vec![visitor])) Ok(CodeGeneration::visitors(vec![visitor]))
...@@ -51,8 +52,11 @@ impl From<ConstantValueCodeGen> for CodeGen { ...@@ -51,8 +52,11 @@ impl From<ConstantValueCodeGen> for CodeGen {
} }
} }
fn define_env_to_expr(value: CompileTimeDefineValue) -> Expr { fn value_to_expr(value: &CompileTimeDefineValue) -> Expr {
match value { match value {
CompileTimeDefineValue::Undefined => {
quote!("(\"TURBOPACK compile-time value\", void 0)" as Expr)
}
CompileTimeDefineValue::Null => { CompileTimeDefineValue::Null => {
quote!("(\"TURBOPACK compile-time value\", null)" as Expr) quote!("(\"TURBOPACK compile-time value\", null)" as Expr)
} }
...@@ -62,28 +66,38 @@ fn define_env_to_expr(value: CompileTimeDefineValue) -> Expr { ...@@ -62,28 +66,38 @@ fn define_env_to_expr(value: CompileTimeDefineValue) -> Expr {
CompileTimeDefineValue::Bool(false) => { CompileTimeDefineValue::Bool(false) => {
quote!("(\"TURBOPACK compile-time value\", false)" as Expr) quote!("(\"TURBOPACK compile-time value\", false)" as Expr)
} }
CompileTimeDefineValue::Number(ref n) => { CompileTimeDefineValue::Number(n) => {
quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = n.parse::<f64>().unwrap().into()) quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = (**n).into())
}
CompileTimeDefineValue::String(s) => {
quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = s.as_str().into())
} }
CompileTimeDefineValue::String(ref s) => { CompileTimeDefineValue::BigInt(n) => {
quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = s.to_string().into()) quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = Expr::Lit(Lit::BigInt(n.as_ref().clone().into())))
}
CompileTimeDefineValue::Regex(pattern, flags) => {
quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = Expr::Lit(Lit::Regex(Regex {
span: DUMMY_SP,
exp: pattern.as_str().into(),
flags: flags.as_str().into(),
})))
} }
CompileTimeDefineValue::Array(a) => { CompileTimeDefineValue::Array(a) => {
quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = Expr::Array(ArrayLit { quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = Expr::Array(ArrayLit {
span: DUMMY_SP, span: DUMMY_SP,
elems: a.into_iter().map(|i| Some(define_env_to_expr(i).into())).collect(), elems: a.iter().map(|i| Some(value_to_expr(i).into())).collect(),
})) }))
} }
CompileTimeDefineValue::Object(m) => { CompileTimeDefineValue::Object(m) => {
quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = Expr::Object(ObjectLit { quote!("(\"TURBOPACK compile-time value\", $e)" as Expr, e: Expr = Expr::Object(ObjectLit {
span: DUMMY_SP, span: DUMMY_SP,
props: m props: m
.into_iter() .iter()
.map(|(k, v)| { .map(|(k, v)| {
swc_core::ecma::ast::PropOrSpread::Prop( swc_core::ecma::ast::PropOrSpread::Prop(
Prop::KeyValue(KeyValueProp { Prop::KeyValue(KeyValueProp {
key: PropName::Str(Str::from(k.as_str())), key: PropName::Str(Str::from(k.as_str())),
value: define_env_to_expr(v).into(), value: value_to_expr(v).into(),
}) })
.into(), .into(),
) )
...@@ -91,14 +105,11 @@ fn define_env_to_expr(value: CompileTimeDefineValue) -> Expr { ...@@ -91,14 +105,11 @@ fn define_env_to_expr(value: CompileTimeDefineValue) -> Expr {
.collect(), .collect(),
})) }))
} }
CompileTimeDefineValue::Undefined => { CompileTimeDefineValue::Evaluate(s) => parse_single_expr_lit(s),
quote!("(\"TURBOPACK compile-time value\", void 0)" as Expr)
}
CompileTimeDefineValue::Evaluate(ref s) => parse_single_expr_lit(s.clone()),
} }
} }
pub(crate) fn parse_single_expr_lit(expr_lit: RcStr) -> Expr { pub(crate) fn parse_single_expr_lit(expr_lit: &RcStr) -> Expr {
let cm = Lrc::new(SourceMap::default()); let cm = Lrc::new(SourceMap::default());
let fm = cm.new_source_file(FileName::Anon.into(), expr_lit.clone()); let fm = cm.new_source_file(FileName::Anon.into(), expr_lit.clone());
parse_file_as_expr( parse_file_as_expr(
......
...@@ -37,10 +37,12 @@ ...@@ -37,10 +37,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Concat( Concat(
3, 3,
[ [
......
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Variable( Variable(
( (
"y", "y",
......
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Str( Str(
Atom( Atom(
...@@ -323,10 +325,12 @@ ...@@ -323,10 +325,12 @@
prop: Constant( prop: Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
ast_path: [ ast_path: [
Program( Program(
Script, Script,
...@@ -366,10 +370,12 @@ ...@@ -366,10 +370,12 @@
prop: Constant( prop: Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
ast_path: [ ast_path: [
Program( Program(
Script, Script,
......
...@@ -4,11 +4,13 @@ ...@@ -4,11 +4,13 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
),
( (
"b", "b",
Constant( Constant(
...@@ -29,10 +31,12 @@ ...@@ -29,10 +31,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Str( Str(
Atom( Atom(
...@@ -66,10 +70,12 @@ ...@@ -66,10 +70,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Str( Str(
Atom( Atom(
...@@ -119,12 +125,14 @@ ...@@ -119,12 +125,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"d4", "d4",
Member( Member(
...@@ -138,12 +146,14 @@ ...@@ -138,12 +146,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"value#3", "value#3",
Iterated( Iterated(
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*anonymous function 339*", "*anonymous function 339*",
Function( Function(
...@@ -21,12 +23,14 @@ ...@@ -21,12 +23,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 11*", "*arrow function 11*",
Function( Function(
...@@ -35,12 +39,14 @@ ...@@ -35,12 +39,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 214*", "*arrow function 214*",
Function( Function(
...@@ -49,12 +55,14 @@ ...@@ -49,12 +55,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 236*", "*arrow function 236*",
Function( Function(
...@@ -63,12 +71,14 @@ ...@@ -63,12 +71,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 259*", "*arrow function 259*",
Function( Function(
...@@ -77,12 +87,14 @@ ...@@ -77,12 +87,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 299*", "*arrow function 299*",
Function( Function(
...@@ -91,12 +103,14 @@ ...@@ -91,12 +103,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 30*", "*arrow function 30*",
Function( Function(
...@@ -105,12 +119,14 @@ ...@@ -105,12 +119,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 50*", "*arrow function 50*",
Function( Function(
...@@ -119,12 +135,14 @@ ...@@ -119,12 +135,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 83*", "*arrow function 83*",
Function( Function(
...@@ -133,12 +151,14 @@ ...@@ -133,12 +151,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"a", "a",
Variable( Variable(
...@@ -192,12 +212,14 @@ ...@@ -192,12 +212,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
4.0, 4.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"f", "f",
Variable( Variable(
...@@ -261,12 +283,14 @@ ...@@ -261,12 +283,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
4.0, 4.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"xe#8", "xe#8",
Variable( Variable(
......
...@@ -41,10 +41,12 @@ ...@@ -41,10 +41,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
),
Unknown { Unknown {
original_value: None, original_value: None,
reason: "unsupported assign operation", reason: "unsupported assign operation",
...@@ -62,10 +64,12 @@ ...@@ -62,10 +64,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
),
Unknown { Unknown {
original_value: None, original_value: None,
reason: "updated with update expression", reason: "updated with update expression",
...@@ -83,17 +87,21 @@ ...@@ -83,17 +87,21 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
], ],
logical_property: None, logical_property: None,
}, },
...@@ -106,17 +114,21 @@ ...@@ -106,17 +114,21 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
], ],
logical_property: None, logical_property: None,
}, },
...@@ -129,17 +141,21 @@ ...@@ -129,17 +141,21 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
], ],
logical_property: None, logical_property: None,
}, },
......
...@@ -59,12 +59,14 @@ ...@@ -59,12 +59,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 468*", "*arrow function 468*",
Function( Function(
...@@ -125,12 +127,14 @@ ...@@ -125,12 +127,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 511*", "*arrow function 511*",
Function( Function(
...@@ -191,12 +195,14 @@ ...@@ -191,12 +195,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"*arrow function 554*", "*arrow function 554*",
Function( Function(
...@@ -257,12 +263,14 @@ ...@@ -257,12 +263,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"a", "a",
Alternatives { Alternatives {
...@@ -271,24 +279,30 @@ ...@@ -271,24 +279,30 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
),
Variable( Variable(
( (
"b", "b",
...@@ -307,24 +321,30 @@ ...@@ -307,24 +321,30 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
4.0, 4.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
5.0, 5.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
6.0, 6.0,
), ),
), ),
), ),
),
Variable( Variable(
( (
"c", "c",
...@@ -343,24 +363,30 @@ ...@@ -343,24 +363,30 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
7.0, 7.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
8.0, 8.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
9.0, 9.0,
), ),
), ),
), ),
),
Variable( Variable(
( (
"a", "a",
......
...@@ -51,11 +51,13 @@ ...@@ -51,11 +51,13 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
123.0, 123.0,
), ),
), ),
), ),
), ),
),
( (
"cc", "cc",
Variable( Variable(
......
...@@ -6135,11 +6135,13 @@ ...@@ -6135,11 +6135,13 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
493.0, 493.0,
), ),
), ),
), ),
), ),
),
], ],
ast_path: [ ast_path: [
Program( Program(
......
...@@ -111,12 +111,14 @@ ...@@ -111,12 +111,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"binPath", "binPath",
Alternatives { Alternatives {
...@@ -290,12 +292,14 @@ ...@@ -290,12 +292,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"e#10", "e#10",
Unknown { Unknown {
......
...@@ -90,12 +90,14 @@ ...@@ -90,12 +90,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"f", "f",
Member( Member(
...@@ -109,12 +111,14 @@ ...@@ -109,12 +111,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"x", "x",
Variable( Variable(
......
...@@ -90,12 +90,14 @@ ...@@ -90,12 +90,14 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
), ),
), ),
),
( (
"f", "f",
Member( Member(
...@@ -109,10 +111,12 @@ ...@@ -109,10 +111,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
), ),
),
] ]
...@@ -20,10 +20,12 @@ ...@@ -20,10 +20,12 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
),
Unknown { Unknown {
original_value: None, original_value: None,
reason: "updated with update expression", reason: "updated with update expression",
......
...@@ -104,20 +104,24 @@ ...@@ -104,20 +104,24 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
),
Value( Value(
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
),
], ],
ast_path: [ ast_path: [
Program( Program(
...@@ -391,20 +395,24 @@ ...@@ -391,20 +395,24 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
),
Value( Value(
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
), ),
),
], ],
ast_path: [ ast_path: [
Program( Program(
...@@ -539,20 +547,24 @@ ...@@ -539,20 +547,24 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
), ),
),
Value( Value(
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
), ),
),
], ],
ast_path: [ ast_path: [
Program( Program(
......
...@@ -71,24 +71,30 @@ ...@@ -71,24 +71,30 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
),
FreeVar( FreeVar(
"global", "global",
), ),
...@@ -108,17 +114,21 @@ ...@@ -108,17 +114,21 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
FreeVar( FreeVar(
"global", "global",
), ),
...@@ -127,17 +137,21 @@ ...@@ -127,17 +137,21 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
4.0, 4.0,
), ),
), ),
), ),
),
], ],
), ),
), ),
...@@ -177,34 +191,42 @@ ...@@ -177,34 +191,42 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
FreeVar( FreeVar(
"global", "global",
), ),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
3.0, 3.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
4.0, 4.0,
), ),
), ),
), ),
),
], ],
), ),
), ),
...@@ -217,34 +239,42 @@ ...@@ -217,34 +239,42 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
2.0, 2.0,
), ),
), ),
), ),
),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
0.0, 0.0,
), ),
), ),
), ),
),
FreeVar( FreeVar(
"global", "global",
), ),
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
4.0, 4.0,
), ),
), ),
), ),
),
], ],
), ),
), ),
......
...@@ -181,11 +181,13 @@ ...@@ -181,11 +181,13 @@
Constant( Constant(
Num( Num(
ConstantNumber( ConstantNumber(
TotalOrderF64(
1.0, 1.0,
), ),
), ),
), ),
), ),
),
], ],
ast_path: [ ast_path: [
Program( Program(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment