mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-19 15:41:36 +03:00
Merge pull request #1666 from AleoHQ/feature/1654-require-types
[Impl] Require Types
This commit is contained in:
commit
527c55f841
@ -31,7 +31,7 @@ pub struct Function {
|
||||
/// The function returns a constant value.
|
||||
pub const_: bool,
|
||||
/// The function return type, if explicitly specified, or `()` if not.
|
||||
pub output: Option<Type>,
|
||||
pub output: Type,
|
||||
/// Any mapping to the core library.
|
||||
/// Always `None` when initially parsed.
|
||||
pub core_mapping: Cell<Option<Symbol>>,
|
||||
@ -67,12 +67,8 @@ impl Function {
|
||||
write!(f, "function {}", self.identifier)?;
|
||||
|
||||
let parameters = self.input.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",");
|
||||
let returns = self.output.as_ref().map(|type_| type_.to_string());
|
||||
if returns.is_none() {
|
||||
write!(f, "({}) {}", parameters, self.block)
|
||||
} else {
|
||||
write!(f, "({}) -> {} {}", parameters, returns.unwrap(), self.block)
|
||||
}
|
||||
let returns = self.output.to_string();
|
||||
write!(f, "({}) -> {} {}", parameters, returns, self.block)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
}
|
||||
|
||||
pub fn reduce_type(&mut self, type_: &Type, span: &Span) -> Result<Type> {
|
||||
let new = match type_ {
|
||||
Type::Identifier(identifier) => Type::Identifier(self.reduce_identifier(identifier)?),
|
||||
_ => type_.clone(),
|
||||
};
|
||||
|
||||
self.reducer.reduce_type(type_, new, span)
|
||||
self.reducer.reduce_type(type_, type_.clone(), span)
|
||||
}
|
||||
|
||||
// Expressions
|
||||
@ -156,11 +151,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
variable_names.push(self.reduce_variable_name(variable_name)?);
|
||||
}
|
||||
|
||||
let type_ = definition
|
||||
.type_
|
||||
.as_ref()
|
||||
.map(|type_| self.reduce_type(type_, &definition.span))
|
||||
.transpose()?;
|
||||
let type_ = self.reduce_type(&definition.type_, &definition.span)?;
|
||||
|
||||
let value = self.reduce_expression(&definition.value)?;
|
||||
|
||||
@ -215,11 +206,13 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
|
||||
pub fn reduce_iteration(&mut self, iteration: &IterationStatement) -> Result<IterationStatement> {
|
||||
let variable = self.reduce_identifier(&iteration.variable)?;
|
||||
let type_ = self.reduce_type(&iteration.type_, iteration.span())?;
|
||||
let start = self.reduce_expression(&iteration.start)?;
|
||||
let stop = self.reduce_expression(&iteration.stop)?;
|
||||
let block = self.reduce_block(&iteration.block)?;
|
||||
|
||||
self.reducer.reduce_iteration(iteration, variable, start, stop, block)
|
||||
self.reducer
|
||||
.reduce_iteration(iteration, variable, type_, start, stop, block)
|
||||
}
|
||||
|
||||
pub fn reduce_console(&mut self, console_function_call: &ConsoleStatement) -> Result<ConsoleStatement> {
|
||||
@ -305,11 +298,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
inputs.push(self.reduce_function_input(input)?);
|
||||
}
|
||||
|
||||
let output = function
|
||||
.output
|
||||
.as_ref()
|
||||
.map(|type_| self.reduce_type(type_, &function.span))
|
||||
.transpose()?;
|
||||
let output = self.reduce_type(&function.output, &function.span)?;
|
||||
|
||||
let block = self.reduce_block(&function.block)?;
|
||||
|
||||
|
@ -150,7 +150,7 @@ pub trait ReconstructingReducer {
|
||||
&mut self,
|
||||
definition: &DefinitionStatement,
|
||||
variable_names: Vec<VariableName>,
|
||||
type_: Option<Type>,
|
||||
type_: Type,
|
||||
value: Expression,
|
||||
) -> Result<DefinitionStatement> {
|
||||
Ok(DefinitionStatement {
|
||||
@ -212,12 +212,14 @@ pub trait ReconstructingReducer {
|
||||
&mut self,
|
||||
iteration: &IterationStatement,
|
||||
variable: Identifier,
|
||||
type_: Type,
|
||||
start: Expression,
|
||||
stop: Expression,
|
||||
block: Block,
|
||||
) -> Result<IterationStatement> {
|
||||
Ok(IterationStatement {
|
||||
variable,
|
||||
type_,
|
||||
start,
|
||||
stop,
|
||||
inclusive: iteration.inclusive,
|
||||
@ -295,7 +297,7 @@ pub trait ReconstructingReducer {
|
||||
identifier: Identifier,
|
||||
input: Vec<FunctionInput>,
|
||||
const_: bool,
|
||||
output: Option<Type>,
|
||||
output: Type,
|
||||
block: Block,
|
||||
) -> Result<Function> {
|
||||
Ok(Function {
|
||||
|
@ -34,7 +34,7 @@ pub struct DefinitionStatement {
|
||||
/// The bindings / variable names to declare.
|
||||
pub variable_names: Vec<VariableName>,
|
||||
/// The types of the bindings, if specified, or inferred otherwise.
|
||||
pub type_: Option<Type>,
|
||||
pub type_: Type,
|
||||
/// An initializer value for the bindings.
|
||||
pub value: Expression,
|
||||
/// The span excluding the semicolon.
|
||||
@ -59,9 +59,7 @@ impl fmt::Display for DefinitionStatement {
|
||||
write!(f, "({})", names)?;
|
||||
}
|
||||
|
||||
if self.type_.is_some() {
|
||||
write!(f, ": {}", self.type_.as_ref().unwrap())?;
|
||||
}
|
||||
write!(f, ": {}", self.type_)?;
|
||||
write!(f, " = {};", self.value)
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
use crate::{Block, Expression, Identifier, Node};
|
||||
use crate::{Block, Expression, Identifier, Node, Type};
|
||||
use leo_span::Span;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -25,6 +25,8 @@ use std::fmt;
|
||||
pub struct IterationStatement {
|
||||
/// The binding / variable to introduce in the body `block`.
|
||||
pub variable: Identifier,
|
||||
/// The type of the iteration.
|
||||
pub type_: Type,
|
||||
/// The start of the iteration.
|
||||
pub start: Expression,
|
||||
/// The end of the iteration, possibly `inclusive`.
|
||||
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
use crate::{Identifier, IntegerType};
|
||||
use crate::IntegerType;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt;
|
||||
@ -36,22 +36,12 @@ pub enum Type {
|
||||
/// An integer type.
|
||||
IntegerType(IntegerType),
|
||||
|
||||
/// A reference to either a nominal type (e.g., a `circuit`) or a type alias.
|
||||
Identifier(Identifier),
|
||||
|
||||
/// Placeholder for a type that could not be resolved or was not well-formed.
|
||||
/// Will eventually lead to a compile error.
|
||||
Err,
|
||||
}
|
||||
|
||||
impl Type {
|
||||
///
|
||||
/// Returns `true` if the self `Type` is a `Circuit`.
|
||||
///
|
||||
pub fn is_circuit(&self) -> bool {
|
||||
matches!(self, Type::Identifier(_))
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns `true` if the self `Type` is equal to the other `Type`.
|
||||
///
|
||||
@ -65,8 +55,6 @@ impl Type {
|
||||
(Type::Field, Type::Field) => true,
|
||||
(Type::Group, Type::Group) => true,
|
||||
(Type::IntegerType(left), Type::IntegerType(right)) => left.eq(right),
|
||||
(Type::Identifier(left), Type::Identifier(right)) => left.eq(right),
|
||||
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -81,7 +69,6 @@ impl fmt::Display for Type {
|
||||
Type::Field => write!(f, "field"),
|
||||
Type::Group => write!(f, "group"),
|
||||
Type::IntegerType(ref integer_type) => write!(f, "{}", integer_type),
|
||||
Type::Identifier(ref variable) => write!(f, "circuit {}", variable),
|
||||
Type::Err => write!(f, "error"),
|
||||
}
|
||||
}
|
||||
|
@ -37,10 +37,8 @@ pub struct ParserContext<'a> {
|
||||
/// The previous token, i.e., if `p.tokens = ['3', *, '4']`,
|
||||
/// then after two `p.bump()`s, we'll have `p.token = '*'` and `p.prev_token = '3'`.
|
||||
pub(crate) prev_token: SpannedToken,
|
||||
|
||||
// true if parsing an expression for if and loop statements -- means circuit inits are not legal
|
||||
/// true if parsing an expression for if and loop statements -- means circuit inits are not legal
|
||||
pub(crate) disallow_circuit_construction: bool,
|
||||
|
||||
/// HACK(Centril): Place to store a dummy EOF.
|
||||
/// Exists to appease borrow checker for now.
|
||||
dummy_eof: SpannedToken,
|
||||
@ -166,10 +164,8 @@ impl<'a> ParserContext<'a> {
|
||||
.ok_or_else(|| ParserError::unexpected_str(&self.token.token, "ident", &self.token.span).into())
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a reference to the next token if it is a [`GroupCoordinate`], or [None] if
|
||||
/// the next token is not a [`GroupCoordinate`].
|
||||
///
|
||||
fn peek_group_coordinate(&self, dist: &mut usize) -> Option<GroupCoordinate> {
|
||||
let (advanced, gc) = self.look_ahead(*dist, |t0| match &t0.token {
|
||||
Token::Add => Some((1, GroupCoordinate::SignHigh)),
|
||||
|
@ -35,10 +35,8 @@ const INT_TYPES: &[Token] = &[
|
||||
];
|
||||
|
||||
impl ParserContext<'_> {
|
||||
///
|
||||
/// Returns an [`Expression`] AST node if the next token is an expression.
|
||||
/// Includes circuit init expressions.
|
||||
///
|
||||
pub fn parse_expression(&mut self) -> Result<Expression> {
|
||||
// Store current parser state.
|
||||
let prior_fuzzy_state = self.disallow_circuit_construction;
|
||||
@ -302,8 +300,7 @@ impl ParserContext<'_> {
|
||||
let int_ty = Self::token_to_int_type(suffix).expect("unknown int type token");
|
||||
Expression::Value(ValueExpression::Integer(int_ty, value, full_span))
|
||||
}
|
||||
// Just literal and no suffix.
|
||||
None => Expression::Value(ValueExpression::Implicit(value, span)),
|
||||
None => return Err(ParserError::implicit_values_not_allowed(value, &span).into()),
|
||||
}
|
||||
}
|
||||
Token::True => Expression::Value(ValueExpression::Boolean("true".into(), span)),
|
||||
|
@ -20,9 +20,7 @@ use leo_errors::{ParserError, ParserWarning, Result};
|
||||
use leo_span::sym;
|
||||
|
||||
impl ParserContext<'_> {
|
||||
///
|
||||
/// Returns a [`Program`] AST if all tokens can be consumed and represent a valid Leo program.
|
||||
///
|
||||
pub fn parse_program(&mut self) -> Result<Program> {
|
||||
let mut functions = IndexMap::new();
|
||||
|
||||
@ -60,9 +58,7 @@ impl ParserContext<'_> {
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`ParamMode`] AST node if the next tokens represent a function parameter mode.
|
||||
///
|
||||
pub fn parse_function_parameter_mode(&mut self) -> Result<ParamMode> {
|
||||
let public = self.eat(&Token::Public).then(|| self.prev_token.span.clone());
|
||||
let constant = self.eat(&Token::Constant).then(|| self.prev_token.span.clone());
|
||||
@ -86,9 +82,7 @@ impl ParserContext<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`FunctionInput`] AST node if the next tokens represent a function parameter.
|
||||
///
|
||||
pub fn parse_function_parameter(&mut self) -> Result<FunctionInput> {
|
||||
let mode = self.parse_function_parameter_mode()?;
|
||||
let mutable = self.eat(&Token::Mut).then(|| self.prev_token.clone());
|
||||
@ -100,7 +94,7 @@ impl ParserContext<'_> {
|
||||
}
|
||||
|
||||
self.expect(&Token::Colon)?;
|
||||
let type_ = self.parse_all_types()?.0;
|
||||
let type_ = self.parse_type()?.0;
|
||||
Ok(FunctionInput::Variable(FunctionInputVariable::new(
|
||||
name.clone(),
|
||||
mode,
|
||||
@ -123,11 +117,8 @@ impl ParserContext<'_> {
|
||||
let (inputs, ..) = self.parse_paren_comma_list(|p| p.parse_function_parameter().map(Some))?;
|
||||
|
||||
// Parse return type.
|
||||
let output = if self.eat(&Token::Arrow) {
|
||||
Some(self.parse_all_types()?.0)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.expect(&Token::Arrow)?;
|
||||
let output = self.parse_type()?.0;
|
||||
|
||||
// Parse the function body.
|
||||
let block = self.parse_block()?;
|
||||
@ -146,10 +137,8 @@ impl ParserContext<'_> {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`(String, DefinitionStatement)`] AST node if the next tokens represent a global
|
||||
/// constant declaration.
|
||||
///
|
||||
pub fn parse_global_const_declaration(&mut self) -> Result<(Vec<Identifier>, DefinitionStatement)> {
|
||||
let statement = self.parse_definition_statement()?;
|
||||
let variable_names = statement
|
||||
|
@ -65,7 +65,7 @@ impl ParserContext<'_> {
|
||||
|
||||
let name = self.expect_ident()?;
|
||||
self.expect(&Token::Colon)?;
|
||||
let (type_, span) = self.parse_non_ident_types()?;
|
||||
let (type_, span) = self.parse_type()?;
|
||||
self.expect(&Token::Assign)?;
|
||||
let value = self.parse_unary_expression()?;
|
||||
self.expect(&Token::Semicolon)?;
|
||||
|
@ -22,10 +22,8 @@ use leo_span::sym;
|
||||
const ASSIGN_TOKENS: &[Token] = &[Token::Assign];
|
||||
|
||||
impl ParserContext<'_> {
|
||||
///
|
||||
/// Returns an [`Identifier`] AST node if the given [`Expression`] AST node evaluates to an
|
||||
/// identifier access. The access is stored in the given accesses.
|
||||
///
|
||||
pub fn construct_assignee_access(expr: Expression, _accesses: &mut [AssigneeAccess]) -> Result<Identifier> {
|
||||
match expr {
|
||||
Expression::Identifier(id) => Ok(id),
|
||||
@ -33,9 +31,7 @@ impl ParserContext<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns an [`Assignee`] AST node from the given [`Expression`] AST node with accesses.
|
||||
///
|
||||
pub fn construct_assignee(expr: Expression) -> Result<Assignee> {
|
||||
let expr_span = expr.span().clone();
|
||||
let mut accesses = Vec::new();
|
||||
@ -48,9 +44,7 @@ impl ParserContext<'_> {
|
||||
})
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`Statement`] AST node if the next tokens represent a statement.
|
||||
///
|
||||
pub fn parse_statement(&mut self) -> Result<Statement> {
|
||||
match &self.token.token {
|
||||
Token::Return => Ok(Statement::Return(self.parse_return_statement()?)),
|
||||
@ -63,9 +57,7 @@ impl ParserContext<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a [`Block`] AST node if the next tokens represent a assign, or expression statement.
|
||||
///
|
||||
pub fn parse_assign_statement(&mut self) -> Result<Statement> {
|
||||
let expr = self.parse_expression()?;
|
||||
|
||||
@ -144,6 +136,8 @@ impl ParserContext<'_> {
|
||||
pub fn parse_loop_statement(&mut self) -> Result<IterationStatement> {
|
||||
let start_span = self.expect(&Token::For)?;
|
||||
let ident = self.expect_ident()?;
|
||||
self.expect(&Token::Colon)?;
|
||||
let type_ = self.parse_type()?;
|
||||
self.expect(&Token::In)?;
|
||||
|
||||
// Parse iteration range.
|
||||
@ -159,6 +153,7 @@ impl ParserContext<'_> {
|
||||
Ok(IterationStatement {
|
||||
span: start_span + block.span.clone(),
|
||||
variable: ident,
|
||||
type_: type_.0,
|
||||
start,
|
||||
stop,
|
||||
inclusive,
|
||||
@ -264,11 +259,8 @@ impl ParserContext<'_> {
|
||||
vec![self.parse_variable_name(decl_type, &decl_span)?]
|
||||
};
|
||||
|
||||
// Parse an optional type ascription.
|
||||
let type_ = self
|
||||
.eat(&Token::Colon)
|
||||
.then(|| self.parse_all_types().map(|t| t.0))
|
||||
.transpose()?;
|
||||
self.expect(&Token::Colon)?;
|
||||
let type_ = self.parse_type()?;
|
||||
|
||||
self.expect(&Token::Assign)?;
|
||||
let expr = self.parse_expression()?;
|
||||
@ -278,7 +270,7 @@ impl ParserContext<'_> {
|
||||
span: &decl_span + expr.span(),
|
||||
declaration_type: decl_type,
|
||||
variable_names,
|
||||
type_,
|
||||
type_: type_.0,
|
||||
value: expr,
|
||||
})
|
||||
}
|
||||
|
@ -32,13 +32,10 @@ pub(crate) const TYPE_TOKENS: &[Token] = &[
|
||||
Token::Group,
|
||||
Token::Address,
|
||||
Token::Bool,
|
||||
Token::Char,
|
||||
];
|
||||
|
||||
impl ParserContext<'_> {
|
||||
///
|
||||
/// Returns a [`IntegerType`] AST node if the given token is a supported integer type, or [`None`].
|
||||
///
|
||||
pub fn token_to_int_type(token: &Token) -> Option<IntegerType> {
|
||||
Some(match token {
|
||||
Token::I8 => IntegerType::I8,
|
||||
@ -57,7 +54,7 @@ impl ParserContext<'_> {
|
||||
|
||||
/// Returns a [`(Type, Span)`] tuple of AST nodes if the next token represents a type.
|
||||
/// Also returns the span of the parsed token.
|
||||
pub fn parse_non_ident_types(&mut self) -> Result<(Type, Span)> {
|
||||
pub fn parse_type(&mut self) -> Result<(Type, Span)> {
|
||||
let span = self.expect_any(TYPE_TOKENS)?;
|
||||
Ok((
|
||||
match &self.prev_token.token {
|
||||
@ -71,15 +68,4 @@ impl ParserContext<'_> {
|
||||
span,
|
||||
))
|
||||
}
|
||||
|
||||
/// Returns a [`(Type, Span)`] tuple of AST nodes if the next token represents a type.
|
||||
/// Also returns the span of the parsed token.
|
||||
pub fn parse_all_types(&mut self) -> Result<(Type, Span)> {
|
||||
Ok(if let Some(ident) = self.eat_identifier() {
|
||||
let span = ident.span.clone();
|
||||
(Type::Identifier(ident), span)
|
||||
} else {
|
||||
self.parse_non_ident_types()?
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use std::{fmt, iter::Peekable, str::FromStr};
|
||||
|
||||
///
|
||||
/// Returns a new `StrTendril` string if an identifier can be eaten, otherwise returns [`None`].
|
||||
/// An identifier can be eaten if its bytes are at the front of the given `input_tendril` string.
|
||||
///
|
||||
fn eat_identifier(input: &mut Peekable<impl Iterator<Item = char>>) -> Option<String> {
|
||||
match input.peek() {
|
||||
None => return None,
|
||||
@ -41,9 +39,7 @@ fn eat_identifier(input: &mut Peekable<impl Iterator<Item = char>>) -> Option<St
|
||||
Some(ident)
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks if a char is a Unicode Bidirectional Override code point
|
||||
///
|
||||
fn is_bidi_override(c: char) -> bool {
|
||||
let i = c as u32;
|
||||
(0x202A..=0x202E).contains(&i) || (0x2066..=0x2069).contains(&i)
|
||||
@ -150,9 +146,7 @@ impl Token {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a `char` if a character can be eaten, otherwise returns [`None`].
|
||||
///
|
||||
fn eat_char(input: &mut Peekable<impl Iterator<Item = char>>) -> Result<(usize, Char)> {
|
||||
match input.next() {
|
||||
None => Err(ParserError::lexer_empty_input_tendril().into()),
|
||||
@ -161,10 +155,8 @@ impl Token {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a tuple: [(integer length, integer token)] if an integer can be eaten, otherwise returns [`None`].
|
||||
/// An integer can be eaten if its bytes are at the front of the given `input_tendril` string.
|
||||
///
|
||||
fn eat_integer(input: &mut Peekable<impl Iterator<Item = char>>) -> Result<(usize, Token)> {
|
||||
if input.peek().is_none() {
|
||||
return Err(ParserError::lexer_empty_input_tendril().into());
|
||||
@ -184,10 +176,8 @@ impl Token {
|
||||
Ok((int.len(), Token::Int(int)))
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns a tuple: [(token length, token)] if the next token can be eaten, otherwise returns [`None`].
|
||||
/// The next token can be eaten if the bytes at the front of the given `input_tendril` string can be scanned into a token.
|
||||
///
|
||||
pub(crate) fn eat(input_tendril: &str) -> Result<(usize, Token)> {
|
||||
if input_tendril.is_empty() {
|
||||
return Err(ParserError::lexer_empty_input_tendril().into());
|
||||
@ -481,9 +471,7 @@ impl fmt::Debug for SpannedToken {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns true if the given string is a valid Aleo address.
|
||||
///
|
||||
pub(crate) fn check_address(address: &str) -> bool {
|
||||
Address::<Testnet2>::from_str(address).is_ok()
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
//! such that it applies changes to the AST nodes for canonicalization.
|
||||
//! An example of these changes are transforming Self -> to the circuit name.
|
||||
|
||||
use std::cell::RefCell;
|
||||
|
||||
use leo_ast::*;
|
||||
use leo_errors::{AstError, Result};
|
||||
use leo_span::{sym, Span, Symbol};
|
||||
@ -104,23 +106,14 @@ impl Canonicalizer {
|
||||
}
|
||||
}
|
||||
|
||||
fn canonicalize_self_type(&self, type_option: Option<&Type>) -> Option<Type> {
|
||||
match type_option {
|
||||
Some(type_) => match type_ {
|
||||
Type::SelfType => Some(Type::Identifier(self.circuit_name.as_ref().unwrap().clone())),
|
||||
Type::Array(type_, dimensions) => Some(Type::Array(
|
||||
Box::new(self.canonicalize_self_type(Some(type_)).unwrap()),
|
||||
dimensions.clone(),
|
||||
)),
|
||||
Type::Tuple(types) => Some(Type::Tuple(
|
||||
types
|
||||
.iter()
|
||||
.map(|type_| self.canonicalize_self_type(Some(type_)).unwrap())
|
||||
.collect(),
|
||||
)),
|
||||
_ => Some(type_.clone()),
|
||||
},
|
||||
None => None,
|
||||
fn canonicalize_self_type(&self, type_: &Type) -> Type {
|
||||
match type_ {
|
||||
Type::SelfType => Type::Identifier(self.circuit_name.as_ref().unwrap().clone()),
|
||||
Type::Array(type_, dimensions) => {
|
||||
Type::Array(Box::new(self.canonicalize_self_type(type_)), dimensions.clone())
|
||||
}
|
||||
Type::Tuple(types) => Type::Tuple(types.iter().map(|type_| self.canonicalize_self_type(type_)).collect()),
|
||||
_ => type_.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +167,7 @@ impl Canonicalizer {
|
||||
|
||||
Expression::Cast(cast) => {
|
||||
let inner = Box::new(self.canonicalize_expression(&cast.inner));
|
||||
let target_type = self.canonicalize_self_type(Some(&cast.target_type)).unwrap();
|
||||
let target_type = self.canonicalize_self_type(&cast.target_type);
|
||||
|
||||
return Expression::Cast(CastExpression {
|
||||
inner,
|
||||
@ -231,7 +224,7 @@ impl Canonicalizer {
|
||||
AccessExpression::Static(static_access) => AccessExpression::Static(StaticAccess {
|
||||
inner: Box::new(self.canonicalize_expression(&static_access.inner)),
|
||||
name: static_access.name.clone(),
|
||||
type_: self.canonicalize_self_type(static_access.type_.as_ref()),
|
||||
type_: RefCell::new(self.canonicalize_self_type(&static_access.type_.borrow())),
|
||||
span: static_access.span.clone(),
|
||||
}),
|
||||
};
|
||||
@ -371,7 +364,7 @@ impl Canonicalizer {
|
||||
}
|
||||
Statement::Definition(definition) => {
|
||||
let value = self.canonicalize_expression(&definition.value);
|
||||
let type_ = self.canonicalize_self_type(definition.type_.as_ref());
|
||||
let type_ = self.canonicalize_self_type(&definition.type_);
|
||||
|
||||
Statement::Definition(DefinitionStatement {
|
||||
declaration_type: definition.declaration_type.clone(),
|
||||
@ -408,12 +401,14 @@ impl Canonicalizer {
|
||||
})
|
||||
}
|
||||
Statement::Iteration(iteration) => {
|
||||
let type_ = self.canonicalize_self_type(&iteration.type_);
|
||||
let start = self.canonicalize_expression(&iteration.start);
|
||||
let stop = self.canonicalize_expression(&iteration.stop);
|
||||
let block = self.canonicalize_block(&iteration.block);
|
||||
|
||||
Statement::Iteration(Box::new(IterationStatement {
|
||||
variable: iteration.variable.clone(),
|
||||
type_,
|
||||
start,
|
||||
stop,
|
||||
inclusive: iteration.inclusive,
|
||||
@ -462,7 +457,7 @@ impl Canonicalizer {
|
||||
|
||||
fn canonicalize_function_input(&mut self, input: &FunctionInput) -> FunctionInput {
|
||||
if let FunctionInput::Variable(variable) = input {
|
||||
let type_ = self.canonicalize_self_type(Some(&variable.type_)).unwrap();
|
||||
let type_ = self.canonicalize_self_type(&variable.type_);
|
||||
|
||||
return FunctionInput::Variable(FunctionInputVariable {
|
||||
identifier: variable.identifier.clone(),
|
||||
@ -492,7 +487,7 @@ impl Canonicalizer {
|
||||
.iter()
|
||||
.map(|input| self.canonicalize_function_input(input))
|
||||
.collect();
|
||||
let output = self.canonicalize_self_type(function.output.as_ref());
|
||||
let output = self.canonicalize_self_type(&function.output);
|
||||
let block = self.canonicalize_block(&function.block);
|
||||
|
||||
return CircuitMember::CircuitFunction(Box::new(Function {
|
||||
@ -617,7 +612,7 @@ impl ReconstructingReducer for Canonicalizer {
|
||||
&mut self,
|
||||
definition: &DefinitionStatement,
|
||||
variable_names: Vec<VariableName>,
|
||||
type_: Option<Type>,
|
||||
type_: Type,
|
||||
value: Expression,
|
||||
) -> Result<DefinitionStatement> {
|
||||
let type_ = self.canonicalize_self_type(type_.as_ref());
|
||||
@ -677,20 +672,15 @@ impl ReconstructingReducer for Canonicalizer {
|
||||
annotations: IndexMap<Symbol, Annotation>,
|
||||
input: Vec<FunctionInput>,
|
||||
const_: bool,
|
||||
output: Option<Type>,
|
||||
output: Type,
|
||||
block: Block,
|
||||
) -> Result<Function> {
|
||||
let new_output = match output {
|
||||
None => Some(Type::Tuple(vec![])),
|
||||
_ => output,
|
||||
};
|
||||
|
||||
Ok(Function {
|
||||
identifier,
|
||||
annotations,
|
||||
input,
|
||||
const_,
|
||||
output: new_output,
|
||||
output,
|
||||
block,
|
||||
core_mapping: function.core_mapping.clone(),
|
||||
span: function.span.clone(),
|
||||
|
9
disabled_tests/parser/circuits/consts.leo
Normal file
9
disabled_tests/parser/circuits/consts.leo
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
namespace: Parse
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
circuit X {
|
||||
static const x: u32 = 2u32;
|
||||
static const y: u32 = 5u32;
|
||||
}
|
16
disabled_tests/parser/circuits/field_and_functions.leo
Normal file
16
disabled_tests/parser/circuits/field_and_functions.leo
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
namespace: Parse
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
circuit X {
|
||||
static const a: u8 = 10u8;
|
||||
x: u32,
|
||||
y: u32
|
||||
function x() {
|
||||
return ();
|
||||
}
|
||||
function y() {
|
||||
return ();
|
||||
}
|
||||
}
|
14
disabled_tests/parser/expression/access/array_access.leo
Normal file
14
disabled_tests/parser/expression/access/array_access.leo
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
x[0u8]
|
||||
X[1u8]
|
||||
x[0u8]
|
||||
x[1u8][2u8]
|
||||
x[x][y][z]
|
||||
x[0u8]()
|
||||
x()[0u8]
|
||||
x(y)::y(x)
|
||||
x[x].0[x]
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
x[..]
|
||||
x[1u8..]
|
||||
x[..1u8]
|
||||
x[1u8..1u8]
|
||||
x[0u8..100u8]
|
||||
|
||||
x[323452345u8.2345234523453453][323452345u8.2345234523453453]
|
||||
|
||||
x[0u8..1u8]
|
||||
x[0u8..]
|
||||
x[..0u8]
|
||||
|
||||
x[..]
|
||||
x[x.y..]
|
||||
x[..y.x]
|
||||
x[x.y..y.x]
|
||||
x[x.y.x..y.x.y]
|
15
disabled_tests/parser/expression/access/call.leo
Normal file
15
disabled_tests/parser/expression/access/call.leo
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
x()
|
||||
X()
|
||||
x(y)
|
||||
x(y, z)
|
||||
x(x, y, z)
|
||||
|
||||
x::y()
|
||||
x::y(x)
|
||||
x.0(x)
|
||||
x[0u32](x)
|
11
disabled_tests/parser/expression/access/circuit.leo
Normal file
11
disabled_tests/parser/expression/access/circuit.leo
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
x.y
|
||||
X.Y
|
||||
x.y.z
|
||||
x.y()
|
||||
x.y.0
|
||||
x.y[1u8]
|
11
disabled_tests/parser/expression/access/circuit_static.leo
Normal file
11
disabled_tests/parser/expression/access/circuit_static.leo
Normal file
@ -0,0 +1,11 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
x::y
|
||||
X::Y
|
||||
x::y::z
|
||||
x::y()
|
||||
x::y.0
|
||||
x::y[1u8]
|
18
disabled_tests/parser/expression/array_init.leo
Normal file
18
disabled_tests/parser/expression/array_init.leo
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
[0u8; 1]
|
||||
|
||||
[0u8; 1]
|
||||
|
||||
[0u8; (1)]
|
||||
|
||||
[0u8; (1, 2)]
|
||||
|
||||
[0u8; (1, 2,)]
|
||||
|
||||
[0u8; (1, 2, 3)]
|
||||
|
||||
[[[0u8; 3]; 2]; 1]
|
24
disabled_tests/parser/expression/array_inline.leo
Normal file
24
disabled_tests/parser/expression/array_inline.leo
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
[0u8, 1u8, 2u8, 3u8]
|
||||
|
||||
[1u8]
|
||||
|
||||
[1u8]
|
||||
|
||||
[1u8,]
|
||||
|
||||
[0u8, 1u8,]
|
||||
|
||||
[0u8,1u8,]
|
||||
|
||||
[]
|
||||
|
||||
[[1u8,2u8,3u8],[1u8,2u8,3u8]]
|
||||
|
||||
[[]]
|
||||
|
||||
[[], []]
|
16
disabled_tests/parser/expression/array_len.leo
Normal file
16
disabled_tests/parser/expression/array_len.leo
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
[0u8; 1].len()
|
||||
|
||||
[0u8; 1].len()
|
||||
|
||||
[0u8; (1)].len()
|
||||
|
||||
[0u8; (1, 2)].len()
|
||||
|
||||
[0u8; (1, 2, 3)].len()
|
||||
|
||||
[[[0u8; 3]; 2]; 1].len()
|
19
disabled_tests/parser/expression/tuple.leo
Normal file
19
disabled_tests/parser/expression/tuple.leo
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
namespace: ParseExpression
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
//not tuples
|
||||
(x)
|
||||
(y)
|
||||
(z)
|
||||
|
||||
//tuples
|
||||
(x,)
|
||||
(x,y)
|
||||
(x,y,z)
|
||||
(123u32,123u8)
|
||||
|
||||
()
|
||||
|
||||
(())
|
34
disabled_tests/parser/input/input_success.leo
Normal file
34
disabled_tests/parser/input/input_success.leo
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
namespace: Input
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
[main]
|
||||
a: bool = true;
|
||||
b: u8 = 2u8;
|
||||
c: field = 0field;
|
||||
d: group = (0, 1)group;
|
||||
e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
f: [u8; 32] = [0u8; 32];
|
||||
g: [[u8; 2]; 3] = [[0u8; 2]; 3];
|
||||
h: (bool, bool) = (true, false);
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
r1: u8 = 2u8;
|
||||
r2: field = 0field;
|
||||
r3: group = (0, 1)group;
|
||||
r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
r5: [u8; 32] = [0u8; 32];
|
||||
r6: [[u8; 2]; 3] = [[0u8; 2]; 3];
|
||||
r7: (bool, bool) = (true, false);
|
||||
|
||||
[constants]
|
||||
c0: bool = true;
|
||||
c1: u8 = 2u8;
|
||||
c2: field = 0field;
|
||||
c3: group = (0, 1)group;
|
||||
c4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||
c5: [u8; 32] = [0u8; 32];
|
||||
c6: [[u8; 2]; 3] = [[0u8; 2]; 3];
|
||||
c7: (bool, bool) = (true, false);
|
70
disabled_tests/parser/serialize/linear_regression.leo
Normal file
70
disabled_tests/parser/serialize/linear_regression.leo
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
namespace: Serialize
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
circuit Point {
|
||||
x: i32,
|
||||
y: i32,
|
||||
|
||||
function new(x: i32, y: i32) -> Self {
|
||||
return Self { x, y };
|
||||
}
|
||||
}
|
||||
|
||||
circuit LinearRegression {
|
||||
points: [Point; 5],
|
||||
|
||||
// Instantiates a linear regression circuit.
|
||||
function new(points: [Point; 5]) -> Self {
|
||||
return Self { points };
|
||||
}
|
||||
|
||||
// Return the slope of the linear regression.
|
||||
function slope(self) -> i32 {
|
||||
|
||||
let num_points: i32 = 5i32;
|
||||
// Calculate the sums.
|
||||
let x_sum: i32 = 0i32;
|
||||
let y_sum: i32 = 0i32;
|
||||
let xy_sum: i32 = 0i32;
|
||||
let x2_sum: i32 = 0i32;
|
||||
for i: u32 in 0u32..5u32 {
|
||||
x_sum += self.points[i].x;
|
||||
y_sum += self.points[i].y;
|
||||
xy_sum += self.points[i].x * self.points[i].y;
|
||||
x2_sum += self.points[i].x * self.points[i].x;
|
||||
}
|
||||
let numerator: i32 = (num_points * xy_sum) - (x_sum * y_sum);
|
||||
let denominator: i32 = (num_points * x2_sum) - (x_sum * x_sum);
|
||||
let slope: i32 = numerator / denominator;
|
||||
return slope;
|
||||
}
|
||||
// Return the offset of the linear regression.
|
||||
function offset(self, slope: i32) -> i32 {
|
||||
let num_points: i32 = 5i32;
|
||||
// Calculate the sum.
|
||||
let x_sum: i32 = 0i32;
|
||||
let y_sum: i32 = 0i32;
|
||||
for i: u32 in 0u32..5u32 {
|
||||
x_sum += self.points[i].x;
|
||||
y_sum += self.points[i].y;
|
||||
}
|
||||
return (y_sum - slope * x_sum) / num_points;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function main (x: i32, y: i32) -> [i32; 2] {
|
||||
let points: [Point; 5] = [
|
||||
Point{x: x + 1i32, y: y + 1i32},
|
||||
Point{x: x + 2i32, y: y + 2i32},
|
||||
Point{x: x + 3i32, y: y + 3i32},
|
||||
Point{x: x + 4i32, y: y + 4i32},
|
||||
Point{x: x + 5i32, y: y + 5i32}
|
||||
];
|
||||
let reg: LinearRegression = LinearRegression::new(points);
|
||||
let slope: i32 = reg.slope();
|
||||
let offset: i32 = reg.offset(slope);
|
||||
return [slope, offset];
|
||||
}
|
64
disabled_tests/parser/serialize/palindrome.leo
Normal file
64
disabled_tests/parser/serialize/palindrome.leo
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
namespace: Serialize
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
// This Program takes in any 20-byte low register string and tells
|
||||
// whether a string is a palindrome ignoring any spaces.
|
||||
|
||||
function main(str: [char; 20]) -> bool {
|
||||
return is_palindrome(str);
|
||||
}
|
||||
|
||||
function is_palindrome(str: [char; 20]) -> bool {
|
||||
const str_len: u32 = 20u32; // saving const for convenience
|
||||
|
||||
// By default we assume that input is a palindrome.
|
||||
let result: bool = true;
|
||||
let processed: u8 = 0u8;
|
||||
|
||||
for start: u32 in 0u32..(str_len / 2u32) {
|
||||
let start_sym: char = str[start];
|
||||
if start_sym != ' ' {
|
||||
let skipped: u8 = 0u8;
|
||||
let end_empty: u8 = 0u8;
|
||||
let end_sym: char = ' ';
|
||||
|
||||
for end: u32 in (str_len - 1u32)..start {
|
||||
if str[end] != ' ' && skipped == processed && end_sym == ' ' {
|
||||
end_sym = str[end];
|
||||
} else {
|
||||
end_empty = end_empty + 1u8;
|
||||
if str[end] != ' ' {
|
||||
skipped = skipped + 1u8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there are symbols left to the right from the start.
|
||||
if end_sym != ' ' {
|
||||
console.log("Comparing: {} ? {}", start_sym, end_sym);
|
||||
|
||||
if result {
|
||||
result = (start_sym == end_sym);
|
||||
}
|
||||
|
||||
processed = processed + 1u8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Result is: {}", result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@test
|
||||
function test_is_palindrome() {
|
||||
console.assert(is_palindrome("a b a "));
|
||||
console.assert(is_palindrome("😀😀😀😀😀 😀😀😀😀😀"));
|
||||
console.assert(is_palindrome("borrow or rob "));
|
||||
console.assert(is_palindrome("bbbb aaaa aaaa bbbb"));
|
||||
console.assert(is_palindrome("aaaaaaaaaaaaaaaaaaaa"));
|
||||
console.assert(is_palindrome("taco cat "));
|
||||
}
|
30
disabled_tests/parser/serialize/pedersen_hash.leo
Normal file
30
disabled_tests/parser/serialize/pedersen_hash.leo
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
namespace: Serialize
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
circuit PedersenHash {
|
||||
parameters: [group; 256];
|
||||
|
||||
// Instantiates a Pedersen hash circuit
|
||||
function new(parameters: [group; 256]) -> Self {
|
||||
return Self { parameters: parameters };
|
||||
}
|
||||
|
||||
function hash(self, bits: [bool; 256]) -> group {
|
||||
let digest: group = 0group;
|
||||
for i: u32 in u32..256u32 {
|
||||
if bits[i] {
|
||||
digest += self.parameters[i];
|
||||
}
|
||||
}
|
||||
return digest;
|
||||
}
|
||||
}
|
||||
|
||||
// The 'pedersen-hash' main function.
|
||||
function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group {
|
||||
const pedersen: PerdesenHash = PedersenHash::new(parameters);
|
||||
return pedersen.hash(hash_input);
|
||||
}
|
||||
|
Binary file not shown.
@ -288,6 +288,14 @@ create_messages!(
|
||||
help: None,
|
||||
}
|
||||
|
||||
/// When the user tries to pass an implicit value.
|
||||
@formatted
|
||||
implicit_values_not_allowed {
|
||||
args: (input: impl Display),
|
||||
msg: format!("Could not parse the implicit value: {}.", input),
|
||||
help: None,
|
||||
}
|
||||
|
||||
/// When a escaped unicode char was given but no following closing symbol.
|
||||
@backtraced
|
||||
lexer_unclosed_escaped_unicode_char {
|
||||
|
@ -6,7 +6,7 @@ input_file: inputs/branch.in
|
||||
|
||||
|
||||
function main (x: address, y: bool) -> bool {
|
||||
let z = aleo18cw5zdez3zhypev3tnfhmwvhre9ramwle4up947gcyy5rnmjw5yqn93wsr;
|
||||
let z: address = aleo18cw5zdez3zhypev3tnfhmwvhre9ramwle4up947gcyy5rnmjw5yqn93wsr;
|
||||
if y {
|
||||
z = aleo1f2gs8g0qpumlgzpvmkw3q07y6xrwsdr0lqsu9h9fgnh8d7e44v9qhpgpkj;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ input_file:
|
||||
*/
|
||||
|
||||
function main(x: address) -> bool {
|
||||
const sender = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8s7pyjh9;
|
||||
const sender: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8s7pyjh9;
|
||||
|
||||
return x == sender;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ input_file:
|
||||
*/
|
||||
|
||||
function main(x: address) -> bool {
|
||||
const sender = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8s7pyjh9;
|
||||
const receiver = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpqy3sr3p;
|
||||
const sender: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8s7pyjh9;
|
||||
const receiver: address = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpqy3sr3p;
|
||||
|
||||
return x == sender ? receiver == x : sender == x;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
[main]
|
||||
a: u32 = 10;
|
||||
b: u32 = 100;
|
||||
a: u32 = 10u32;
|
||||
b: u32 = 100u32;
|
||||
y: bool = true;
|
||||
|
||||
[registers]
|
||||
|
@ -1,7 +1,7 @@
|
||||
[main]
|
||||
a: u32 = 0;
|
||||
b: u32 = 0;
|
||||
a: u32 = 0u32;
|
||||
b: u32 = 0u32;
|
||||
|
||||
[registers]
|
||||
a: u32 = 0;
|
||||
b: u32 = 0;
|
||||
a: u32 = 0u32;
|
||||
b: u32 = 0u32;
|
@ -9,9 +9,9 @@ function one() -> u32 {
|
||||
}
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
let a = 0u32;
|
||||
let a: u32 = 0u32;
|
||||
|
||||
for i in 0..10 {
|
||||
for i: u32 in 0u32..10u32 {
|
||||
a = a + one();
|
||||
}
|
||||
|
||||
|
@ -5,17 +5,17 @@ input_file: input/dummy.in
|
||||
*/
|
||||
|
||||
function iteration() -> u32 {
|
||||
let a = 0u32;
|
||||
let a: u32 = 0u32;
|
||||
|
||||
for i in 0..10 {
|
||||
a = a + 1;
|
||||
for i: u32 in 0u32..10u32 {
|
||||
a = a + 1u32;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
const total = iteration() + iteration();
|
||||
const total: u32 = iteration() + iteration();
|
||||
|
||||
return (total == 20) == y;
|
||||
return (total == 20u32) == y;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ function one() -> bool {
|
||||
}
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
const a = one() && one();
|
||||
const a: bool = one() && one();
|
||||
|
||||
return (a == true) == y;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[main]
|
||||
a: field = 1;
|
||||
b: field = -1;
|
||||
a: field = 1field;
|
||||
b: field = -1field;
|
||||
y: bool = true;
|
||||
|
||||
[registers]
|
||||
|
@ -4,9 +4,10 @@ expectation: Pass
|
||||
input_file: input/main_group.in
|
||||
*/
|
||||
|
||||
function main(a: group, b: group, c: group) {
|
||||
function main(a: group, b: group, c: group) -> bool {
|
||||
// Change to assert when == is implemented for group.
|
||||
console.log("a: {}", a);
|
||||
console.log("b: {}", b);
|
||||
console.log("c: {}", c);
|
||||
return true;
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
y: bool = true;
|
||||
|
||||
[constants]
|
||||
a: field = 1;
|
||||
b: field = -1;
|
||||
a: field = 1field;
|
||||
b: field = -1field;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
|
@ -1,15 +1,7 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = 1;
|
||||
b: i128 = 2;
|
||||
c: i128 = 3;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = 1;
|
||||
b: i128 = 1;
|
||||
input_file: inputs/eq.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128) {
|
||||
console.assert(a == b);
|
||||
function main(a: i128, b: i128) -> bool {
|
||||
let ret: bool = a == b;
|
||||
console.assert(ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = 4;
|
||||
b: i128 = 2;
|
||||
c: i128 = 2;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file: inputs/div.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
|
@ -1,15 +1,7 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = 2;
|
||||
b: i128 = 2;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file: inputs/eq.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: bool) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128_e.in: |
|
||||
[main]
|
||||
a: i128 = 4;
|
||||
b: i128 = 4;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
- i128_g.in: |
|
||||
[main]
|
||||
a: i128 = 5;
|
||||
b: i128 = 4;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/ge.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: bool) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128_g.in: |
|
||||
[main]
|
||||
a: i128 = 4;
|
||||
b: i128 = 2;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
- i128_e.in: |
|
||||
[main]
|
||||
a: i128 = 4;
|
||||
b: i128 = 4;
|
||||
c: bool = false;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/gt.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: bool) -> bool {
|
||||
|
7
tests/compiler/integers/i128/inputs/add.in
Normal file
7
tests/compiler/integers/i128/inputs/add.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 1i128;
|
||||
b: i128 = 2i128;
|
||||
c: i128 = 3i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i128/inputs/div.in
Normal file
7
tests/compiler/integers/i128/inputs/div.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 4i128;
|
||||
b: i128 = 2i128;
|
||||
c: i128 = 2i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i128/inputs/eq.in
Normal file
7
tests/compiler/integers/i128/inputs/eq.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 2i128;
|
||||
b: i128 = 2i128;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i128/inputs/ge.in
Normal file
7
tests/compiler/integers/i128/inputs/ge.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 5i128;
|
||||
b: i128 = 4i128;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i128/inputs/gt.in
Normal file
7
tests/compiler/integers/i128/inputs/gt.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 4i128;
|
||||
b: i128 = 2i128;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i128/inputs/le.in
Normal file
7
tests/compiler/integers/i128/inputs/le.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 1i128;
|
||||
b: i128 = 100i128;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i128/inputs/lt.in
Normal file
7
tests/compiler/integers/i128/inputs/lt.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 2i128;
|
||||
b: i128 = 4i128;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
7
tests/compiler/integers/i128/inputs/mul.in
Normal file
7
tests/compiler/integers/i128/inputs/mul.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 2i128;
|
||||
b: i128 = 5i128;
|
||||
c: i128 = 10i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
7
tests/compiler/integers/i128/inputs/ne.in
Normal file
7
tests/compiler/integers/i128/inputs/ne.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 2i128;
|
||||
b: i128 = 5i128;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
6
tests/compiler/integers/i128/inputs/neg.in
Normal file
6
tests/compiler/integers/i128/inputs/neg.in
Normal file
@ -0,0 +1,6 @@
|
||||
[main]
|
||||
a: i128 = 5i128;
|
||||
b: i128 = -5i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
6
tests/compiler/integers/i128/inputs/neg_rev.in
Normal file
6
tests/compiler/integers/i128/inputs/neg_rev.in
Normal file
@ -0,0 +1,6 @@
|
||||
[main]
|
||||
a: i128 = -5i128;
|
||||
b: i128 = 5i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
7
tests/compiler/integers/i128/inputs/sub.in
Normal file
7
tests/compiler/integers/i128/inputs/sub.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i128 = 100i128;
|
||||
b: i128 = 50i128;
|
||||
c: i128 = 50i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
8
tests/compiler/integers/i128/inputs/tern.in
Normal file
8
tests/compiler/integers/i128/inputs/tern.in
Normal file
@ -0,0 +1,8 @@
|
||||
[main]
|
||||
s: bool = true;
|
||||
a: i128 = 10i128;
|
||||
b: i128 = 5i128;
|
||||
c: i128 = 10i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
8
tests/compiler/integers/i128/inputs/tern_rev.in
Normal file
8
tests/compiler/integers/i128/inputs/tern_rev.in
Normal file
@ -0,0 +1,8 @@
|
||||
[main]
|
||||
s: bool = false;
|
||||
a: i128 = 10i128;
|
||||
b: i128 = 5i128;
|
||||
c: i128 = 5i128;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128_l.in: |
|
||||
[main]
|
||||
a: i128 = 1;
|
||||
b: i128 = 100;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
- i128_e.in: |
|
||||
[main]
|
||||
a: i128 = 2;
|
||||
b: i128 = 2;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/le.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: bool) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128_l.in: |
|
||||
[main]
|
||||
a: i128 = 2;
|
||||
b: i128 = 4;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
- i128_e.in: |
|
||||
[main]
|
||||
a: i128 = 2;
|
||||
b: i128 = 2;
|
||||
c: bool = false;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/lt.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: bool) -> bool{
|
||||
|
@ -5,6 +5,6 @@ input_file: ../input/dummy.in
|
||||
*/
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
const a: i128 = 170141183460469231731687303715884105727;
|
||||
const a: i128 = 170141183460469231731687303715884105727i128;
|
||||
return y == true;
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ input_file: ../input/dummy.in
|
||||
*/
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
const a: i128 = -170141183460469231731687303715884105728;
|
||||
const a: i128 = -170141183460469231731687303715884105728i128;
|
||||
return y == true;
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = 2;
|
||||
b: i128 = 5;
|
||||
c: i128 = 10;
|
||||
input_file:
|
||||
- inputs/mul.in
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128_ne.in: |
|
||||
[main]
|
||||
a: i128 = 2;
|
||||
b: i128 = 5;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
- i128_e.in: |
|
||||
[main]
|
||||
a: i128 = 5;
|
||||
b: i128 = 5;
|
||||
c: bool = false;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/ne.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: bool) -> bool{
|
||||
|
@ -1,21 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = 5;
|
||||
b: i128 = -5;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = -5;
|
||||
b: i128 = 5;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/neg.in
|
||||
- inputs/neg_rev.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128) -> bool {
|
||||
|
@ -1,17 +1,12 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- dummy.in: |
|
||||
[main]
|
||||
y: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- ../input/dummy.in
|
||||
*/
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
const a = 0i128;
|
||||
const a: i128 = 0i128;
|
||||
|
||||
return (-a == 0i128) == y;
|
||||
}
|
||||
|
@ -1,15 +1,8 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
a: i128 = 100;
|
||||
b: i128 = 50;
|
||||
c: i128 = 50;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/sub.in
|
||||
*/
|
||||
|
||||
function main(a: i128, b: i128, c: i128) -> bool {
|
||||
|
@ -1,29 +1,13 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i128.in: |
|
||||
[main]
|
||||
s: bool = true;
|
||||
a: i128 = 10;
|
||||
b: i128 = 5;
|
||||
c: i128 = 10;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
- i128_rev.in: |
|
||||
[main]
|
||||
s: bool = false;
|
||||
a: i128 = 10;
|
||||
b: i128 = 5;
|
||||
c: i128 = 5;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/tern.in
|
||||
- inputs/tern_rev.in
|
||||
*/
|
||||
|
||||
function main(s: bool, a: i128, b: i128, c: i128) -> bool {
|
||||
let r = s ? a : b;
|
||||
let r: i128 = s ? a : b;
|
||||
|
||||
return r == c;
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16.in: |
|
||||
[main]
|
||||
a: i16 = 1;
|
||||
b: i16 = 2;
|
||||
c: i16 = 3;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file: inputs/add.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
|
@ -1,13 +1,11 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16.in: |
|
||||
[main]
|
||||
a: i16 = 1;
|
||||
b: i16 = 1;
|
||||
input_file: inputs/eq.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16) {
|
||||
console.assert(a == b);
|
||||
function main(a: i16, b: i16) -> bool {
|
||||
let ret: bool = a == b;
|
||||
console.assert(ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,15 +1,7 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16.in: |
|
||||
[main]
|
||||
a: i16 = 4;
|
||||
b: i16 = 2;
|
||||
c: i16 = 2;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file: inputs/div.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
|
@ -1,15 +1,7 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16.in: |
|
||||
[main]
|
||||
a: i16 = 2;
|
||||
b: i16 = 2;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file: inputs/eq.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: bool) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16_e.in: |
|
||||
[main]
|
||||
a: i16 = 4;
|
||||
b: i16 = 4;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
- i16_g.in: |
|
||||
[main]
|
||||
a: i16 = 5;
|
||||
b: i16 = 4;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/ge.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: bool) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16_g.in: |
|
||||
[main]
|
||||
a: i16 = 4;
|
||||
b: i16 = 2;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
- i16_e.in: |
|
||||
[main]
|
||||
a: i16 = 4;
|
||||
b: i16 = 4;
|
||||
c: bool = false;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/gt.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: bool) -> bool {
|
||||
|
7
tests/compiler/integers/i16/inputs/add.in
Normal file
7
tests/compiler/integers/i16/inputs/add.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 1i16;
|
||||
b: i16 = 2i16;
|
||||
c: i16 = 3i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i16/inputs/div.in
Normal file
7
tests/compiler/integers/i16/inputs/div.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 4i16;
|
||||
b: i16 = 2i16;
|
||||
c: i16 = 2i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i16/inputs/eq.in
Normal file
7
tests/compiler/integers/i16/inputs/eq.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 2i16;
|
||||
b: i16 = 2i16;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i16/inputs/ge.in
Normal file
7
tests/compiler/integers/i16/inputs/ge.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 5i16;
|
||||
b: i16 = 4i16;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i16/inputs/gt.in
Normal file
7
tests/compiler/integers/i16/inputs/gt.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 4i16;
|
||||
b: i16 = 2i16;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i16/inputs/le.in
Normal file
7
tests/compiler/integers/i16/inputs/le.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 1i16;
|
||||
b: i16 = 100i16;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i16/inputs/lt.in
Normal file
7
tests/compiler/integers/i16/inputs/lt.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 2i16;
|
||||
b: i16 = 4i16;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
7
tests/compiler/integers/i16/inputs/mul.in
Normal file
7
tests/compiler/integers/i16/inputs/mul.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 2i16;
|
||||
b: i16 = 5i16;
|
||||
c: i16 = 10i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
7
tests/compiler/integers/i16/inputs/ne.in
Normal file
7
tests/compiler/integers/i16/inputs/ne.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 2i16;
|
||||
b: i16 = 5i16;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
6
tests/compiler/integers/i16/inputs/neg.in
Normal file
6
tests/compiler/integers/i16/inputs/neg.in
Normal file
@ -0,0 +1,6 @@
|
||||
[main]
|
||||
a: i16 = 5i16;
|
||||
b: i16 = -5i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
6
tests/compiler/integers/i16/inputs/neg_rev.in
Normal file
6
tests/compiler/integers/i16/inputs/neg_rev.in
Normal file
@ -0,0 +1,6 @@
|
||||
[main]
|
||||
a: i16 = -5i16;
|
||||
b: i16 = 5i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
7
tests/compiler/integers/i16/inputs/pow.in
Normal file
7
tests/compiler/integers/i16/inputs/pow.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 2i16;
|
||||
b: i16 = 2i16;
|
||||
c: i16 = 4i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
7
tests/compiler/integers/i16/inputs/sub.in
Normal file
7
tests/compiler/integers/i16/inputs/sub.in
Normal file
@ -0,0 +1,7 @@
|
||||
[main]
|
||||
a: i16 = 100i16;
|
||||
b: i16 = 50i16;
|
||||
c: i16 = 50i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
8
tests/compiler/integers/i16/inputs/tern.in
Normal file
8
tests/compiler/integers/i16/inputs/tern.in
Normal file
@ -0,0 +1,8 @@
|
||||
[main]
|
||||
s: bool = true;
|
||||
a: i16 = 10i16;
|
||||
b: i16 = 5i16;
|
||||
c: i16 = 10i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
8
tests/compiler/integers/i16/inputs/tern_rev.in
Normal file
8
tests/compiler/integers/i16/inputs/tern_rev.in
Normal file
@ -0,0 +1,8 @@
|
||||
[main]
|
||||
s: bool = false;
|
||||
a: i16 = 10i16;
|
||||
b: i16 = 5i16;
|
||||
c: i16 = 5i16;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16_l.in: |
|
||||
[main]
|
||||
a: i16 = 1;
|
||||
b: i16 = 100;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
- i16_e.in: |
|
||||
[main]
|
||||
a: i16 = 2;
|
||||
b: i16 = 2;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = true;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/le.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: bool) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16_l.in: |
|
||||
[main]
|
||||
a: i16 = 2;
|
||||
b: i16 = 4;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
- i16_e.in: |
|
||||
[main]
|
||||
a: i16 = 2;
|
||||
b: i16 = 2;
|
||||
c: bool = false;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/lt.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: bool) -> bool{
|
||||
|
@ -5,6 +5,6 @@ input_file: ../input/dummy.in
|
||||
*/
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
const a: i16 = 32767;
|
||||
const a: i16 = 32767i16;
|
||||
return y == true;
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ input_file: ../input/dummy.in
|
||||
*/
|
||||
|
||||
function main(y: bool) -> bool {
|
||||
const a: i16 = -32768;
|
||||
const a: i16 = -32768i16;
|
||||
return y == true;
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16.in: |
|
||||
[main]
|
||||
a: i16 = 2;
|
||||
b: i16 = 5;
|
||||
c: i16 = 10;
|
||||
input_file:
|
||||
- inputs/mul.in
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: i16) -> bool {
|
||||
|
@ -1,23 +1,9 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
inputs:
|
||||
- i16_ne.in: |
|
||||
[main]
|
||||
a: i16 = 2;
|
||||
b: i16 = 5;
|
||||
c: bool = true;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
- i16_e.in: |
|
||||
[main]
|
||||
a: i16 = 5;
|
||||
b: i16 = 5;
|
||||
c: bool = false;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
||||
input_file:
|
||||
- inputs/eq.in
|
||||
- inputs/ne.in
|
||||
*/
|
||||
|
||||
function main(a: i16, b: i16, c: bool) -> bool{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user