jit works
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::eval::PrimitiveType;
|
||||
use crate::ir::{Expression, Primitive, Program, TopLevel, Type, Value, ValueOrRef, Variable};
|
||||
use crate::ir::{Expression, Primitive, Program, TopLevel, Type, TypeWithVoid, Value, ValueOrRef, Variable};
|
||||
use crate::syntax::Location;
|
||||
use crate::util::scoped_map::ScopedMap;
|
||||
use proptest::strategy::{NewTree, Strategy, ValueTree};
|
||||
@@ -288,14 +288,25 @@ fn generate_random_expression(
|
||||
ExpressionType::Block => {
|
||||
let num_stmts = BLOCK_LENGTH_DISTRIBUTION.sample(rng);
|
||||
let mut stmts = Vec::new();
|
||||
let mut last_type = Type::Primitive(PrimitiveType::Void);
|
||||
|
||||
if num_stmts == 0 {
|
||||
return Expression::Block(Location::manufactured(), Type::void(), stmts);
|
||||
}
|
||||
|
||||
env.new_scope();
|
||||
for _ in 0..num_stmts {
|
||||
let next = generate_random_expression(rng, env);
|
||||
last_type = next.type_of();
|
||||
for _ in 1..num_stmts {
|
||||
let mut next = generate_random_expression(rng, env);
|
||||
let next_type = next.type_of();
|
||||
if !next_type.is_void() {
|
||||
let name = generate_random_name(rng);
|
||||
env.insert(name.clone(), next_type.clone());
|
||||
next = Expression::Bind(Location::manufactured(), name, next_type, Box::new(next));
|
||||
}
|
||||
stmts.push(next);
|
||||
}
|
||||
let last_expr = generate_random_expression(rng, env);
|
||||
let last_type = last_expr.type_of();
|
||||
stmts.push(last_expr);
|
||||
env.release_scope();
|
||||
|
||||
Expression::Block(Location::manufactured(), last_type, stmts)
|
||||
|
||||
Reference in New Issue
Block a user