Merge branch 'master' into boxing_improvements

This commit is contained in:
Collin Chin 2020-10-21 00:51:49 -07:00 committed by GitHub
commit 3c0409da16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 1694 additions and 43 deletions

View File

@ -16,22 +16,18 @@
use leo_ast::LeoAst; use leo_ast::LeoAst;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{criterion_group, criterion_main, Criterion};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
fn leo_ast<'ast>(filepath: &'ast PathBuf, program_string: &'ast str) { fn leo_ast<'ast>(filepath: &'ast PathBuf, program_string: &'ast str) -> LeoAst<'ast> {
let result = LeoAst::<'ast>::new(filepath, program_string).unwrap(); LeoAst::<'ast>::new(filepath, program_string).unwrap()
black_box(result);
} }
fn criterion_benchmark(c: &mut Criterion) { fn criterion_benchmark(c: &mut Criterion) {
let filepath = Path::new("./main.leo").to_path_buf(); let filepath = Path::new("./main.leo").to_path_buf();
// let program_string = &LeoAst::load_file(&filepath).unwrap();
let program_string = include_str!("./main.leo"); let program_string = include_str!("./main.leo");
c.bench_function("LeoAst::new", |b| { c.bench_function("LeoAst::new", |b| b.iter(|| leo_ast(&filepath, program_string)));
b.iter(|| leo_ast(black_box(&filepath), black_box(program_string)))
});
} }
criterion_group!(benches, criterion_benchmark); criterion_group!(benches, criterion_benchmark);

View File

@ -1,3 +1,26 @@
function main() { circuit PedersenHash {
return 1 + 1 parameters: [group; 256],
// Instantiates a Pedersen hash circuit
static function new(parameters: [group; 256]) -> Self {
return Self { parameters: parameters }
}
function hash(bits: [bool; 256]) -> group {
let mut digest: group = 0;
for i in 0..256 {
if bits[i] {
digest += self.parameters[i];
}
}
return digest
}
}
// The 'pedersen-hash' main function.
function main() -> group {
const parameters = [1group; 256];
const pedersen = PedersenHash::new(parameters);
let hash_input: [bool; 256] = [true; 256];
return pedersen.hash(hash_input)
} }

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{ast::Rule, expressions::TupleExpression, SpanDef}; use crate::{ast::Rule, expressions::Expression, SpanDef};
use pest::Span; use pest::Span;
use pest_ast::FromPest; use pest_ast::FromPest;
@ -23,7 +23,7 @@ use serde::Serialize;
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
#[pest_ast(rule(Rule::access_call))] #[pest_ast(rule(Rule::access_call))]
pub struct CallAccess<'ast> { pub struct CallAccess<'ast> {
pub expressions: TupleExpression<'ast>, pub expressions: Vec<Expression<'ast>>,
#[pest_ast(outer())] #[pest_ast(outer())]
#[serde(with = "SpanDef")] #[serde(with = "SpanDef")]
pub span: Span<'ast>, pub span: Span<'ast>,

View File

@ -159,8 +159,7 @@ impl<'ast> FromPest<'ast> for Expression<'ast> {
type Rule = Rule; type Rule = Rule;
fn from_pest(pest: &mut Pairs<'ast, Rule>) -> Result<Self, ConversionError<Void>> { fn from_pest(pest: &mut Pairs<'ast, Rule>) -> Result<Self, ConversionError<Void>> {
let mut clone = pest.clone(); let pair = pest.peek().ok_or(::from_pest::ConversionError::NoMatch)?;
let pair = clone.next().ok_or(::from_pest::ConversionError::NoMatch)?;
match pair.as_rule() { match pair.as_rule() {
Rule::expression => { Rule::expression => {
// Transfer iterated state to pest. // Transfer iterated state to pest.

View File

@ -226,7 +226,7 @@ dimension_single = {
// Declared in types/array_dimensions.rs // Declared in types/array_dimensions.rs
dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"} dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"}
type_tuple = { "(" ~ NEWLINE* ~ type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","? ~ NEWLINE* ~ ")" } type_tuple = { "(" ~ NEWLINE* ~ (type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","?)? ~ NEWLINE* ~ ")" }
/// Values /// Values
@ -302,7 +302,7 @@ access_tuple = ${ "." ~ number_positive }
access_assignee = { access_array | access_tuple | access_member } access_assignee = { access_array | access_tuple | access_member }
// Declared in access/call_access.rs // Declared in access/call_access.rs
access_call = !{ expression_tuple } access_call = !{ "(" ~ (expression ~ ("," ~ expression)*)? ~ ")" }
// Declared in access/member_access.rs // Declared in access/member_access.rs
access_member = ${ "." ~ identifier } access_member = ${ "." ~ identifier }
@ -351,7 +351,7 @@ expression_term = {
expression = { expression_term ~ (operation_binary ~ expression_term)* } expression = { expression_term ~ (operation_binary ~ expression_term)* }
// Declared in expressions/expression_tuple.rs // Declared in expressions/expression_tuple.rs
expression_tuple = { "(" ~ (expression ~ ("," ~ expression)*)? ~ ")" } expression_tuple = { "(" ~ (expression ~ ("," ~ expression)+)? ~ ")" }
// Declared in expressions/array_initializer_expression.rs // Declared in expressions/array_initializer_expression.rs
expression_array_initializer = { "[" ~ expression ~ ";" ~ array_dimensions ~ "]" } expression_array_initializer = { "[" ~ expression ~ ";" ~ array_dimensions ~ "]" }

View File

@ -21,7 +21,7 @@ extern crate pest_derive;
#[macro_use] #[macro_use]
extern crate thiserror; extern crate thiserror;
mod ast; pub mod ast;
pub mod access; pub mod access;
pub mod annotations; pub mod annotations;

39
ast/tests/expression.rs Normal file
View File

@ -0,0 +1,39 @@
use leo_ast::ast::{LanguageParser, Rule};
use pest::*;
#[test]
fn redundant_parens() {
parses_to! {
parser: LanguageParser,
input: "(true)",
rule: Rule::expression,
tokens: [
expression(0, 6, [
expression_term(0, 6, [expression(1, 5, [expression_term(1, 5, [value(1, 5, [value_boolean(1, 5, [])])])])])
])
]
}
}
#[test]
fn multiple_redundant_parens() {
parses_to! {
parser: LanguageParser,
input: "(((true)))",
rule: Rule::expression,
tokens: [
expression(0, 10, [
expression_term(0, 10, [
expression(1, 9, [expression_term(1, 9, [
expression(2, 8, [expression_term(2, 8, [
expression(3, 7, [expression_term(3, 7, [
value(3, 7, [value_boolean(3, 7, [])])
])])
])])
])])
])
])
]
}
}

115
ast/tests/function.rs Normal file
View File

@ -0,0 +1,115 @@
use leo_ast::ast::{LanguageParser, Rule};
use pest::*;
#[test]
fn call_wo_args() {
parses_to! {
parser: LanguageParser,
input: "x()",
rule: Rule::expression_postfix,
tokens: [
expression_postfix(0, 3, [
keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]),
access(1, 3, [access_call(1, 3, [])])
])
]
}
}
#[test]
fn call_with_arg() {
parses_to! {
parser: LanguageParser,
input: "x(true)",
rule: Rule::expression_postfix,
tokens: [
expression_postfix(0, 7, [
keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]),
access(1, 7, [access_call(1, 7, [
expression(2, 6, [expression_term(2, 6, [value(2, 6, [value_boolean(2, 6, [])])])])
])])
])
]
}
}
#[test]
fn call_with_2_args() {
parses_to! {
parser: LanguageParser,
input: "x(true, false)",
rule: Rule::expression_postfix,
tokens: [
expression_postfix(0, 14, [
keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]),
access(1, 14, [access_call(1, 14, [
expression(2, 6, [expression_term(2, 6, [value(2, 6, [value_boolean(2, 6, [])])])]),
expression(8, 13, [expression_term(8, 13, [value(8, 13, [value_boolean(8, 13, [])])])])
])])
])
]
}
}
#[test]
fn empty_def() {
parses_to! {
parser: LanguageParser,
input: "function x() {}",
rule: Rule::function,
tokens: [
function(0, 15, [identifier(9, 10, [])])
]
}
}
#[test]
fn returning_unit_type() {
parses_to! {
parser: LanguageParser,
input: "function x() -> () {}",
rule: Rule::function,
tokens: [
function(0, 21, [identifier(9, 10, []), type_(16, 18, [type_tuple(16, 18, [])])])
]
}
}
#[test]
fn returning_unit_value() {
parses_to! {
parser: LanguageParser,
input: "function x() { return () }",
rule: Rule::function,
tokens: [
function(0, 26, [identifier(9, 10, []), statement(15, 25, [
statement_return(15, 25, [expression(22, 25, [expression_term(22, 24, [expression_tuple(22, 24, [])])])])
])])
]
}
}
#[test]
fn id_def() {
parses_to! {
parser: LanguageParser,
input: "function id(x: u8) -> u8 { return x }",
rule: Rule::function,
tokens: [
function(0, 37, [
identifier(9, 11, []),
input(12, 17, [
function_input(12, 17, [
identifier(12, 13, []),
type_(15, 17, [type_data(15, 17, [type_integer(15, 17, [type_integer_unsigned(15, 17, [type_u8(15, 17, [])])])])])
])
]),
type_(22, 24, [type_data(22, 24, [type_integer(22, 24, [type_integer_unsigned(22, 24, [type_u8(22, 24, [])])])])]),
statement(27, 36, [statement_return(27, 36, [
expression(34, 36, [expression_term(34, 35, [identifier(34, 35, [])])])
])])
])
]
}
}

View File

@ -14,4 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>. // along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
mod expression;
mod function;
mod serialization; mod serialization;
mod tuple;

91
ast/tests/tuple.rs Normal file
View File

@ -0,0 +1,91 @@
use leo_ast::ast::{LanguageParser, Rule};
use pest::*;
#[test]
fn implicitly_typed() {
parses_to! {
parser: LanguageParser,
input: "(true, false)",
rule: Rule::expression_tuple,
tokens: [
expression_tuple(0, 13, [
expression(1, 5, [expression_term(1, 5, [value(1, 5, [value_boolean(1, 5, [])])])]),
expression(7, 12, [expression_term(7, 12, [value(7, 12, [value_boolean(7, 12, [])])])])
])
]
}
}
#[test]
fn explicitly_typed() {
parses_to! {
parser: LanguageParser,
input: "let tup: (bool, bool) = (true, false);",
rule: Rule::statement_definition,
tokens: [
statement_definition(0, 38, [
declare(0, 4, [let_(0, 4, [])]),
variables(4, 21, [
variable_name(4, 7, [identifier(4, 7, [])]),
type_(9, 21, [type_tuple(9, 21, [
type_(10, 14, [type_data(10, 14, [type_boolean(10, 14, [])])]),
type_(16, 20, [type_data(16, 20, [type_boolean(16, 20, [])])]),
])])
]),
expression(24, 37, [expression_term(24, 37, [expression_tuple(24, 37, [
expression(25, 29, [expression_term(25, 29, [value(25, 29, [value_boolean(25, 29, [])])])]),
expression(31, 36, [expression_term(31, 36, [value(31, 36, [value_boolean(31, 36, [])])])]),
])])]),
LINE_END(37, 38, [])
])
]
}
}
#[test]
fn access() {
parses_to! {
parser: LanguageParser,
input: "x.0",
rule: Rule::expression_postfix,
tokens: [
expression_postfix(0, 3, [
keyword_or_identifier(0, 1, [self_keyword_or_identifier(0, 1, [identifier(0, 1, [])])]),
access(1, 3, [access_tuple(1, 3, [number_positive(2, 3, [])])])
])
]
}
}
#[test]
fn implicit_unit() {
parses_to! {
parser: LanguageParser,
input: "()",
rule: Rule::expression_tuple,
tokens: [
expression_tuple(0, 2, [])
]
}
}
#[test]
fn explicit_unit() {
parses_to! {
parser: LanguageParser,
input: "let x: () = ();",
rule: Rule::statement_definition,
tokens: [
statement_definition(0, 15, [
declare(0, 4, [let_(0, 4, [])]),
variables(4, 9, [
variable_name(4, 5, [identifier(4, 5, [])]),
type_(7, 9, [type_tuple(7, 9, [])])
]),
expression(12, 14, [expression_term(12, 14, [expression_tuple(12, 14, [])])]),
LINE_END(14, 15, [])
])
]
}
}

View File

@ -54,7 +54,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
Expression::Address(address, span) => Ok(ConstrainedValue::Address(Address::constant(address, span)?)), Expression::Address(address, span) => Ok(ConstrainedValue::Address(Address::constant(address, span)?)),
Expression::Boolean(boolean, span) => Ok(ConstrainedValue::Boolean(new_bool_constant(boolean, span)?)), Expression::Boolean(boolean, span) => Ok(ConstrainedValue::Boolean(new_bool_constant(boolean, span)?)),
Expression::Field(field, span) => Ok(ConstrainedValue::Field(FieldType::constant(field, span)?)), Expression::Field(field, span) => Ok(ConstrainedValue::Field(FieldType::constant(field, span)?)),
Expression::Group(group_element) => Ok(ConstrainedValue::Group(G::constant(group_element)?)), Expression::Group(group_element) => Ok(ConstrainedValue::Group(G::constant(*group_element)?)),
Expression::Implicit(value, span) => Ok(enforce_number_implicit(expected_type, value, span)?), Expression::Implicit(value, span) => Ok(enforce_number_implicit(expected_type, value, span)?),
Expression::Integer(type_, integer, span) => { Expression::Integer(type_, integer, span) => {
Ok(ConstrainedValue::Integer(Integer::new_constant(&type_, integer, span)?)) Ok(ConstrainedValue::Integer(Integer::new_constant(&type_, integer, span)?))

View File

@ -0,0 +1,265 @@
function main() {
let foo = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 };
let bar = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 };
return foo.x0 + bar.x255
}
circuit Foo {
x0: u8,
x1: u8,
x2: u8,
x3: u8,
x4: u8,
x5: u8,
x6: u8,
x7: u8,
x8: u8,
x9: u8,
x10: u8,
x11: u8,
x12: u8,
x13: u8,
x14: u8,
x15: u8,
x16: u8,
x17: u8,
x18: u8,
x19: u8,
x20: u8,
x21: u8,
x22: u8,
x23: u8,
x24: u8,
x25: u8,
x26: u8,
x27: u8,
x28: u8,
x29: u8,
x30: u8,
x31: u8,
x32: u8,
x33: u8,
x34: u8,
x35: u8,
x36: u8,
x37: u8,
x38: u8,
x39: u8,
x40: u8,
x41: u8,
x42: u8,
x43: u8,
x44: u8,
x45: u8,
x46: u8,
x47: u8,
x48: u8,
x49: u8,
x50: u8,
x51: u8,
x52: u8,
x53: u8,
x54: u8,
x55: u8,
x56: u8,
x57: u8,
x58: u8,
x59: u8,
x60: u8,
x61: u8,
x62: u8,
x63: u8,
x64: u8,
x65: u8,
x66: u8,
x67: u8,
x68: u8,
x69: u8,
x70: u8,
x71: u8,
x72: u8,
x73: u8,
x74: u8,
x75: u8,
x76: u8,
x77: u8,
x78: u8,
x79: u8,
x80: u8,
x81: u8,
x82: u8,
x83: u8,
x84: u8,
x85: u8,
x86: u8,
x87: u8,
x88: u8,
x89: u8,
x90: u8,
x91: u8,
x92: u8,
x93: u8,
x94: u8,
x95: u8,
x96: u8,
x97: u8,
x98: u8,
x99: u8,
x100: u8,
x101: u8,
x102: u8,
x103: u8,
x104: u8,
x105: u8,
x106: u8,
x107: u8,
x108: u8,
x109: u8,
x110: u8,
x111: u8,
x112: u8,
x113: u8,
x114: u8,
x115: u8,
x116: u8,
x117: u8,
x118: u8,
x119: u8,
x120: u8,
x121: u8,
x122: u8,
x123: u8,
x124: u8,
x125: u8,
x126: u8,
x127: u8,
x128: u8,
x129: u8,
x130: u8,
x131: u8,
x132: u8,
x133: u8,
x134: u8,
x135: u8,
x136: u8,
x137: u8,
x138: u8,
x139: u8,
x140: u8,
x141: u8,
x142: u8,
x143: u8,
x144: u8,
x145: u8,
x146: u8,
x147: u8,
x148: u8,
x149: u8,
x150: u8,
x151: u8,
x152: u8,
x153: u8,
x154: u8,
x155: u8,
x156: u8,
x157: u8,
x158: u8,
x159: u8,
x160: u8,
x161: u8,
x162: u8,
x163: u8,
x164: u8,
x165: u8,
x166: u8,
x167: u8,
x168: u8,
x169: u8,
x170: u8,
x171: u8,
x172: u8,
x173: u8,
x174: u8,
x175: u8,
x176: u8,
x177: u8,
x178: u8,
x179: u8,
x180: u8,
x181: u8,
x182: u8,
x183: u8,
x184: u8,
x185: u8,
x186: u8,
x187: u8,
x188: u8,
x189: u8,
x190: u8,
x191: u8,
x192: u8,
x193: u8,
x194: u8,
x195: u8,
x196: u8,
x197: u8,
x198: u8,
x199: u8,
x200: u8,
x201: u8,
x202: u8,
x203: u8,
x204: u8,
x205: u8,
x206: u8,
x207: u8,
x208: u8,
x209: u8,
x210: u8,
x211: u8,
x212: u8,
x213: u8,
x214: u8,
x215: u8,
x216: u8,
x217: u8,
x218: u8,
x219: u8,
x220: u8,
x221: u8,
x222: u8,
x223: u8,
x224: u8,
x225: u8,
x226: u8,
x227: u8,
x228: u8,
x229: u8,
x230: u8,
x231: u8,
x232: u8,
x233: u8,
x234: u8,
x235: u8,
x236: u8,
x237: u8,
x238: u8,
x239: u8,
x240: u8,
x241: u8,
x242: u8,
x243: u8,
x244: u8,
x245: u8,
x246: u8,
x247: u8,
x248: u8,
x249: u8,
x250: u8,
x251: u8,
x252: u8,
x253: u8,
x254: u8,
x255: u8
}

View File

@ -0,0 +1,389 @@
function main() {
let x: u8 = 191;
if x == 0 {
return x
} else if x == 1 {
return x - 1
} else if x == 2 {
return x - 2
} else if x == 3 {
return x - 3
} else if x == 4 {
return x - 4
} else if x == 5 {
return x - 5
} else if x == 6 {
return x - 6
} else if x == 7 {
return x - 7
} else if x == 8 {
return x - 8
} else if x == 9 {
return x - 9
} else if x == 10 {
return x - 10
} else if x == 11 {
return x - 11
} else if x == 12 {
return x - 12
} else if x == 13 {
return x - 13
} else if x == 14 {
return x - 14
} else if x == 15 {
return x - 15
} else if x == 16 {
return x - 16
} else if x == 17 {
return x - 17
} else if x == 18 {
return x - 18
} else if x == 19 {
return x - 19
} else if x == 20 {
return x - 20
} else if x == 21 {
return x - 21
} else if x == 22 {
return x - 22
} else if x == 23 {
return x - 23
} else if x == 24 {
return x - 24
} else if x == 25 {
return x - 25
} else if x == 26 {
return x - 26
} else if x == 27 {
return x - 27
} else if x == 28 {
return x - 28
} else if x == 29 {
return x - 29
} else if x == 30 {
return x - 30
} else if x == 31 {
return x - 31
} else if x == 32 {
return x - 32
} else if x == 33 {
return x - 33
} else if x == 34 {
return x - 34
} else if x == 35 {
return x - 35
} else if x == 36 {
return x - 36
} else if x == 37 {
return x - 37
} else if x == 38 {
return x - 38
} else if x == 39 {
return x - 39
} else if x == 40 {
return x - 40
} else if x == 41 {
return x - 41
} else if x == 42 {
return x - 42
} else if x == 43 {
return x - 43
} else if x == 44 {
return x - 44
} else if x == 45 {
return x - 45
} else if x == 46 {
return x - 46
} else if x == 47 {
return x - 47
} else if x == 48 {
return x - 48
} else if x == 49 {
return x - 49
} else if x == 50 {
return x - 50
} else if x == 51 {
return x - 51
} else if x == 52 {
return x - 52
} else if x == 53 {
return x - 53
} else if x == 54 {
return x - 54
} else if x == 55 {
return x - 55
} else if x == 56 {
return x - 56
} else if x == 57 {
return x - 57
} else if x == 58 {
return x - 58
} else if x == 59 {
return x - 59
} else if x == 60 {
return x - 60
} else if x == 61 {
return x - 61
} else if x == 62 {
return x - 62
} else if x == 63 {
return x - 63
} else if x == 64 {
return x - 64
} else if x == 65 {
return x - 65
} else if x == 66 {
return x - 66
} else if x == 67 {
return x - 67
} else if x == 68 {
return x - 68
} else if x == 69 {
return x - 69
} else if x == 70 {
return x - 70
} else if x == 71 {
return x - 71
} else if x == 72 {
return x - 72
} else if x == 73 {
return x - 73
} else if x == 74 {
return x - 74
} else if x == 75 {
return x - 75
} else if x == 76 {
return x - 76
} else if x == 77 {
return x - 77
} else if x == 78 {
return x - 78
} else if x == 79 {
return x - 79
} else if x == 80 {
return x - 80
} else if x == 81 {
return x - 81
} else if x == 82 {
return x - 82
} else if x == 83 {
return x - 83
} else if x == 84 {
return x - 84
} else if x == 85 {
return x - 85
} else if x == 86 {
return x - 86
} else if x == 87 {
return x - 87
} else if x == 88 {
return x - 88
} else if x == 89 {
return x - 89
} else if x == 90 {
return x - 90
} else if x == 91 {
return x - 91
} else if x == 92 {
return x - 92
} else if x == 93 {
return x - 93
} else if x == 94 {
return x - 94
} else if x == 95 {
return x - 95
} else if x == 96 {
return x - 96
} else if x == 97 {
return x - 97
} else if x == 98 {
return x - 98
} else if x == 99 {
return x - 99
} else if x == 100 {
return x - 100
} else if x == 101 {
return x - 101
} else if x == 102 {
return x - 102
} else if x == 103 {
return x - 103
} else if x == 104 {
return x - 104
} else if x == 105 {
return x - 105
} else if x == 106 {
return x - 106
} else if x == 107 {
return x - 107
} else if x == 108 {
return x - 108
} else if x == 109 {
return x - 109
} else if x == 110 {
return x - 110
} else if x == 111 {
return x - 111
} else if x == 112 {
return x - 112
} else if x == 113 {
return x - 113
} else if x == 114 {
return x - 114
} else if x == 115 {
return x - 115
} else if x == 116 {
return x - 116
} else if x == 117 {
return x - 117
} else if x == 118 {
return x - 118
} else if x == 119 {
return x - 119
} else if x == 120 {
return x - 120
} else if x == 121 {
return x - 121
} else if x == 122 {
return x - 122
} else if x == 123 {
return x - 123
} else if x == 124 {
return x - 124
} else if x == 125 {
return x - 125
} else if x == 126 {
return x - 126
} else if x == 127 {
return x - 127
} else if x == 128 {
return x - 128
} else if x == 129 {
return x - 129
} else if x == 130 {
return x - 130
} else if x == 131 {
return x - 131
} else if x == 132 {
return x - 132
} else if x == 133 {
return x - 133
} else if x == 134 {
return x - 134
} else if x == 135 {
return x - 135
} else if x == 136 {
return x - 136
} else if x == 137 {
return x - 137
} else if x == 138 {
return x - 138
} else if x == 139 {
return x - 139
} else if x == 140 {
return x - 140
} else if x == 141 {
return x - 141
} else if x == 142 {
return x - 142
} else if x == 143 {
return x - 143
} else if x == 144 {
return x - 144
} else if x == 145 {
return x - 145
} else if x == 146 {
return x - 146
} else if x == 147 {
return x - 147
} else if x == 148 {
return x - 148
} else if x == 149 {
return x - 149
} else if x == 150 {
return x - 150
} else if x == 151 {
return x - 151
} else if x == 152 {
return x - 152
} else if x == 153 {
return x - 153
} else if x == 154 {
return x - 154
} else if x == 155 {
return x - 155
} else if x == 156 {
return x - 156
} else if x == 157 {
return x - 157
} else if x == 158 {
return x - 158
} else if x == 159 {
return x - 159
} else if x == 160 {
return x - 160
} else if x == 161 {
return x - 161
} else if x == 162 {
return x - 162
} else if x == 163 {
return x - 163
} else if x == 164 {
return x - 164
} else if x == 165 {
return x - 165
} else if x == 166 {
return x - 166
} else if x == 167 {
return x - 167
} else if x == 168 {
return x - 168
} else if x == 169 {
return x - 169
} else if x == 170 {
return x - 170
} else if x == 171 {
return x - 171
} else if x == 172 {
return x - 172
} else if x == 173 {
return x - 173
} else if x == 174 {
return x - 174
} else if x == 175 {
return x - 175
} else if x == 176 {
return x - 176
} else if x == 177 {
return x - 177
} else if x == 178 {
return x - 178
} else if x == 179 {
return x - 179
} else if x == 180 {
return x - 180
} else if x == 181 {
return x - 181
} else if x == 182 {
return x - 182
} else if x == 183 {
return x - 183
} else if x == 184 {
return x - 184
} else if x == 185 {
return x - 185
} else if x == 186 {
return x - 186
} else if x == 187 {
return x - 187
} else if x == 188 {
return x - 188
} else if x == 189 {
return x - 189
} else if x == 190 {
return x - 190
} else if x == 191 {
return x - 191
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,57 @@
function main() {
let arr1: [u8; (32, 32)] = [
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31]
];
let arr2: [u8; (16, 32)] = [
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31]
];
return arr1[31][31] + arr2[15][31]
}

View File

@ -0,0 +1,9 @@
function main() {
let a = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1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 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1;
return a + b + c + d + e
}

View File

@ -1,3 +0,0 @@
function main() {
return 1 + 1
}

View File

@ -0,0 +1,388 @@
function main() {
let x0: u8 = 0;
let x1: u8 = x0;
let x2: u8 = x1;
let x3: u8 = x2;
let x4: u8 = x3;
let x5: u8 = x4;
let x6: u8 = x5;
let x7: u8 = x6;
let x8: u8 = x7;
let x9: u8 = x8;
let x10: u8 = x9;
let x11: u8 = x10;
let x12: u8 = x11;
let x13: u8 = x12;
let x14: u8 = x13;
let x15: u8 = x14;
let x16: u8 = x15;
let x17: u8 = x16;
let x18: u8 = x17;
let x19: u8 = x18;
let x20: u8 = x19;
let x21: u8 = x20;
let x22: u8 = x21;
let x23: u8 = x22;
let x24: u8 = x23;
let x25: u8 = x24;
let x26: u8 = x25;
let x27: u8 = x26;
let x28: u8 = x27;
let x29: u8 = x28;
let x30: u8 = x29;
let x31: u8 = x30;
let x32: u8 = x31;
let x33: u8 = x32;
let x34: u8 = x33;
let x35: u8 = x34;
let x36: u8 = x35;
let x37: u8 = x36;
let x38: u8 = x37;
let x39: u8 = x38;
let x40: u8 = x39;
let x41: u8 = x40;
let x42: u8 = x41;
let x43: u8 = x42;
let x44: u8 = x43;
let x45: u8 = x44;
let x46: u8 = x45;
let x47: u8 = x46;
let x48: u8 = x47;
let x49: u8 = x48;
let x50: u8 = x49;
let x51: u8 = x50;
let x52: u8 = x51;
let x53: u8 = x52;
let x54: u8 = x53;
let x55: u8 = x54;
let x56: u8 = x55;
let x57: u8 = x56;
let x58: u8 = x57;
let x59: u8 = x58;
let x60: u8 = x59;
let x61: u8 = x60;
let x62: u8 = x61;
let x63: u8 = x62;
let x64: u8 = x63;
let x65: u8 = x64;
let x66: u8 = x65;
let x67: u8 = x66;
let x68: u8 = x67;
let x69: u8 = x68;
let x70: u8 = x69;
let x71: u8 = x70;
let x72: u8 = x71;
let x73: u8 = x72;
let x74: u8 = x73;
let x75: u8 = x74;
let x76: u8 = x75;
let x77: u8 = x76;
let x78: u8 = x77;
let x79: u8 = x78;
let x80: u8 = x79;
let x81: u8 = x80;
let x82: u8 = x81;
let x83: u8 = x82;
let x84: u8 = x83;
let x85: u8 = x84;
let x86: u8 = x85;
let x87: u8 = x86;
let x88: u8 = x87;
let x89: u8 = x88;
let x90: u8 = x89;
let x91: u8 = x90;
let x92: u8 = x91;
let x93: u8 = x92;
let x94: u8 = x93;
let x95: u8 = x94;
let x96: u8 = x95;
let x97: u8 = x96;
let x98: u8 = x97;
let x99: u8 = x98;
let x100: u8 = x99;
let x101: u8 = x100;
let x102: u8 = x101;
let x103: u8 = x102;
let x104: u8 = x103;
let x105: u8 = x104;
let x106: u8 = x105;
let x107: u8 = x106;
let x108: u8 = x107;
let x109: u8 = x108;
let x110: u8 = x109;
let x111: u8 = x110;
let x112: u8 = x111;
let x113: u8 = x112;
let x114: u8 = x113;
let x115: u8 = x114;
let x116: u8 = x115;
let x117: u8 = x116;
let x118: u8 = x117;
let x119: u8 = x118;
let x120: u8 = x119;
let x121: u8 = x120;
let x122: u8 = x121;
let x123: u8 = x122;
let x124: u8 = x123;
let x125: u8 = x124;
let x126: u8 = x125;
let x127: u8 = x126;
let x128: u8 = x127;
let x129: u8 = x128;
let x130: u8 = x129;
let x131: u8 = x130;
let x132: u8 = x131;
let x133: u8 = x132;
let x134: u8 = x133;
let x135: u8 = x134;
let x136: u8 = x135;
let x137: u8 = x136;
let x138: u8 = x137;
let x139: u8 = x138;
let x140: u8 = x139;
let x141: u8 = x140;
let x142: u8 = x141;
let x143: u8 = x142;
let x144: u8 = x143;
let x145: u8 = x144;
let x146: u8 = x145;
let x147: u8 = x146;
let x148: u8 = x147;
let x149: u8 = x148;
let x150: u8 = x149;
let x151: u8 = x150;
let x152: u8 = x151;
let x153: u8 = x152;
let x154: u8 = x153;
let x155: u8 = x154;
let x156: u8 = x155;
let x157: u8 = x156;
let x158: u8 = x157;
let x159: u8 = x158;
let x160: u8 = x159;
let x161: u8 = x160;
let x162: u8 = x161;
let x163: u8 = x162;
let x164: u8 = x163;
let x165: u8 = x164;
let x166: u8 = x165;
let x167: u8 = x166;
let x168: u8 = x167;
let x169: u8 = x168;
let x170: u8 = x169;
let x171: u8 = x170;
let x172: u8 = x171;
let x173: u8 = x172;
let x174: u8 = x173;
let x175: u8 = x174;
let x176: u8 = x175;
let x177: u8 = x176;
let x178: u8 = x177;
let x179: u8 = x178;
let x180: u8 = x179;
let x181: u8 = x180;
let x182: u8 = x181;
let x183: u8 = x182;
let x184: u8 = x183;
let x185: u8 = x184;
let x186: u8 = x185;
let x187: u8 = x186;
let x188: u8 = x187;
let x189: u8 = x188;
let x190: u8 = x189;
let x191: u8 = x190;
let x192: u8 = x191;
let x193: u8 = x192;
let x194: u8 = x193;
let x195: u8 = x194;
let x196: u8 = x195;
let x197: u8 = x196;
let x198: u8 = x197;
let x199: u8 = x198;
let x200: u8 = x199;
let x201: u8 = x200;
let x202: u8 = x201;
let x203: u8 = x202;
let x204: u8 = x203;
let x205: u8 = x204;
let x206: u8 = x205;
let x207: u8 = x206;
let x208: u8 = x207;
let x209: u8 = x208;
let x210: u8 = x209;
let x211: u8 = x210;
let x212: u8 = x211;
let x213: u8 = x212;
let x214: u8 = x213;
let x215: u8 = x214;
let x216: u8 = x215;
let x217: u8 = x216;
let x218: u8 = x217;
let x219: u8 = x218;
let x220: u8 = x219;
let x221: u8 = x220;
let x222: u8 = x221;
let x223: u8 = x222;
let x224: u8 = x223;
let x225: u8 = x224;
let x226: u8 = x225;
let x227: u8 = x226;
let x228: u8 = x227;
let x229: u8 = x228;
let x230: u8 = x229;
let x231: u8 = x230;
let x232: u8 = x231;
let x233: u8 = x232;
let x234: u8 = x233;
let x235: u8 = x234;
let x236: u8 = x235;
let x237: u8 = x236;
let x238: u8 = x237;
let x239: u8 = x238;
let x240: u8 = x239;
let x241: u8 = x240;
let x242: u8 = x241;
let x243: u8 = x242;
let x244: u8 = x243;
let x245: u8 = x244;
let x246: u8 = x245;
let x247: u8 = x246;
let x248: u8 = x247;
let x249: u8 = x248;
let x250: u8 = x249;
let x251: u8 = x250;
let x252: u8 = x251;
let x253: u8 = x252;
let x254: u8 = x253;
let x255: u8 = x254;
let x256: u8 = x255;
let x257: u8 = x256;
let x258: u8 = x257;
let x259: u8 = x258;
let x260: u8 = x259;
let x261: u8 = x260;
let x262: u8 = x261;
let x263: u8 = x262;
let x264: u8 = x263;
let x265: u8 = x264;
let x266: u8 = x265;
let x267: u8 = x266;
let x268: u8 = x267;
let x269: u8 = x268;
let x270: u8 = x269;
let x271: u8 = x270;
let x272: u8 = x271;
let x273: u8 = x272;
let x274: u8 = x273;
let x275: u8 = x274;
let x276: u8 = x275;
let x277: u8 = x276;
let x278: u8 = x277;
let x279: u8 = x278;
let x280: u8 = x279;
let x281: u8 = x280;
let x282: u8 = x281;
let x283: u8 = x282;
let x284: u8 = x283;
let x285: u8 = x284;
let x286: u8 = x285;
let x287: u8 = x286;
let x288: u8 = x287;
let x289: u8 = x288;
let x290: u8 = x289;
let x291: u8 = x290;
let x292: u8 = x291;
let x293: u8 = x292;
let x294: u8 = x293;
let x295: u8 = x294;
let x296: u8 = x295;
let x297: u8 = x296;
let x298: u8 = x297;
let x299: u8 = x298;
let x300: u8 = x299;
let x301: u8 = x300;
let x302: u8 = x301;
let x303: u8 = x302;
let x304: u8 = x303;
let x305: u8 = x304;
let x306: u8 = x305;
let x307: u8 = x306;
let x308: u8 = x307;
let x309: u8 = x308;
let x310: u8 = x309;
let x311: u8 = x310;
let x312: u8 = x311;
let x313: u8 = x312;
let x314: u8 = x313;
let x315: u8 = x314;
let x316: u8 = x315;
let x317: u8 = x316;
let x318: u8 = x317;
let x319: u8 = x318;
let x320: u8 = x319;
let x321: u8 = x320;
let x322: u8 = x321;
let x323: u8 = x322;
let x324: u8 = x323;
let x325: u8 = x324;
let x326: u8 = x325;
let x327: u8 = x326;
let x328: u8 = x327;
let x329: u8 = x328;
let x330: u8 = x329;
let x331: u8 = x330;
let x332: u8 = x331;
let x333: u8 = x332;
let x334: u8 = x333;
let x335: u8 = x334;
let x336: u8 = x335;
let x337: u8 = x336;
let x338: u8 = x337;
let x339: u8 = x338;
let x340: u8 = x339;
let x341: u8 = x340;
let x342: u8 = x341;
let x343: u8 = x342;
let x344: u8 = x343;
let x345: u8 = x344;
let x346: u8 = x345;
let x347: u8 = x346;
let x348: u8 = x347;
let x349: u8 = x348;
let x350: u8 = x349;
let x351: u8 = x350;
let x352: u8 = x351;
let x353: u8 = x352;
let x354: u8 = x353;
let x355: u8 = x354;
let x356: u8 = x355;
let x357: u8 = x356;
let x358: u8 = x357;
let x359: u8 = x358;
let x360: u8 = x359;
let x361: u8 = x360;
let x362: u8 = x361;
let x363: u8 = x362;
let x364: u8 = x363;
let x365: u8 = x364;
let x366: u8 = x365;
let x367: u8 = x366;
let x368: u8 = x367;
let x369: u8 = x368;
let x370: u8 = x369;
let x371: u8 = x370;
let x372: u8 = x371;
let x373: u8 = x372;
let x374: u8 = x373;
let x375: u8 = x374;
let x376: u8 = x375;
let x377: u8 = x376;
let x378: u8 = x377;
let x379: u8 = x378;
let x380: u8 = x379;
let x381: u8 = x380;
let x382: u8 = x381;
let x383: u8 = x382;
return x383
}

196
typed/benches/many_foos.leo Normal file
View File

@ -0,0 +1,196 @@
function main() {
return x191(0u32)
}
function x0(val: u8) -> u8 { return val }
function x1(val: u8) -> u8 { return x0(val) }
function x2(val: u8) -> u8 { return x1(val) }
function x3(val: u8) -> u8 { return x2(val) }
function x4(val: u8) -> u8 { return x3(val) }
function x5(val: u8) -> u8 { return x4(val) }
function x6(val: u8) -> u8 { return x5(val) }
function x7(val: u8) -> u8 { return x6(val) }
function x8(val: u8) -> u8 { return x7(val) }
function x9(val: u8) -> u8 { return x8(val) }
function x10(val: u8) -> u8 { return x9(val) }
function x11(val: u8) -> u8 { return x10(val) }
function x12(val: u8) -> u8 { return x11(val) }
function x13(val: u8) -> u8 { return x12(val) }
function x14(val: u8) -> u8 { return x13(val) }
function x15(val: u8) -> u8 { return x14(val) }
function x16(val: u8) -> u8 { return x15(val) }
function x17(val: u8) -> u8 { return x16(val) }
function x18(val: u8) -> u8 { return x17(val) }
function x19(val: u8) -> u8 { return x18(val) }
function x20(val: u8) -> u8 { return x19(val) }
function x21(val: u8) -> u8 { return x20(val) }
function x22(val: u8) -> u8 { return x21(val) }
function x23(val: u8) -> u8 { return x22(val) }
function x24(val: u8) -> u8 { return x23(val) }
function x25(val: u8) -> u8 { return x24(val) }
function x26(val: u8) -> u8 { return x25(val) }
function x27(val: u8) -> u8 { return x26(val) }
function x28(val: u8) -> u8 { return x27(val) }
function x29(val: u8) -> u8 { return x28(val) }
function x30(val: u8) -> u8 { return x29(val) }
function x31(val: u8) -> u8 { return x30(val) }
function x32(val: u8) -> u8 { return x31(val) }
function x33(val: u8) -> u8 { return x32(val) }
function x34(val: u8) -> u8 { return x33(val) }
function x35(val: u8) -> u8 { return x34(val) }
function x36(val: u8) -> u8 { return x35(val) }
function x37(val: u8) -> u8 { return x36(val) }
function x38(val: u8) -> u8 { return x37(val) }
function x39(val: u8) -> u8 { return x38(val) }
function x40(val: u8) -> u8 { return x39(val) }
function x41(val: u8) -> u8 { return x40(val) }
function x42(val: u8) -> u8 { return x41(val) }
function x43(val: u8) -> u8 { return x42(val) }
function x44(val: u8) -> u8 { return x43(val) }
function x45(val: u8) -> u8 { return x44(val) }
function x46(val: u8) -> u8 { return x45(val) }
function x47(val: u8) -> u8 { return x46(val) }
function x48(val: u8) -> u8 { return x47(val) }
function x49(val: u8) -> u8 { return x48(val) }
function x50(val: u8) -> u8 { return x49(val) }
function x51(val: u8) -> u8 { return x50(val) }
function x52(val: u8) -> u8 { return x51(val) }
function x53(val: u8) -> u8 { return x52(val) }
function x54(val: u8) -> u8 { return x53(val) }
function x55(val: u8) -> u8 { return x54(val) }
function x56(val: u8) -> u8 { return x55(val) }
function x57(val: u8) -> u8 { return x56(val) }
function x58(val: u8) -> u8 { return x57(val) }
function x59(val: u8) -> u8 { return x58(val) }
function x60(val: u8) -> u8 { return x59(val) }
function x61(val: u8) -> u8 { return x60(val) }
function x62(val: u8) -> u8 { return x61(val) }
function x63(val: u8) -> u8 { return x62(val) }
function x64(val: u8) -> u8 { return x63(val) }
function x65(val: u8) -> u8 { return x64(val) }
function x66(val: u8) -> u8 { return x65(val) }
function x67(val: u8) -> u8 { return x66(val) }
function x68(val: u8) -> u8 { return x67(val) }
function x69(val: u8) -> u8 { return x68(val) }
function x70(val: u8) -> u8 { return x69(val) }
function x71(val: u8) -> u8 { return x70(val) }
function x72(val: u8) -> u8 { return x71(val) }
function x73(val: u8) -> u8 { return x72(val) }
function x74(val: u8) -> u8 { return x73(val) }
function x75(val: u8) -> u8 { return x74(val) }
function x76(val: u8) -> u8 { return x75(val) }
function x77(val: u8) -> u8 { return x76(val) }
function x78(val: u8) -> u8 { return x77(val) }
function x79(val: u8) -> u8 { return x78(val) }
function x80(val: u8) -> u8 { return x79(val) }
function x81(val: u8) -> u8 { return x80(val) }
function x82(val: u8) -> u8 { return x81(val) }
function x83(val: u8) -> u8 { return x82(val) }
function x84(val: u8) -> u8 { return x83(val) }
function x85(val: u8) -> u8 { return x84(val) }
function x86(val: u8) -> u8 { return x85(val) }
function x87(val: u8) -> u8 { return x86(val) }
function x88(val: u8) -> u8 { return x87(val) }
function x89(val: u8) -> u8 { return x88(val) }
function x90(val: u8) -> u8 { return x89(val) }
function x91(val: u8) -> u8 { return x90(val) }
function x92(val: u8) -> u8 { return x91(val) }
function x93(val: u8) -> u8 { return x92(val) }
function x94(val: u8) -> u8 { return x93(val) }
function x95(val: u8) -> u8 { return x94(val) }
function x96(val: u8) -> u8 { return x95(val) }
function x97(val: u8) -> u8 { return x96(val) }
function x98(val: u8) -> u8 { return x97(val) }
function x99(val: u8) -> u8 { return x98(val) }
function x100(val: u8) -> u8 { return x99(val) }
function x101(val: u8) -> u8 { return x100(val) }
function x102(val: u8) -> u8 { return x101(val) }
function x103(val: u8) -> u8 { return x102(val) }
function x104(val: u8) -> u8 { return x103(val) }
function x105(val: u8) -> u8 { return x104(val) }
function x106(val: u8) -> u8 { return x105(val) }
function x107(val: u8) -> u8 { return x106(val) }
function x108(val: u8) -> u8 { return x107(val) }
function x109(val: u8) -> u8 { return x108(val) }
function x110(val: u8) -> u8 { return x109(val) }
function x111(val: u8) -> u8 { return x110(val) }
function x112(val: u8) -> u8 { return x111(val) }
function x113(val: u8) -> u8 { return x112(val) }
function x114(val: u8) -> u8 { return x113(val) }
function x115(val: u8) -> u8 { return x114(val) }
function x116(val: u8) -> u8 { return x115(val) }
function x117(val: u8) -> u8 { return x116(val) }
function x118(val: u8) -> u8 { return x117(val) }
function x119(val: u8) -> u8 { return x118(val) }
function x120(val: u8) -> u8 { return x119(val) }
function x121(val: u8) -> u8 { return x120(val) }
function x122(val: u8) -> u8 { return x121(val) }
function x123(val: u8) -> u8 { return x122(val) }
function x124(val: u8) -> u8 { return x123(val) }
function x125(val: u8) -> u8 { return x124(val) }
function x126(val: u8) -> u8 { return x125(val) }
function x127(val: u8) -> u8 { return x126(val) }
function x128(val: u8) -> u8 { return x127(val) }
function x129(val: u8) -> u8 { return x128(val) }
function x130(val: u8) -> u8 { return x129(val) }
function x131(val: u8) -> u8 { return x130(val) }
function x132(val: u8) -> u8 { return x131(val) }
function x133(val: u8) -> u8 { return x132(val) }
function x134(val: u8) -> u8 { return x133(val) }
function x135(val: u8) -> u8 { return x134(val) }
function x136(val: u8) -> u8 { return x135(val) }
function x137(val: u8) -> u8 { return x136(val) }
function x138(val: u8) -> u8 { return x137(val) }
function x139(val: u8) -> u8 { return x138(val) }
function x140(val: u8) -> u8 { return x139(val) }
function x141(val: u8) -> u8 { return x140(val) }
function x142(val: u8) -> u8 { return x141(val) }
function x143(val: u8) -> u8 { return x142(val) }
function x144(val: u8) -> u8 { return x143(val) }
function x145(val: u8) -> u8 { return x144(val) }
function x146(val: u8) -> u8 { return x145(val) }
function x147(val: u8) -> u8 { return x146(val) }
function x148(val: u8) -> u8 { return x147(val) }
function x149(val: u8) -> u8 { return x148(val) }
function x150(val: u8) -> u8 { return x149(val) }
function x151(val: u8) -> u8 { return x150(val) }
function x152(val: u8) -> u8 { return x151(val) }
function x153(val: u8) -> u8 { return x152(val) }
function x154(val: u8) -> u8 { return x153(val) }
function x155(val: u8) -> u8 { return x154(val) }
function x156(val: u8) -> u8 { return x155(val) }
function x157(val: u8) -> u8 { return x156(val) }
function x158(val: u8) -> u8 { return x157(val) }
function x159(val: u8) -> u8 { return x158(val) }
function x160(val: u8) -> u8 { return x159(val) }
function x161(val: u8) -> u8 { return x160(val) }
function x162(val: u8) -> u8 { return x161(val) }
function x163(val: u8) -> u8 { return x162(val) }
function x164(val: u8) -> u8 { return x163(val) }
function x165(val: u8) -> u8 { return x164(val) }
function x166(val: u8) -> u8 { return x165(val) }
function x167(val: u8) -> u8 { return x166(val) }
function x168(val: u8) -> u8 { return x167(val) }
function x169(val: u8) -> u8 { return x168(val) }
function x170(val: u8) -> u8 { return x169(val) }
function x171(val: u8) -> u8 { return x170(val) }
function x172(val: u8) -> u8 { return x171(val) }
function x173(val: u8) -> u8 { return x172(val) }
function x174(val: u8) -> u8 { return x173(val) }
function x175(val: u8) -> u8 { return x174(val) }
function x176(val: u8) -> u8 { return x175(val) }
function x177(val: u8) -> u8 { return x176(val) }
function x178(val: u8) -> u8 { return x177(val) }
function x179(val: u8) -> u8 { return x178(val) }
function x180(val: u8) -> u8 { return x179(val) }
function x181(val: u8) -> u8 { return x180(val) }
function x182(val: u8) -> u8 { return x181(val) }
function x183(val: u8) -> u8 { return x182(val) }
function x184(val: u8) -> u8 { return x183(val) }
function x185(val: u8) -> u8 { return x184(val) }
function x186(val: u8) -> u8 { return x185(val) }
function x187(val: u8) -> u8 { return x186(val) }
function x188(val: u8) -> u8 { return x187(val) }
function x189(val: u8) -> u8 { return x188(val) }
function x190(val: u8) -> u8 { return x189(val) }
function x191(val: u8) -> u8 { return x190(val) }

View File

@ -17,22 +17,81 @@
use leo_ast::LeoAst; use leo_ast::LeoAst;
use leo_typed::LeoTypedAst; use leo_typed::LeoTypedAst;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{criterion_group, criterion_main, Criterion};
use std::path::Path; use std::{
path::{Path, PathBuf},
time::Duration,
};
fn leo_typed_ast<'ast>(ast: &LeoAst<'ast>) { fn leo_typed_ast<'ast>(ast: &LeoAst<'ast>) -> LeoTypedAst {
let typed_ast = LeoTypedAst::new("leo_typed_tree", &ast); LeoTypedAst::new("leo_typed_tree", &ast)
black_box(typed_ast);
} }
fn criterion_benchmark(c: &mut Criterion) { fn bench_big_if_else(c: &mut Criterion) {
let filepath = Path::new("./main.leo").to_path_buf(); let filepath = Path::new("./big_if_else.leo").to_path_buf();
// let program_string = &LeoAst::load_file(&filepath).unwrap(); let program_string = include_str!("./big_if_else.leo");
let program_string = include_str!("./main.leo");
let ast = LeoAst::new(&filepath, program_string).unwrap(); let ast = LeoAst::new(&filepath, program_string).unwrap();
c.bench_function("LeoTypedAst::new", |b| b.iter(|| leo_typed_ast(black_box(&ast)))); c.bench_function("LeoTypedAst::big_if_else", |b| b.iter(|| leo_typed_ast(&ast)));
} }
criterion_group!(benches, criterion_benchmark); fn bench_big_ternary(c: &mut Criterion) {
let filepath = Path::new("./big_ternary.leo").to_path_buf();
let program_string = include_str!("./big_ternary.leo");
let ast = LeoAst::new(&filepath, program_string).unwrap();
c.bench_function("LeoTypedAst::big_ternary", |b| b.iter(|| leo_typed_ast(&ast)));
}
fn bench_big_circuit(c: &mut Criterion) {
let filepath = Path::new("./big_circuit.leo").to_path_buf();
let program_string = include_str!("./big_circuit.leo");
let ast = LeoAst::new(&filepath, program_string).unwrap();
c.bench_function("LeoTypedAst::big_circuit", |b| b.iter(|| leo_typed_ast(&ast)));
}
fn bench_long_expr(c: &mut Criterion) {
let filepath = Path::new("./long_expr.leo").to_path_buf();
let program_string = include_str!("./long_expr.leo");
let ast = LeoAst::new(&filepath, program_string).unwrap();
c.bench_function("LeoTypedAst::long_expr", |b| b.iter(|| leo_typed_ast(&ast)));
}
fn bench_long_array(c: &mut Criterion) {
let filepath = Path::new("./long_array.leo").to_path_buf();
let program_string = include_str!("./long_array.leo");
let ast = LeoAst::new(&filepath, program_string).unwrap();
c.bench_function("LeoTypedAst::long_array", |b| b.iter(|| leo_typed_ast(&ast)));
}
fn bench_many_foos(c: &mut Criterion) {
let filepath = Path::new("./many_foos.leo").to_path_buf();
let program_string = include_str!("./many_foos.leo");
let ast = LeoAst::new(&filepath, program_string).unwrap();
c.bench_function("LeoTypedAst::many_foos", |b| b.iter(|| leo_typed_ast(&ast)));
}
fn bench_many_assigns(c: &mut Criterion) {
let filepath = Path::new("./many_assigns.leo").to_path_buf();
let program_string = include_str!("./many_assigns.leo");
let ast = LeoAst::new(&filepath, program_string).unwrap();
c.bench_function("LeoTypedAst::many_assigns", |b| b.iter(|| leo_typed_ast(&ast)));
}
criterion_group!(
name = benches;
config = Criterion::default().sample_size(200).measurement_time(Duration::from_secs(10)).nresamples(200_000);
targets = bench_big_circuit,
bench_long_expr,
bench_big_if_else,
bench_big_ternary,
bench_long_array,
bench_many_assigns,
bench_many_foos,
);
criterion_main!(benches); criterion_main!(benches);

View File

@ -16,8 +16,9 @@
use pest::Span as AstSpan; use pest::Span as AstSpan;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::hash::{Hash, Hasher};
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Span { pub struct Span {
/// text of input string /// text of input string
pub text: String, pub text: String,
@ -29,6 +30,22 @@ pub struct Span {
pub end: usize, pub end: usize,
} }
impl PartialEq for Span {
fn eq(&self, other: &Self) -> bool {
self.line == other.line && self.start == other.start && self.end == other.end
}
}
impl Eq for Span {}
impl Hash for Span {
fn hash<H: Hasher>(&self, state: &mut H) {
self.line.hash(state);
self.start.hash(state);
self.end.hash(state);
}
}
impl<'ast> From<AstSpan<'ast>> for Span { impl<'ast> From<AstSpan<'ast>> for Span {
fn from(span: AstSpan<'ast>) -> Self { fn from(span: AstSpan<'ast>) -> Self {
let mut text = " ".to_string(); let mut text = " ".to_string();

View File

@ -64,7 +64,7 @@ pub enum Expression {
Address(String, Span), Address(String, Span),
Boolean(String, Span), Boolean(String, Span),
Field(String, Span), Field(String, Span),
Group(GroupValue), Group(Box<GroupValue>),
Implicit(String, Span), Implicit(String, Span),
Integer(IntegerType, String, Span), Integer(IntegerType, String, Span),
@ -336,12 +336,7 @@ impl<'ast> From<PostfixExpression<'ast>> for Expression {
let span = Span::from(function.span); let span = Span::from(function.span);
Expression::FunctionCall( Expression::FunctionCall(
Box::new(acc), Box::new(acc),
function function.expressions.into_iter().map(Expression::from).collect(),
.expressions
.expressions
.into_iter()
.map(Expression::from)
.collect(),
span, span,
) )
} }
@ -576,7 +571,7 @@ impl<'ast> From<FieldValue<'ast>> for Expression {
impl<'ast> From<AstGroupValue<'ast>> for Expression { impl<'ast> From<AstGroupValue<'ast>> for Expression {
fn from(ast_group: AstGroupValue<'ast>) -> Self { fn from(ast_group: AstGroupValue<'ast>) -> Self {
Expression::Group(GroupValue::from(ast_group)) Expression::Group(Box::new(GroupValue::from(ast_group)))
} }
} }

View File

@ -20,7 +20,7 @@ use leo_ast::functions::Function as AstFunction;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fmt; use std::fmt;
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Serialize, Deserialize)]
pub struct Function { pub struct Function {
pub identifier: Identifier, pub identifier: Identifier,
pub input: Vec<InputVariable>, pub input: Vec<InputVariable>,
@ -29,6 +29,14 @@ pub struct Function {
pub span: Span, pub span: Span,
} }
impl PartialEq for Function {
fn eq(&self, other: &Self) -> bool {
self.identifier == other.identifier
}
}
impl Eq for Function {}
impl<'ast> From<AstFunction<'ast>> for Function { impl<'ast> From<AstFunction<'ast>> for Function {
fn from(function: AstFunction<'ast>) -> Self { fn from(function: AstFunction<'ast>) -> Self {
let function_name = Identifier::from(function.identifier); let function_name = Identifier::from(function.identifier);