|
@@ -1,7 +1,7 @@
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
use super::symtable::Symtable;
|
|
use super::symtable::Symtable;
|
|
|
-use crate::abi::anchor::discriminator;
|
|
|
|
|
|
|
+use crate::abi::anchor::function_discriminator;
|
|
|
use crate::codegen::cfg::{ControlFlowGraph, Instr};
|
|
use crate::codegen::cfg::{ControlFlowGraph, Instr};
|
|
|
use crate::diagnostics::Diagnostics;
|
|
use crate::diagnostics::Diagnostics;
|
|
|
use crate::sema::ast::ExternalCallAccounts::{AbsentArgument, NoAccount};
|
|
use crate::sema::ast::ExternalCallAccounts::{AbsentArgument, NoAccount};
|
|
@@ -169,7 +169,7 @@ pub struct StructDecl {
|
|
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
|
|
pub struct EventDecl {
|
|
pub struct EventDecl {
|
|
|
pub tags: Vec<Tag>,
|
|
pub tags: Vec<Tag>,
|
|
|
- pub name: String,
|
|
|
|
|
|
|
+ pub id: pt::Identifier,
|
|
|
pub loc: pt::Loc,
|
|
pub loc: pt::Loc,
|
|
|
pub contract: Option<usize>,
|
|
pub contract: Option<usize>,
|
|
|
pub fields: Vec<Parameter>,
|
|
pub fields: Vec<Parameter>,
|
|
@@ -181,8 +181,8 @@ pub struct EventDecl {
|
|
|
impl EventDecl {
|
|
impl EventDecl {
|
|
|
pub fn symbol_name(&self, ns: &Namespace) -> String {
|
|
pub fn symbol_name(&self, ns: &Namespace) -> String {
|
|
|
match &self.contract {
|
|
match &self.contract {
|
|
|
- Some(c) => format!("{}.{}", ns.contracts[*c].id, self.name),
|
|
|
|
|
- None => self.name.to_string(),
|
|
|
|
|
|
|
+ Some(c) => format!("{}.{}", ns.contracts[*c].id, self.id),
|
|
|
|
|
+ None => self.id.to_string(),
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -468,14 +468,14 @@ impl Function {
|
|
|
selector.clone()
|
|
selector.clone()
|
|
|
} else if ns.target == Target::Solana {
|
|
} else if ns.target == Target::Solana {
|
|
|
match self.ty {
|
|
match self.ty {
|
|
|
- FunctionTy::Constructor => discriminator("global", "new"),
|
|
|
|
|
|
|
+ FunctionTy::Constructor => function_discriminator("new"),
|
|
|
_ => {
|
|
_ => {
|
|
|
let discriminator_image = if self.mangled_name_contracts.contains(contract_no) {
|
|
let discriminator_image = if self.mangled_name_contracts.contains(contract_no) {
|
|
|
&self.mangled_name
|
|
&self.mangled_name
|
|
|
} else {
|
|
} else {
|
|
|
&self.name
|
|
&self.name
|
|
|
};
|
|
};
|
|
|
- discriminator("global", discriminator_image.as_str())
|
|
|
|
|
|
|
+ function_discriminator(discriminator_image.as_str())
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
@@ -1198,6 +1198,11 @@ pub enum Expression {
|
|
|
function_no: usize,
|
|
function_no: usize,
|
|
|
args: Vec<Expression>,
|
|
args: Vec<Expression>,
|
|
|
},
|
|
},
|
|
|
|
|
+ EventSelector {
|
|
|
|
|
+ loc: pt::Loc,
|
|
|
|
|
+ ty: Type,
|
|
|
|
|
+ event_no: usize,
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, Clone, Default, Debug)]
|
|
#[derive(PartialEq, Eq, Clone, Default, Debug)]
|
|
@@ -1442,7 +1447,8 @@ impl Recurse for Expression {
|
|
|
| Expression::RationalNumberLiteral { .. }
|
|
| Expression::RationalNumberLiteral { .. }
|
|
|
| Expression::CodeLiteral { .. }
|
|
| Expression::CodeLiteral { .. }
|
|
|
| Expression::BytesLiteral { .. }
|
|
| Expression::BytesLiteral { .. }
|
|
|
- | Expression::BoolLiteral { .. } => (),
|
|
|
|
|
|
|
+ | Expression::BoolLiteral { .. }
|
|
|
|
|
+ | Expression::EventSelector { .. } => (),
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1516,7 +1522,8 @@ impl CodeLocation for Expression {
|
|
|
| Expression::InterfaceId { loc, .. }
|
|
| Expression::InterfaceId { loc, .. }
|
|
|
| Expression::And { loc, .. }
|
|
| Expression::And { loc, .. }
|
|
|
| Expression::NamedMember { loc, .. }
|
|
| Expression::NamedMember { loc, .. }
|
|
|
- | Expression::UserDefinedOperator { loc, .. } => *loc,
|
|
|
|
|
|
|
+ | Expression::UserDefinedOperator { loc, .. }
|
|
|
|
|
+ | Expression::EventSelector { loc, .. } => *loc,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|