merge dev
This commit is contained in:
commit
60309d2702
6 changed files with 24 additions and 25 deletions
|
@ -2208,16 +2208,19 @@ impl<'ast, T: Field> Flattener<'ast, T> {
|
|||
///
|
||||
/// * `prog` - `ZirProgram` that will be flattened.
|
||||
fn flatten_program(&mut self, prog: ZirProgram<'ast, T>) -> FlatProg<T> {
|
||||
let main_module = prog.modules.get(&prog.main).unwrap();
|
||||
let mut prog = prog;
|
||||
|
||||
let main = main_module
|
||||
let mut main_module = prog.modules.remove(&prog.main).unwrap();
|
||||
|
||||
let main_key = main_module
|
||||
.functions
|
||||
.iter()
|
||||
.find(|(k, _)| k.id == "main")
|
||||
.keys()
|
||||
.find(|k| k.id == "main")
|
||||
.unwrap()
|
||||
.1
|
||||
.clone();
|
||||
|
||||
let main = main_module.functions.remove(&main_key).unwrap();
|
||||
|
||||
let symbols = &main_module.functions;
|
||||
|
||||
let main_flattened = match main {
|
||||
|
|
|
@ -12,7 +12,7 @@ pub struct Flattener<T: Field> {
|
|||
|
||||
fn flatten_identifier_rec<'ast>(
|
||||
id: zir::SourceIdentifier<'ast>,
|
||||
ty: typed_absy::types::ConcreteType,
|
||||
ty: &typed_absy::types::ConcreteType,
|
||||
) -> Vec<zir::Variable<'ast>> {
|
||||
match ty {
|
||||
typed_absy::ConcreteType::Int => unreachable!(),
|
||||
|
@ -32,16 +32,16 @@ fn flatten_identifier_rec<'ast>(
|
|||
.flat_map(|i| {
|
||||
flatten_identifier_rec(
|
||||
zir::SourceIdentifier::Select(box id.clone(), i),
|
||||
*array_type.ty.clone(),
|
||||
&array_type.ty,
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
typed_absy::types::ConcreteType::Struct(members) => members
|
||||
.into_iter()
|
||||
.iter()
|
||||
.flat_map(|struct_member| {
|
||||
flatten_identifier_rec(
|
||||
zir::SourceIdentifier::Member(box id.clone(), struct_member.id),
|
||||
*struct_member.ty,
|
||||
zir::SourceIdentifier::Member(box id.clone(), struct_member.id.clone()),
|
||||
&struct_member.ty,
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
|
@ -99,7 +99,7 @@ impl<'ast, T: Field> Flattener<T> {
|
|||
|
||||
let ty = typed_absy::types::ConcreteType::try_from(ty).unwrap();
|
||||
|
||||
flatten_identifier_rec(id, ty)
|
||||
flatten_identifier_rec(id, &ty)
|
||||
}
|
||||
|
||||
fn fold_assignee(
|
||||
|
@ -293,7 +293,7 @@ pub fn fold_array_expression_inner<'ast, T: Field>(
|
|||
typed_absy::ArrayExpressionInner::Identifier(id) => {
|
||||
let variables = flatten_identifier_rec(
|
||||
f.fold_name(id),
|
||||
typed_absy::types::ConcreteType::array(t.clone(), size),
|
||||
&typed_absy::types::ConcreteType::array(t.clone(), size),
|
||||
);
|
||||
variables
|
||||
.into_iter()
|
||||
|
@ -390,7 +390,7 @@ pub fn fold_struct_expression_inner<'ast, T: Field>(
|
|||
typed_absy::StructExpressionInner::Identifier(id) => {
|
||||
let variables = flatten_identifier_rec(
|
||||
f.fold_name(id),
|
||||
typed_absy::types::ConcreteType::struc(t.clone()),
|
||||
&typed_absy::types::ConcreteType::struc(t.clone()),
|
||||
);
|
||||
variables
|
||||
.into_iter()
|
||||
|
@ -492,7 +492,7 @@ pub fn fold_field_expression<'ast, T: Field>(
|
|||
zir::FieldElementExpression::Identifier(
|
||||
flatten_identifier_rec(
|
||||
f.fold_name(id),
|
||||
typed_absy::types::ConcreteType::FieldElement,
|
||||
&typed_absy::types::ConcreteType::FieldElement,
|
||||
)[0]
|
||||
.id
|
||||
.clone(),
|
||||
|
@ -567,7 +567,7 @@ pub fn fold_boolean_expression<'ast, T: Field>(
|
|||
match e {
|
||||
typed_absy::BooleanExpression::Value(v) => zir::BooleanExpression::Value(v),
|
||||
typed_absy::BooleanExpression::Identifier(id) => zir::BooleanExpression::Identifier(
|
||||
flatten_identifier_rec(f.fold_name(id), typed_absy::types::ConcreteType::Boolean)[0]
|
||||
flatten_identifier_rec(f.fold_name(id), &typed_absy::types::ConcreteType::Boolean)[0]
|
||||
.id
|
||||
.clone(),
|
||||
),
|
||||
|
@ -751,7 +751,7 @@ pub fn fold_uint_expression_inner<'ast, T: Field>(
|
|||
typed_absy::UExpressionInner::Identifier(id) => zir::UExpressionInner::Identifier(
|
||||
flatten_identifier_rec(
|
||||
f.fold_name(id),
|
||||
typed_absy::types::ConcreteType::Uint(bitwidth),
|
||||
&typed_absy::types::ConcreteType::Uint(bitwidth),
|
||||
)[0]
|
||||
.id
|
||||
.clone(),
|
||||
|
|
|
@ -71,9 +71,4 @@ impl<'ast> Identifier<'ast> {
|
|||
self.version = version;
|
||||
self
|
||||
}
|
||||
|
||||
// pub fn stack(mut self, stack: Vec<(TypedModuleId, ConcreteFunctionKey<'ast>, usize)>) -> Self {
|
||||
// self.stack = stack;
|
||||
// self
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
### ZoKrates Ace Mode (Syntax Highlighting)
|
||||
### ZoKrates Ace Mode (Syntax Highlighting for Ace/Brace)
|
||||
|
||||
[Ace](https://ace.c9.io/) Edit Mode for [ZoKrates DSL](https://github.com/Zokrates/ZoKrates).
|
||||
Compatible with browserify version of the ace editor, [brace](https://www.npmjs.com/package/brace).
|
|
@ -37,7 +37,7 @@ ace.define("ace/mode/zokrates_highlight_rules",["require","exports","module","ac
|
|||
var ZoKratesHighlightRules = function () {
|
||||
|
||||
var keywords = (
|
||||
"assert|endfor|as|return|byte|field|bool|if|then|fi|do|else|export|false|def|for|import|from|uint|in|public|private|struct|true"
|
||||
"assert|as|bool|byte|def|do|else|endfor|export|false|field|for|if|then|fi|import|from|in|private|public|return|struct|true|u8|u16|u32"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
|
@ -68,7 +68,7 @@ ace.define("ace/mode/zokrates_highlight_rules",["require","exports","module","ac
|
|||
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||
}, {
|
||||
token: "keyword.operator",
|
||||
regex: "\\+|\\-|\\*|\\*\\*|\\/|\\|\\||&&|\\^|!|<|>|<=|=>|==|!=|="
|
||||
regex: "\\+|\\-|\\*\\*?|\\/|\\|\\|?|&&?|\\^|!|<<?|>>?|<=|=>|==|!=|="
|
||||
}, {
|
||||
token: "punctuation",
|
||||
regex: ",|:|;"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ace-mode-zokrates",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Ace Mode for ZoKrates DSL",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in a new issue