瀏覽代碼

Rename assembly to yul in Solang (#719)

* Rename assembly to yul in Solang Parser

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>

* Rename assembly to yul in Solang sema

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
Lucas Steuernagel 3 年之前
父節點
當前提交
4302102fc1

+ 3 - 3
solang-parser/src/lexer.rs

@@ -182,7 +182,7 @@ pub enum Token<'input> {
     Switch,
     Case,
     Default,
-    AssemblyArrow,
+    YulArrow,
 }
 
 impl<'input> fmt::Display for Token<'input> {
@@ -327,7 +327,7 @@ impl<'input> fmt::Display for Token<'input> {
             Token::Switch => write!(f, "switch"),
             Token::Case => write!(f, "case"),
             Token::Default => write!(f, "default"),
-            Token::AssemblyArrow => write!(f, "->"),
+            Token::YulArrow => write!(f, "->"),
         }
     }
 }
@@ -1089,7 +1089,7 @@ impl<'input> Lexer<'input> {
                         }
                         Some((_, '>')) => {
                             self.chars.next();
-                            Some(Ok((i, Token::AssemblyArrow, i + 2)))
+                            Some(Ok((i, Token::YulArrow, i + 2)))
                         }
                         _ => Some(Ok((i, Token::Subtract, i + 1))),
                     };

+ 48 - 52
solang-parser/src/pt.rs

@@ -608,7 +608,7 @@ pub enum Statement {
     Assembly {
         loc: Loc,
         dialect: Option<StringLiteral>,
-        block: AssemblyBlock,
+        block: YulBlock,
     },
     Args(Loc, Vec<NamedArgument>),
     If(Loc, Expression, Box<Statement>, Option<Box<Statement>>),
@@ -644,91 +644,87 @@ pub enum CatchClause {
 }
 
 #[derive(Debug, PartialEq, Clone)]
-pub enum AssemblyStatement {
-    Assign(Loc, Vec<AssemblyExpression>, AssemblyExpression),
-    VariableDeclaration(
-        Loc,
-        Vec<AssemblyTypedIdentifier>,
-        Option<AssemblyExpression>,
-    ),
-    If(Loc, AssemblyExpression, AssemblyBlock),
-    For(AssemblyFor),
-    Switch(AssemblySwitch),
+pub enum YulStatement {
+    Assign(Loc, Vec<YulExpression>, YulExpression),
+    VariableDeclaration(Loc, Vec<YulTypedIdentifier>, Option<YulExpression>),
+    If(Loc, YulExpression, YulBlock),
+    For(YulFor),
+    Switch(YulSwitch),
     Leave(Loc),
     Break(Loc),
     Continue(Loc),
-    Block(AssemblyBlock),
-    FunctionDefinition(Box<AssemblyFunctionDefinition>),
-    FunctionCall(Box<AssemblyFunctionCall>),
+    Block(YulBlock),
+    FunctionDefinition(Box<YulFunctionDefinition>),
+    FunctionCall(Box<YulFunctionCall>),
 }
 #[derive(PartialEq, Clone, Debug)]
-pub struct AssemblySwitch {
+pub struct YulSwitch {
     pub loc: Loc,
-    pub condition: AssemblyExpression,
-    pub cases: Vec<AssemblySwitchOptions>,
-    pub default: Option<AssemblySwitchOptions>,
+    pub condition: YulExpression,
+    pub cases: Vec<YulSwitchOptions>,
+    pub default: Option<YulSwitchOptions>,
 }
 
 #[derive(PartialEq, Clone, Debug)]
-pub struct AssemblyFor {
+pub struct YulFor {
     pub loc: Loc,
-    pub init_block: AssemblyBlock,
-    pub condition: AssemblyExpression,
-    pub post_block: AssemblyBlock,
-    pub execution_block: AssemblyBlock,
+    pub init_block: YulBlock,
+    pub condition: YulExpression,
+    pub post_block: YulBlock,
+    pub execution_block: YulBlock,
 }
 
 #[derive(Debug, PartialEq, Clone)]
-pub struct AssemblyBlock {
+pub struct YulBlock {
     pub loc: Loc,
-    pub statements: Vec<AssemblyStatement>,
+    pub statements: Vec<YulStatement>,
 }
 
 #[derive(Debug, PartialEq, Clone)]
-pub enum AssemblyExpression {
+pub enum YulExpression {
     BoolLiteral(Loc, bool, Option<Identifier>),
     NumberLiteral(Loc, BigInt, Option<Identifier>),
     HexNumberLiteral(Loc, String, Option<Identifier>),
     HexStringLiteral(HexLiteral, Option<Identifier>),
     StringLiteral(StringLiteral, Option<Identifier>),
     Variable(Identifier),
-    FunctionCall(Box<AssemblyFunctionCall>),
-    Member(Loc, Box<AssemblyExpression>, Identifier),
+    FunctionCall(Box<YulFunctionCall>),
+    Member(Loc, Box<YulExpression>, Identifier),
 }
 
 #[derive(Debug, PartialEq, Clone)]
-pub struct AssemblyTypedIdentifier {
+pub struct YulTypedIdentifier {
     pub loc: Loc,
     pub id: Identifier,
     pub ty: Option<Identifier>,
 }
 
 #[derive(Debug, PartialEq, Clone)]
-pub struct AssemblyFunctionDefinition {
+pub struct YulFunctionDefinition {
     pub loc: Loc,
     pub id: Identifier,
-    pub params: Vec<AssemblyTypedIdentifier>,
-    pub returns: Vec<AssemblyTypedIdentifier>,
-    pub body: AssemblyBlock,
+    pub params: Vec<YulTypedIdentifier>,
+    pub returns: Vec<YulTypedIdentifier>,
+    pub body: YulBlock,
 }
 
 #[derive(Debug, PartialEq, Clone)]
-pub struct AssemblyFunctionCall {
+pub struct YulFunctionCall {
     pub loc: Loc,
     pub id: Identifier,
-    pub arguments: Vec<AssemblyExpression>,
+    pub arguments: Vec<YulExpression>,
 }
 
 #[derive(Debug, PartialEq, Clone)]
-pub enum AssemblySwitchOptions {
-    Case(Loc, AssemblyExpression, AssemblyBlock),
-    Default(Loc, AssemblyBlock),
+pub enum YulSwitchOptions {
+    Case(Loc, YulExpression, YulBlock),
+    Default(Loc, YulBlock),
 }
 
-impl CodeLocation for AssemblySwitchOptions {
+impl CodeLocation for YulSwitchOptions {
     fn loc(&self) -> Loc {
         match self {
-            AssemblySwitchOptions::Case(loc, ..) | AssemblySwitchOptions::Default(loc, ..) => *loc,
+            YulSwitchOptions::Case(loc, ..) | YulSwitchOptions::Default(loc, ..) => *loc,
         }
     }
 }
@@ -756,24 +752,24 @@ impl CodeLocation for Statement {
     }
 }
 
-impl AssemblyStatement {
+impl YulStatement {
     pub fn loc(&self) -> Loc {
         match self {
-            AssemblyStatement::Assign(loc, ..)
-            | AssemblyStatement::VariableDeclaration(loc, ..)
-            | AssemblyStatement::If(loc, ..)
-            | AssemblyStatement::Leave(loc, ..)
-            | AssemblyStatement::Break(loc, ..)
-            | AssemblyStatement::Continue(loc, ..) => *loc,
+            YulStatement::Assign(loc, ..)
+            | YulStatement::VariableDeclaration(loc, ..)
+            | YulStatement::If(loc, ..)
+            | YulStatement::Leave(loc, ..)
+            | YulStatement::Break(loc, ..)
+            | YulStatement::Continue(loc, ..) => *loc,
 
-            AssemblyStatement::Block(block) => block.loc,
+            YulStatement::Block(block) => block.loc,
 
-            AssemblyStatement::FunctionDefinition(func_def) => func_def.loc,
+            YulStatement::FunctionDefinition(func_def) => func_def.loc,
 
-            AssemblyStatement::FunctionCall(func_call) => func_call.loc,
+            YulStatement::FunctionCall(func_call) => func_call.loc,
 
-            AssemblyStatement::For(for_struct) => for_struct.loc,
-            AssemblyStatement::Switch(switch_struct) => switch_struct.loc,
+            YulStatement::For(for_struct) => for_struct.loc,
+            YulStatement::Switch(switch_struct) => switch_struct.loc,
         }
     }
 }

+ 73 - 73
solang-parser/src/solidity.lalrpop

@@ -754,7 +754,7 @@ NonIfStatement: Statement = {
     <l:@L> "unchecked" "{" <statements:Statement*> "}" <r:@R> => {
         Statement::Block { loc: Loc::File(file_no, l, r), unchecked: true, statements }
     },
-    <l:@L> "assembly" <dialect:StringLiteral?> <block:AssemblyBlock> <r:@R> => {
+    <l:@L> "assembly" <dialect:StringLiteral?> <block:YulBlock> <r:@R> => {
         Statement::Assembly {
             loc: Loc::File(file_no, l, r),
             dialect: dialect.map(|dialect| dialect.to_owned()),
@@ -788,7 +788,7 @@ NonIfStatement: Statement = {
     },
 }
 
-AssemblyIdentifier: Identifier = {
+YulIdentifier: Identifier = {
     <l:@L> <n:identifier> <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: n.to_string()},
     <l:@L> "return" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "return".to_string()},
     <l:@L> "revert" <r:@R> => Identifier{loc: Loc::File(file_no, l, r), name: "revert".to_string()},
@@ -796,34 +796,34 @@ AssemblyIdentifier: Identifier = {
     <l:@L> "address" <r:@L> => Identifier{loc: Loc::File(file_no, l, r), name: "address".to_string()},
 }
 
-AssemblyStatement: AssemblyStatement = {
-    <AssemblyBlock> => AssemblyStatement::Block(<>),
-    <AssemblyVariableDeclaration> => <>,
-    <AssemblyAssignment> => <>,
-    <AssemblyFunctionCall> => AssemblyStatement::FunctionCall(Box::new(<>)),
-    <AssemblyIf> => <>,
-    <AssemblyFor> => <>,
-    <AssemblySwitch> => <>,
-    <AssemblyFunctionDefinition> => <>,
+YulStatement: YulStatement = {
+    <YulBlock> => YulStatement::Block(<>),
+    <YulVariableDeclaration> => <>,
+    <YulAssignment> => <>,
+    <YulFunctionCall> => YulStatement::FunctionCall(Box::new(<>)),
+    <YulIf> => <>,
+    <YulFor> => <>,
+    <YulSwitch> => <>,
+    <YulFunctionDefinition> => <>,
     <l:@L> "leave" <r:@R> => {
-        AssemblyStatement::Leave(Loc::File(file_no, l, r))
+        YulStatement::Leave(Loc::File(file_no, l, r))
     },
     <l:@L> "break" <r:@R> => {
-        AssemblyStatement::Break(Loc::File(file_no, l, r))
+        YulStatement::Break(Loc::File(file_no, l, r))
     },
     <l:@L> "continue" <r:@R> => {
-        AssemblyStatement::Continue(Loc::File(file_no, l, r))
+        YulStatement::Continue(Loc::File(file_no, l, r))
     },
 }
 
-AssemblyBlock: AssemblyBlock = {
-    <l:@L> "{" <statements:AssemblyStatement*> "}" <r:@R> => AssemblyBlock{loc: Loc::File(file_no, l, r), statements},
+YulBlock: YulBlock = {
+    <l:@L> "{" <statements:YulStatement*> "}" <r:@R> => YulBlock{loc: Loc::File(file_no, l, r), statements},
 }
 
-AssemblyLiteral: AssemblyExpression = {
-    <a:@L> "true" <t_type:(":" <AssemblyIdentifier>)?> <b:@R> => AssemblyExpression::BoolLiteral(Loc::File(file_no, a, b), true, t_type),
-    <a:@L> "false" <t_type:(":" <AssemblyIdentifier>)?> <b:@R> => AssemblyExpression::BoolLiteral(Loc::File(file_no, a, b), false, t_type),
-    <l:@L> <n:number> <t_type:(":" <AssemblyIdentifier>)?> <r:@R> => {
+YulLiteral: YulExpression = {
+    <a:@L> "true" <t_type:(":" <YulIdentifier>)?> <b:@R> => YulExpression::BoolLiteral(Loc::File(file_no, a, b), true, t_type),
+    <a:@L> "false" <t_type:(":" <YulIdentifier>)?> <b:@R> => YulExpression::BoolLiteral(Loc::File(file_no, a, b), false, t_type),
+    <l:@L> <n:number> <t_type:(":" <YulIdentifier>)?> <r:@R> => {
         let base: String = n.0.chars().filter(|v| *v != '_').collect();
         let exp: String = n.1.chars().filter(|v| *v != '_').collect();
 
@@ -836,48 +836,48 @@ AssemblyLiteral: AssemblyExpression = {
             base.mul(exp)
         };
 
-        AssemblyExpression::NumberLiteral(Loc::File(file_no, l, r), n, t_type)
+        YulExpression::NumberLiteral(Loc::File(file_no, l, r), n, t_type)
     },
-    <l:@L> <n:hexnumber> <t_type:(":" <AssemblyIdentifier>)?> <r:@R> => {
-        AssemblyExpression::HexNumberLiteral(Loc::File(file_no, l, r), n.to_owned(), t_type)
+    <l:@L> <n:hexnumber> <t_type:(":" <YulIdentifier>)?> <r:@R> => {
+        YulExpression::HexNumberLiteral(Loc::File(file_no, l, r), n.to_owned(), t_type)
     },
-    <l:@L> <s:hexstring> <t_type:(":" <AssemblyIdentifier>)?> <r:@R> => {
+    <l:@L> <s:hexstring> <t_type:(":" <YulIdentifier>)?> <r:@R> => {
         let v = s.to_string();
         let hex_len = v.len() - 5;
-        AssemblyExpression::HexStringLiteral(HexLiteral{ loc: Loc::File(file_no, l, r), hex: v.chars().skip(4).filter(|c| *c != '_' && *c != '"' && *c != '\'').collect()},
+        YulExpression::HexStringLiteral(HexLiteral{ loc: Loc::File(file_no, l, r), hex: v.chars().skip(4).filter(|c| *c != '_' && *c != '"' && *c != '\'').collect()},
         t_type)
     },
-    <str:StringLiteral> <t_type:(":" <AssemblyIdentifier>)?> => {
-        AssemblyExpression::StringLiteral(str, t_type)
+    <str:StringLiteral> <t_type:(":" <YulIdentifier>)?> => {
+        YulExpression::StringLiteral(str, t_type)
     },
 }
 
-AssemblyFunctionCall: AssemblyFunctionCall = {
-    <l:@L> <id:AssemblyIdentifier> "(" <arguments:Comma<AssemblyExpression>> ")" <r:@R> =>
-     AssemblyFunctionCall{loc: Loc::File(file_no, l, r), id, arguments}
+YulFunctionCall: YulFunctionCall = {
+    <l:@L> <id:YulIdentifier> "(" <arguments:Comma<YulExpression>> ")" <r:@R> =>
+     YulFunctionCall{loc: Loc::File(file_no, l, r), id, arguments}
 }
 
-AssemblyPath: AssemblyExpression = {
- <AssemblyIdentifier> => AssemblyExpression::Variable(<>),
- <l:@L> <array:AssemblyPath> "." <member:AssemblyIdentifier> <r:@R> => {
-         AssemblyExpression::Member(Loc::File(file_no, l, r), Box::new(array), member)
+YulPath: YulExpression = {
+ <YulIdentifier> => YulExpression::Variable(<>),
+ <l:@L> <array:YulPath> "." <member:YulIdentifier> <r:@R> => {
+         YulExpression::Member(Loc::File(file_no, l, r), Box::new(array), member)
      },
 }
 
-AssemblyExpression: AssemblyExpression = {
-    <AssemblyPath> => <>,
-    <AssemblyFunctionCall> => AssemblyExpression::FunctionCall(Box::new(<>)),
-    <AssemblyLiteral> => <>,
+YulExpression: YulExpression = {
+    <YulPath> => <>,
+    <YulFunctionCall> => YulExpression::FunctionCall(Box::new(<>)),
+    <YulLiteral> => <>,
 }
 
-AssemblyFunctionDefinition: AssemblyStatement = {
-    <l:@L> "function" <name: AssemblyIdentifier> "(" <params: AssemblyTypedIdentifierList> ")" <returns:("->" <AssemblyTypedIdentifierList>)?>
-    <body: AssemblyBlock> <r:@R> => {
+YulFunctionDefinition: YulStatement = {
+    <l:@L> "function" <name: YulIdentifier> "(" <params: YulTypedIdentifierList> ")" <returns:("->" <YulTypedIdentifierList>)?>
+    <body: YulBlock> <r:@R> => {
         let returns = match returns {
             Some(content) => content,
             None => vec![]
         };
-        AssemblyStatement::FunctionDefinition(Box::new(AssemblyFunctionDefinition{
+        YulStatement::FunctionDefinition(Box::new(YulFunctionDefinition{
             loc: Loc::File(file_no, l, r),
             id: name,
             params,
@@ -890,30 +890,30 @@ AssemblyFunctionDefinition: AssemblyStatement = {
 
 }
 
-AssemblyTypedIdentifierList: Vec<AssemblyTypedIdentifier> = {
-    CommaOne<<AssemblyType>> => <>
+YulTypedIdentifierList: Vec<YulTypedIdentifier> = {
+    CommaOne<<YulType>> => <>
 }
 
-AssemblyType: AssemblyTypedIdentifier = {
-    <l:@L> <var_name:AssemblyIdentifier> ":" <var_type:AssemblyIdentifier> <r:@R> =>
-       AssemblyTypedIdentifier{
+YulType: YulTypedIdentifier = {
+    <l:@L> <var_name:YulIdentifier> ":" <var_type:YulIdentifier> <r:@R> =>
+       YulTypedIdentifier{
             loc: Loc::File(file_no, l, r),
             id: var_name, ty: Some(var_type)
        },
-    <l:@L> <id:AssemblyIdentifier> <r:@R> =>
-       AssemblyTypedIdentifier{loc: Loc::File(file_no, l, r), id, ty: None},
+    <l:@L> <id:YulIdentifier> <r:@R> =>
+       YulTypedIdentifier{loc: Loc::File(file_no, l, r), id, ty: None},
 }
 
-AssemblySwitch: AssemblyStatement = {
-    <l:@L> "switch" <condition:AssemblyExpression> <default:AssemblySwitchDefault> <r:@R> =>
-    AssemblyStatement::Switch(AssemblySwitch{
+YulSwitch: YulStatement = {
+    <l:@L> "switch" <condition:YulExpression> <default:YulSwitchDefault> <r:@R> =>
+    YulStatement::Switch(YulSwitch{
         loc: Loc::File(file_no, l, r),
         condition,
         cases: Vec::new(),
         default: Some(default)
     }),
-    <l:@L> "switch" <condition:AssemblyExpression> <cases:AssemblySwitchCase+> <default:AssemblySwitchDefault?> <r:@R> =>
-    AssemblyStatement::Switch(AssemblySwitch{
+    <l:@L> "switch" <condition:YulExpression> <cases:YulSwitchCase+> <default:YulSwitchDefault?> <r:@R> =>
+    YulStatement::Switch(YulSwitch{
         loc: Loc::File(file_no, l, r),
         condition,
         cases,
@@ -921,21 +921,21 @@ AssemblySwitch: AssemblyStatement = {
     }),
 }
 
-AssemblySwitchDefault: AssemblySwitchOptions = {
-    <l:@L> "default" <body:AssemblyBlock> <r:@R> => {
-        AssemblySwitchOptions::Default(Loc::File(file_no, l, r), body)
+YulSwitchDefault: YulSwitchOptions = {
+    <l:@L> "default" <body:YulBlock> <r:@R> => {
+        YulSwitchOptions::Default(Loc::File(file_no, l, r), body)
     }
 }
 
-AssemblySwitchCase: AssemblySwitchOptions = {
-    <l:@L> "case" <case:AssemblyLiteral> <body:AssemblyBlock> <r:@R> => {
-        AssemblySwitchOptions::Case(Loc::File(file_no, l, r), case, body)
+YulSwitchCase: YulSwitchOptions = {
+    <l:@L> "case" <case:YulLiteral> <body:YulBlock> <r:@R> => {
+        YulSwitchOptions::Case(Loc::File(file_no, l, r), case, body)
     }
 }
 
-AssemblyFor: AssemblyStatement = {
-    <l:@L> "for" <init:AssemblyBlock> <cond:AssemblyExpression> <post_iter:AssemblyBlock> <body:AssemblyBlock> <r:@R> => {
-        AssemblyStatement::For(AssemblyFor{
+YulFor: YulStatement = {
+    <l:@L> "for" <init:YulBlock> <cond:YulExpression> <post_iter:YulBlock> <body:YulBlock> <r:@R> => {
+        YulStatement::For(YulFor{
             loc: Loc::File(file_no, l, r),
             init_block: init,
             condition: cond,
@@ -945,20 +945,20 @@ AssemblyFor: AssemblyStatement = {
     },
 }
 
-AssemblyIf: AssemblyStatement = {
-    <l:@L> "if" <cond:AssemblyExpression> <body:AssemblyBlock> <r:@R> => {
-        AssemblyStatement::If(Loc::File(file_no, l, r), cond, body)
+YulIf: YulStatement = {
+    <l:@L> "if" <cond:YulExpression> <body:YulBlock> <r:@R> => {
+        YulStatement::If(Loc::File(file_no, l, r), cond, body)
     },
 }
 
-AssemblyAssignment: AssemblyStatement = {
- <l:@L> <paths:CommaOne<AssemblyPath>> ":=" <expr:AssemblyExpression> <r:@R> =>
- AssemblyStatement::Assign(Loc::File(file_no, l, r), paths, expr)
+YulAssignment: YulStatement = {
+ <l:@L> <paths:CommaOne<YulPath>> ":=" <expr:YulExpression> <r:@R> =>
+ YulStatement::Assign(Loc::File(file_no, l, r), paths, expr)
 }
 
-AssemblyVariableDeclaration: AssemblyStatement = {
-    <l:@L>  "let" <names:AssemblyTypedIdentifierList> <expr:(":=" <AssemblyExpression>)?> <r:@R> =>
-    AssemblyStatement::VariableDeclaration(Loc::File(file_no, l, r), names, expr),
+YulVariableDeclaration: YulStatement = {
+    <l:@L>  "let" <names:YulTypedIdentifierList> <expr:(":=" <YulExpression>)?> <r:@R> =>
+    YulStatement::VariableDeclaration(Loc::File(file_no, l, r), names, expr),
 }
 
 
@@ -1003,7 +1003,7 @@ extern {
         "=" => Token::Assign,
         "==" => Token::Equal,
         "=>" => Token::Arrow,
-        "->" => Token::AssemblyArrow,
+        "->" => Token::YulArrow,
         "|=" => Token::BitwiseOrAssign,
         "^=" => Token::BitwiseXorAssign,
         "&=" => Token::BitwiseAndAssign,

+ 71 - 71
solang-parser/src/test.rs

@@ -633,12 +633,12 @@ fn test_assembly_parser() {
                 statements: vec![
                     Statement::Assembly {
                         loc: Loc::File(0, 54, 736),
-                        block: AssemblyBlock {
+                        block: YulBlock {
                             loc: Loc::File(0, 72, 736),
                             statements: vec![
-                                AssemblyStatement::VariableDeclaration(
+                                YulStatement::VariableDeclaration(
                                     Loc::File(0, 98, 108),
-                                    vec![AssemblyTypedIdentifier {
+                                    vec![YulTypedIdentifier {
                                         loc: Loc::File(0, 102, 103),
                                         id: Identifier {
                                             loc: Loc::File(0, 102, 103),
@@ -646,19 +646,19 @@ fn test_assembly_parser() {
                                         },
                                         ty: None,
                                     }],
-                                    Some(AssemblyExpression::NumberLiteral(
+                                    Some(YulExpression::NumberLiteral(
                                         Loc::File(0, 107, 108),
                                         BigInt::from(0),
                                         None,
                                     )),
                                 ),
-                                AssemblyStatement::For(AssemblyFor{
+                                YulStatement::For(YulFor {
                                     loc: Loc::File(0, 133, 388),
-                                    init_block: AssemblyBlock{
+                                    init_block: YulBlock {
                                         loc: Loc::File(0, 137, 151),
-                                        statements: vec![AssemblyStatement::VariableDeclaration(
+                                        statements: vec![YulStatement::VariableDeclaration(
                                             Loc::File(0, 139, 149),
-                                            vec![AssemblyTypedIdentifier {
+                                            vec![YulTypedIdentifier {
                                                 loc: Loc::File(0, 143, 144),
                                                 id: Identifier {
                                                     loc: Loc::File(0, 143, 144),
@@ -666,52 +666,52 @@ fn test_assembly_parser() {
                                                 },
                                                 ty: None,
                                             }],
-                                            Some(AssemblyExpression::NumberLiteral(
+                                            Some(YulExpression::NumberLiteral(
                                                 Loc::File(0, 148, 149),
                                                 BigInt::from(0),
                                                 None,
                                             )),
                                         )],
                                     },
-                                    condition: AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+                                    condition: YulExpression::FunctionCall(Box::new(YulFunctionCall {
                                         loc: Loc::File(0, 152, 164),
                                         id: Identifier {
                                             loc: Loc::File(0, 152, 154),
                                             name: "lt".to_string(),
                                         },
                                         arguments: vec![
-                                            AssemblyExpression::Variable(Identifier {
+                                            YulExpression::Variable(Identifier {
                                                 loc: Loc::File(0, 155, 156),
                                                 name: "i".to_string(),
                                             }),
-                                            AssemblyExpression::HexNumberLiteral(
+                                            YulExpression::HexNumberLiteral(
                                                 Loc::File(0, 158, 163),
                                                 "0x100".to_string(),
                                                 None,
                                             ),
                                         ],
                                     })),
-                                    post_block: AssemblyBlock {
+                                    post_block: YulBlock {
                                         loc: Loc::File(0, 165, 186),
-                                        statements: vec![AssemblyStatement::Assign(
+                                        statements: vec![YulStatement::Assign(
                                             Loc::File(0, 167, 184),
-                                            vec![AssemblyExpression::Variable(Identifier {
+                                            vec![YulExpression::Variable(Identifier {
                                                 loc: Loc::File(0, 167, 168),
                                                 name: "i".to_string(),
                                             })],
-                                            AssemblyExpression::FunctionCall(Box::new(
-                                                AssemblyFunctionCall {
+                                            YulExpression::FunctionCall(Box::new(
+                                                YulFunctionCall {
                                                     loc: Loc::File(0, 172, 184),
                                                     id: Identifier {
                                                         loc: Loc::File(0, 172, 175),
                                                         name: "add".to_string(),
                                                     },
                                                     arguments: vec![
-                                                        AssemblyExpression::Variable(Identifier {
+                                                        YulExpression::Variable(Identifier {
                                                             loc: Loc::File(0, 176, 177),
                                                             name: "i".to_string(),
                                                         }),
-                                                        AssemblyExpression::HexNumberLiteral(
+                                                        YulExpression::HexNumberLiteral(
                                                             Loc::File(0, 179, 183),
                                                             "0x20".to_string(),
                                                             None,
@@ -721,36 +721,36 @@ fn test_assembly_parser() {
                                             )),
                                         )],
                                     },
-                                    execution_block: AssemblyBlock{
+                                    execution_block: YulBlock {
                                         loc: Loc::File(0, 187, 388),
                                         statements: vec![
-                                            AssemblyStatement::Assign(
+                                            YulStatement::Assign(
                                                 Loc::File(0, 217, 248),
-                                                vec![AssemblyExpression::Variable(Identifier {
+                                                vec![YulExpression::Variable(Identifier {
                                                     loc: Loc::File(0, 217, 218),
                                                     name: "x".to_string(),
                                                 })],
-                                                AssemblyExpression::FunctionCall(Box::new(
-                                                    AssemblyFunctionCall {
+                                                YulExpression::FunctionCall(Box::new(
+                                                    YulFunctionCall {
                                                         loc: Loc::File(0, 232, 248),
                                                         id: Identifier {
                                                             loc: Loc::File(0, 232, 235),
                                                             name: "add".to_string(),
                                                         },
                                                         arguments: vec![
-                                                            AssemblyExpression::Variable(Identifier {
+                                                            YulExpression::Variable(Identifier {
                                                                 loc: Loc::File(0, 236, 237),
                                                                 name: "x".to_string(),
                                                             }),
-                                                            AssemblyExpression::FunctionCall(Box::new(
-                                                                AssemblyFunctionCall {
+                                                            YulExpression::FunctionCall(Box::new(
+                                                                YulFunctionCall {
                                                                     loc: Loc::File(0, 239, 247),
                                                                     id: Identifier {
                                                                         loc: Loc::File(0, 239, 244),
                                                                         name: "mload".to_string(),
                                                                     },
                                                                     arguments: vec![
-                                                                        AssemblyExpression::Variable(
+                                                                        YulExpression::Variable(
                                                                             Identifier {
                                                                                 loc: Loc::File(0, 245, 246),
                                                                                 name: "i".to_string(),
@@ -763,21 +763,21 @@ fn test_assembly_parser() {
                                                     },
                                                 )),
                                             ),
-                                            AssemblyStatement::If(
+                                            YulStatement::If(
                                                 Loc::File(0, 278, 362),
-                                                AssemblyExpression::FunctionCall(Box::new(
-                                                    AssemblyFunctionCall {
+                                                YulExpression::FunctionCall(Box::new(
+                                                    YulFunctionCall {
                                                         loc: Loc::File(0, 281, 292),
                                                         id: Identifier {
                                                             loc: Loc::File(0, 281, 283),
                                                             name: "gt".to_string(),
                                                         },
                                                         arguments: vec![
-                                                            AssemblyExpression::Variable(Identifier {
+                                                            YulExpression::Variable(Identifier {
                                                                 loc: Loc::File(0, 284, 285),
                                                                 name: "i".to_string(),
                                                             }),
-                                                            AssemblyExpression::HexNumberLiteral(
+                                                            YulExpression::HexNumberLiteral(
                                                                 Loc::File(0, 287, 291),
                                                                 "0x10".to_string(),
                                                                 None,
@@ -785,18 +785,18 @@ fn test_assembly_parser() {
                                                         ],
                                                     },
                                                 )),
-                                                AssemblyBlock{
+                                                YulBlock {
                                                     loc: Loc::File(0, 293, 362),
-                                                    statements: vec![AssemblyStatement::Break(Loc::File(0, 327, 332))],
+                                                    statements: vec![YulStatement::Break(Loc::File(0, 327, 332))],
                                                 },
                                             ),
                                         ],
                                     },
                             }),
-                                AssemblyStatement::VariableDeclaration(
+                                YulStatement::VariableDeclaration(
                                     Loc::File(0, 414, 451),
                                     vec![
-                                        AssemblyTypedIdentifier {
+                                        YulTypedIdentifier {
                                             loc: Loc::File(0, 418, 425),
                                             id: Identifier {
                                                 loc: Loc::File(0, 418, 419),
@@ -807,7 +807,7 @@ fn test_assembly_parser() {
                                                 name: "u32".to_string(),
                                             }),
                                         },
-                                        AssemblyTypedIdentifier {
+                                        YulTypedIdentifier {
                                             loc: Loc::File(0, 427, 428),
                                             id: Identifier {
                                                 loc: Loc::File(0, 427, 428),
@@ -815,7 +815,7 @@ fn test_assembly_parser() {
                                             },
                                             ty: None,
                                         },
-                                        AssemblyTypedIdentifier {
+                                        YulTypedIdentifier {
                                             loc: Loc::File(0, 430, 437),
                                             id: Identifier {
                                                 loc: Loc::File(0, 430, 431),
@@ -827,8 +827,8 @@ fn test_assembly_parser() {
                                             }),
                                         },
                                     ],
-                                    Some(AssemblyExpression::FunctionCall(Box::new(
-                                        AssemblyFunctionCall {
+                                    Some(YulExpression::FunctionCall(Box::new(
+                                        YulFunctionCall {
                                             loc: Loc::File(0, 441, 451),
                                             id: Identifier {
                                                 loc: Loc::File(0, 441, 449),
@@ -838,35 +838,35 @@ fn test_assembly_parser() {
                                         },
                                     ))),
                                 ),
-                                AssemblyStatement::Switch(AssemblySwitch{
+                                YulStatement::Switch(YulSwitch {
                                     loc: Loc::File(0, 477, 714),
-                                    condition: AssemblyExpression::Variable(Identifier {
+                                    condition: YulExpression::Variable(Identifier {
                                         loc: Loc::File(0, 484, 485),
                                         name: "x".to_string(),
                                     }),
-                                    cases: vec![AssemblySwitchOptions::Case(
+                                    cases: vec![YulSwitchOptions::Case(
                                         Loc::File(0, 510, 620),
-                                        AssemblyExpression::NumberLiteral(
+                                        YulExpression::NumberLiteral(
                                             Loc::File(0, 515, 516),
                                             BigInt::from(0),
                                             None,
                                         ),
-                                        AssemblyBlock{
+                                        YulBlock {
                                             loc: Loc::File(0, 517, 620),
-                                            statements: vec![AssemblyStatement::FunctionCall(Box::new(
-                                                AssemblyFunctionCall {
+                                            statements: vec![YulStatement::FunctionCall(Box::new(
+                                                YulFunctionCall {
                                                     loc: Loc::File(0, 547, 559),
                                                     id: Identifier {
                                                         loc: Loc::File(0, 547, 553),
                                                         name: "revert".to_string(),
                                                     },
                                                     arguments: vec![
-                                                        AssemblyExpression::NumberLiteral(
+                                                        YulExpression::NumberLiteral(
                                                             Loc::File(0, 554, 555),
                                                             BigInt::from(0),
                                                             None,
                                                         ),
-                                                        AssemblyExpression::NumberLiteral(
+                                                        YulExpression::NumberLiteral(
                                                             Loc::File(0, 557, 558),
                                                             BigInt::from(0),
                                                             None,
@@ -876,11 +876,11 @@ fn test_assembly_parser() {
                                             ))],
                                         }
                                     )],
-                                    default: Some(AssemblySwitchOptions::Default(
+                                    default: Some(YulSwitchOptions::Default(
                                         Loc::File(0, 645, 714),
-                                        AssemblyBlock {
+                                        YulBlock {
                                             loc: Loc::File(0, 653, 714),
-                                            statements: vec![AssemblyStatement::Leave(Loc::File(0, 683, 688))],
+                                            statements: vec![YulStatement::Leave(Loc::File(0, 683, 688))],
                                         }
                                     )),
                             }),
@@ -893,17 +893,17 @@ fn test_assembly_parser() {
                     },
                     Statement::Assembly {
                         loc: Loc::File(0, 758, 1027),
-                        block: AssemblyBlock{
+                        block: YulBlock {
                           loc: Loc::File(0, 767, 1027),
-                            statements: vec![AssemblyStatement::FunctionDefinition(Box::new(
-                                AssemblyFunctionDefinition {
+                            statements: vec![YulStatement::FunctionDefinition(Box::new(
+                                YulFunctionDefinition {
                                     loc: Loc::File(0, 794, 1005),
                                     id: Identifier {
                                         loc: Loc::File(0, 803, 808),
                                         name: "power".to_string(),
                                     },
                                     params: vec![
-                                        AssemblyTypedIdentifier {
+                                        YulTypedIdentifier {
                                             loc: Loc::File(0, 809, 820),
                                             id: Identifier {
                                                 loc: Loc::File(0, 809, 813),
@@ -914,7 +914,7 @@ fn test_assembly_parser() {
                                                 name: "u256".to_string(),
                                             }),
                                         },
-                                        AssemblyTypedIdentifier {
+                                        YulTypedIdentifier {
                                             loc: Loc::File(0, 822, 830),
                                             id: Identifier {
                                                 loc: Loc::File(0, 822, 830),
@@ -923,7 +923,7 @@ fn test_assembly_parser() {
                                             ty: None,
                                         },
                                     ],
-                                    returns: vec![AssemblyTypedIdentifier {
+                                    returns: vec![YulTypedIdentifier {
                                         loc: Loc::File(0, 835, 841),
                                         id: Identifier {
                                             loc: Loc::File(0, 835, 841),
@@ -931,12 +931,12 @@ fn test_assembly_parser() {
                                         },
                                         ty: None,
                                     }],
-                                    body: AssemblyBlock {
+                                    body: YulBlock {
                                         loc: Loc::File(0, 866, 1005),
                                         statements:  vec![
-                                            AssemblyStatement::VariableDeclaration(
+                                            YulStatement::VariableDeclaration(
                                                 Loc::File(0, 896, 940),
-                                                vec![AssemblyTypedIdentifier {
+                                                vec![YulTypedIdentifier {
                                                     loc: Loc::File(0, 900, 901),
                                                     id: Identifier {
                                                         loc: Loc::File(0, 900, 901),
@@ -944,15 +944,15 @@ fn test_assembly_parser() {
                                                     },
                                                     ty: None,
                                                 }],
-                                                Some(AssemblyExpression::FunctionCall(Box::new(
-                                                    AssemblyFunctionCall {
+                                                Some(YulExpression::FunctionCall(Box::new(
+                                                    YulFunctionCall {
                                                         loc: Loc::File(0, 905, 940),
                                                         id: Identifier {
                                                             loc: Loc::File(0, 905, 908),
                                                             name: "and".to_string(),
                                                         },
                                                         arguments: vec![
-                                                            AssemblyExpression::StringLiteral(
+                                                            YulExpression::StringLiteral(
                                                                 StringLiteral {
                                                                     loc: Loc::File(0, 909, 914),
                                                                     string: "abc".to_string(),
@@ -962,15 +962,15 @@ fn test_assembly_parser() {
                                                                     name: "u32".to_string(),
                                                                 }),
                                                             ),
-                                                            AssemblyExpression::FunctionCall(Box::new(
-                                                                AssemblyFunctionCall {
+                                                            YulExpression::FunctionCall(Box::new(
+                                                                YulFunctionCall {
                                                                     loc: Loc::File(0, 920, 939),
                                                                     id: Identifier {
                                                                         loc: Loc::File(0, 920, 923),
                                                                         name: "add".to_string(),
                                                                     },
                                                                     arguments: vec![
-                                                                        AssemblyExpression::NumberLiteral(
+                                                                        YulExpression::NumberLiteral(
                                                                             Loc::File(0, 924, 930),
                                                                             BigInt::from(3),
                                                                             Some(Identifier {
@@ -978,7 +978,7 @@ fn test_assembly_parser() {
                                                                                 name: "u256".to_string(),
                                                                             }),
                                                                         ),
-                                                                        AssemblyExpression::NumberLiteral(
+                                                                        YulExpression::NumberLiteral(
                                                                             Loc::File(0, 932, 938),
                                                                             BigInt::from(2),
                                                                             Some(Identifier {
@@ -993,9 +993,9 @@ fn test_assembly_parser() {
                                                     },
                                                 ))),
                                             ),
-                                            AssemblyStatement::VariableDeclaration(
+                                            YulStatement::VariableDeclaration(
                                                 Loc::File(0, 969, 979),
-                                                vec![AssemblyTypedIdentifier {
+                                                vec![YulTypedIdentifier {
                                                     loc: Loc::File(0, 973, 979),
                                                     id: Identifier {
                                                         loc: Loc::File(0, 973, 979),

+ 0 - 125
src/sema/assembly/ast.rs

@@ -1,125 +0,0 @@
-use crate::ast::Type;
-use crate::sema::assembly::builtin::AssemblyBuiltInFunction;
-use crate::sema::symtable::Symtable;
-use num_bigint::BigInt;
-use solang_parser::pt;
-use solang_parser::pt::{CodeLocation, StorageLocation};
-use std::sync::Arc;
-
-#[derive(Debug, Clone)]
-pub struct InlineAssembly {
-    pub loc: pt::Loc,
-    pub body: Vec<(AssemblyStatement, bool)>,
-    pub functions: Vec<AssemblyFunction>,
-}
-
-#[derive(Debug, Clone)]
-pub struct AssemblyBlock {
-    pub loc: pt::Loc,
-    pub body: Vec<(AssemblyStatement, bool)>,
-}
-
-#[derive(PartialEq, Debug, Clone)]
-pub enum AssemblyExpression {
-    BoolLiteral(pt::Loc, bool, Type),
-    NumberLiteral(pt::Loc, BigInt, Type),
-    StringLiteral(pt::Loc, Vec<u8>, Type),
-    AssemblyLocalVariable(pt::Loc, Type, usize),
-    SolidityLocalVariable(pt::Loc, Type, Option<StorageLocation>, usize),
-    ConstantVariable(pt::Loc, Type, Option<usize>, usize),
-    StorageVariable(pt::Loc, Type, usize, usize),
-    BuiltInCall(pt::Loc, AssemblyBuiltInFunction, Vec<AssemblyExpression>),
-    FunctionCall(pt::Loc, usize, Vec<AssemblyExpression>),
-    MemberAccess(pt::Loc, Box<AssemblyExpression>, AssemblySuffix),
-}
-
-#[derive(PartialEq, Debug, Clone)]
-pub enum AssemblySuffix {
-    Offset,
-    Slot,
-    Length,
-    Selector,
-    Address,
-}
-
-impl ToString for AssemblySuffix {
-    fn to_string(&self) -> String {
-        let name = match self {
-            AssemblySuffix::Offset => "offset",
-            AssemblySuffix::Slot => "slot",
-            AssemblySuffix::Length => "length",
-            AssemblySuffix::Selector => "selector",
-            AssemblySuffix::Address => "address",
-        };
-
-        name.to_string()
-    }
-}
-
-impl CodeLocation for AssemblyExpression {
-    fn loc(&self) -> pt::Loc {
-        match self {
-            AssemblyExpression::BoolLiteral(loc, ..)
-            | AssemblyExpression::NumberLiteral(loc, ..)
-            | AssemblyExpression::StringLiteral(loc, ..)
-            | AssemblyExpression::AssemblyLocalVariable(loc, ..)
-            | AssemblyExpression::SolidityLocalVariable(loc, ..)
-            | AssemblyExpression::ConstantVariable(loc, ..)
-            | AssemblyExpression::StorageVariable(loc, ..)
-            | AssemblyExpression::BuiltInCall(loc, ..)
-            | AssemblyExpression::MemberAccess(loc, ..)
-            | AssemblyExpression::FunctionCall(loc, ..) => *loc,
-        }
-    }
-}
-
-#[derive(Debug, Clone)]
-pub struct AssemblyFunction {
-    pub loc: pt::Loc,
-    pub name: String,
-    pub params: Arc<Vec<AssemblyFunctionParameter>>,
-    pub returns: Arc<Vec<AssemblyFunctionParameter>>,
-    pub body: Vec<(AssemblyStatement, bool)>,
-    pub symtable: Symtable,
-    pub called: bool,
-}
-
-#[derive(Debug, Clone)]
-pub struct AssemblyFunctionParameter {
-    pub loc: pt::Loc,
-    pub id: pt::Identifier,
-    pub ty: Type,
-}
-
-#[derive(Clone, Debug)]
-pub enum AssemblyStatement {
-    FunctionCall(pt::Loc, usize, Vec<AssemblyExpression>),
-    BuiltInCall(pt::Loc, AssemblyBuiltInFunction, Vec<AssemblyExpression>),
-    Block(Box<AssemblyBlock>),
-    VariableDeclaration(pt::Loc, Vec<usize>, Option<AssemblyExpression>),
-    Assignment(pt::Loc, Vec<AssemblyExpression>, AssemblyExpression),
-    IfBlock(pt::Loc, AssemblyExpression, Box<AssemblyBlock>),
-    Switch {
-        loc: pt::Loc,
-        condition: AssemblyExpression,
-        cases: Vec<CaseBlock>,
-        default: Option<AssemblyBlock>,
-    },
-    For {
-        loc: pt::Loc,
-        init_block: AssemblyBlock,
-        condition: AssemblyExpression,
-        post_block: AssemblyBlock,
-        execution_block: AssemblyBlock,
-    },
-    Leave(pt::Loc),
-    Break(pt::Loc),
-    Continue(pt::Loc),
-}
-
-#[derive(Debug, Clone)]
-pub struct CaseBlock {
-    pub loc: pt::Loc,
-    pub condition: AssemblyExpression,
-    pub block: AssemblyBlock,
-}

+ 0 - 48
src/sema/assembly/unused_variable.rs

@@ -1,48 +0,0 @@
-use crate::ast::Namespace;
-use crate::sema::assembly::ast::AssemblyExpression;
-use crate::sema::symtable::Symtable;
-
-pub(crate) fn assigned_variable(
-    ns: &mut Namespace,
-    exp: &AssemblyExpression,
-    symtable: &mut Symtable,
-) {
-    match exp {
-        // Considering that semantic analysis already considered the assignment valid
-        AssemblyExpression::SolidityLocalVariable(_, _, _, var_no)
-        | AssemblyExpression::AssemblyLocalVariable(_, _, var_no) => {
-            let var = symtable.vars.get_mut(var_no).unwrap();
-            (*var).assigned = true;
-        }
-
-        AssemblyExpression::StorageVariable(_, _, contract_no, var_no) => {
-            ns.contracts[*contract_no].variables[*var_no].assigned = true;
-        }
-
-        AssemblyExpression::MemberAccess(_, member, _) => {
-            assigned_variable(ns, member, symtable);
-        }
-
-        _ => (),
-    }
-}
-
-pub(crate) fn used_variable(ns: &mut Namespace, exp: &AssemblyExpression, symtable: &mut Symtable) {
-    match exp {
-        AssemblyExpression::SolidityLocalVariable(_, _, _, var_no)
-        | AssemblyExpression::AssemblyLocalVariable(_, _, var_no) => {
-            let var = symtable.vars.get_mut(var_no).unwrap();
-            (*var).read = true;
-        }
-
-        AssemblyExpression::StorageVariable(_, _, contract_no, var_no) => {
-            ns.contracts[*contract_no].variables[*var_no].read = true;
-        }
-
-        AssemblyExpression::MemberAccess(_, member, _) => {
-            used_variable(ns, member, symtable);
-        }
-
-        _ => (),
-    }
-}

+ 1 - 1
src/sema/ast.rs

@@ -3,7 +3,7 @@ use crate::codegen::cfg::ControlFlowGraph;
 pub use crate::parser::diagnostics::*;
 use crate::parser::pt;
 use crate::parser::pt::{CodeLocation, OptionalCodeLocation};
-use crate::sema::assembly::ast::InlineAssembly;
+use crate::sema::yul::ast::InlineAssembly;
 use crate::Target;
 use num_bigint::BigInt;
 use num_rational::BigRational;

+ 35 - 37
src/sema/dotgraphviz.rs

@@ -1,10 +1,8 @@
 use super::ast::*;
 use crate::parser::pt;
-use crate::sema::assembly::ast::{
-    AssemblyBlock, AssemblyExpression, AssemblyFunction, AssemblyStatement,
-};
-use crate::sema::assembly::builtin::AssemblyBuiltInFunction;
 use crate::sema::symtable::Symtable;
+use crate::sema::yul::ast::{YulBlock, YulExpression, YulFunction, YulStatement};
+use crate::sema::yul::builtin::YulBuiltInFunction;
 use solang_parser::pt::Loc;
 
 struct Node {
@@ -1572,7 +1570,7 @@ impl Dot {
     fn add_yul_function(
         &mut self,
         func_no: usize,
-        avail_functions: &[AssemblyFunction],
+        avail_functions: &[YulFunction],
         ns: &Namespace,
         parent: usize,
         parent_rel: String,
@@ -1637,15 +1635,15 @@ impl Dot {
 
     fn add_yul_expression(
         &mut self,
-        expr: &AssemblyExpression,
+        expr: &YulExpression,
         symtable: &Symtable,
-        avail_functions: &[AssemblyFunction],
+        avail_functions: &[YulFunction],
         ns: &Namespace,
         parent: usize,
         parent_rel: String,
     ) {
         match expr {
-            AssemblyExpression::BoolLiteral(loc, value, ty) => {
+            YulExpression::BoolLiteral(loc, value, ty) => {
                 let labels = vec![
                     format!(
                         "bool literal: {} of type {}",
@@ -1661,7 +1659,7 @@ impl Dot {
                     Some(parent_rel),
                 );
             }
-            AssemblyExpression::NumberLiteral(loc, value, ty) => {
+            YulExpression::NumberLiteral(loc, value, ty) => {
                 let labels = vec![
                     format!("{} literal: {}", ty.to_string(ns), value),
                     ns.loc_to_string(loc),
@@ -1673,7 +1671,7 @@ impl Dot {
                     Some(parent_rel),
                 );
             }
-            AssemblyExpression::StringLiteral(loc, value, ty) => {
+            YulExpression::StringLiteral(loc, value, ty) => {
                 let labels = vec![
                     format!("{} literal: {}", ty.to_string(ns), hex::encode(value)),
                     ns.loc_to_string(loc),
@@ -1685,7 +1683,7 @@ impl Dot {
                     Some(parent_rel),
                 );
             }
-            AssemblyExpression::AssemblyLocalVariable(loc, ty, var_no) => {
+            YulExpression::YulLocalVariable(loc, ty, var_no) => {
                 let labels = vec![
                     format!("yul variable: {}", symtable.vars[var_no].id.name),
                     ty.to_string(ns),
@@ -1697,7 +1695,7 @@ impl Dot {
                     Some(parent_rel),
                 );
             }
-            AssemblyExpression::SolidityLocalVariable(loc, ty, _, var_no) => {
+            YulExpression::SolidityLocalVariable(loc, ty, _, var_no) => {
                 let labels = vec![
                     format!("solidity variable: {}", symtable.vars[var_no].id.name),
                     ty.to_string(ns),
@@ -1710,13 +1708,13 @@ impl Dot {
                     Some(parent_rel),
                 );
             }
-            AssemblyExpression::ConstantVariable(loc, ty, contract, var_no) => {
+            YulExpression::ConstantVariable(loc, ty, contract, var_no) => {
                 self.add_constant_variable(loc, ty, contract, var_no, parent, parent_rel, ns);
             }
-            AssemblyExpression::StorageVariable(loc, ty, contract, var_no) => {
+            YulExpression::StorageVariable(loc, ty, contract, var_no) => {
                 self.add_storage_variable(loc, ty, contract, var_no, parent, parent_rel, ns);
             }
-            AssemblyExpression::BuiltInCall(loc, builtin_ty, args) => {
+            YulExpression::BuiltInCall(loc, builtin_ty, args) => {
                 self.add_yul_builtin_call(
                     loc,
                     builtin_ty,
@@ -1728,7 +1726,7 @@ impl Dot {
                     ns,
                 );
             }
-            AssemblyExpression::FunctionCall(loc, func_no, args) => {
+            YulExpression::FunctionCall(loc, func_no, args) => {
                 self.add_yul_function_call(
                     loc,
                     func_no,
@@ -1740,7 +1738,7 @@ impl Dot {
                     ns,
                 );
             }
-            AssemblyExpression::MemberAccess(loc, member, suffix) => {
+            YulExpression::MemberAccess(loc, member, suffix) => {
                 let labels = vec![
                     format!("yul member ‘{}‘ access", suffix.to_string()),
                     ns.loc_to_string(loc),
@@ -1828,15 +1826,15 @@ impl Dot {
 
     fn add_yul_statement(
         &mut self,
-        statement: &AssemblyStatement,
+        statement: &YulStatement,
         parent: usize,
         parent_rel: String,
-        avail_functions: &[AssemblyFunction],
+        avail_functions: &[YulFunction],
         symtable: &Symtable,
         ns: &Namespace,
     ) -> usize {
         match statement {
-            AssemblyStatement::FunctionCall(loc, func_no, args) => self.add_yul_function_call(
+            YulStatement::FunctionCall(loc, func_no, args) => self.add_yul_function_call(
                 loc,
                 func_no,
                 args,
@@ -1846,7 +1844,7 @@ impl Dot {
                 symtable,
                 ns,
             ),
-            AssemblyStatement::BuiltInCall(loc, builtin_ty, args) => self.add_yul_builtin_call(
+            YulStatement::BuiltInCall(loc, builtin_ty, args) => self.add_yul_builtin_call(
                 loc,
                 builtin_ty,
                 args,
@@ -1856,10 +1854,10 @@ impl Dot {
                 symtable,
                 ns,
             ),
-            AssemblyStatement::Block(block) => {
+            YulStatement::Block(block) => {
                 self.add_yul_block(block, parent, parent_rel, avail_functions, symtable, ns)
             }
-            AssemblyStatement::VariableDeclaration(loc, declared_vars, initializer) => {
+            YulStatement::VariableDeclaration(loc, declared_vars, initializer) => {
                 let labels = vec![
                     "yul variable declaration".to_string(),
                     ns.loc_to_string(loc),
@@ -1903,7 +1901,7 @@ impl Dot {
 
                 node
             }
-            AssemblyStatement::Assignment(loc, lhs, rhs) => {
+            YulStatement::Assignment(loc, lhs, rhs) => {
                 let labels = vec!["yul assignment".to_string(), ns.loc_to_string(loc)];
 
                 let node = self.add_node(
@@ -1933,7 +1931,7 @@ impl Dot {
                 );
                 node
             }
-            AssemblyStatement::IfBlock(loc, condition, block) => {
+            YulStatement::IfBlock(loc, condition, block) => {
                 let labels = vec!["yul if".to_string(), ns.loc_to_string(loc)];
 
                 let node = self.add_node(Node::new("if", labels), Some(parent), Some(parent_rel));
@@ -1956,7 +1954,7 @@ impl Dot {
                 );
                 node
             }
-            AssemblyStatement::Switch {
+            YulStatement::Switch {
                 loc,
                 condition,
                 cases,
@@ -2026,7 +2024,7 @@ impl Dot {
                 }
                 node
             }
-            AssemblyStatement::For {
+            YulStatement::For {
                 loc,
                 init_block,
                 condition,
@@ -2071,15 +2069,15 @@ impl Dot {
                 );
                 node
             }
-            AssemblyStatement::Leave(loc) => {
+            YulStatement::Leave(loc) => {
                 let labels = vec!["leave".to_string(), ns.loc_to_string(loc)];
                 self.add_node(Node::new("leave", labels), Some(parent), Some(parent_rel))
             }
-            AssemblyStatement::Break(loc) => {
+            YulStatement::Break(loc) => {
                 let labels = vec!["break".to_string(), ns.loc_to_string(loc)];
                 self.add_node(Node::new("break", labels), Some(parent), Some(parent_rel))
             }
-            AssemblyStatement::Continue(loc) => {
+            YulStatement::Continue(loc) => {
                 let labels = vec!["continue".to_string(), ns.loc_to_string(loc)];
                 self.add_node(
                     Node::new("continue", labels),
@@ -2092,10 +2090,10 @@ impl Dot {
 
     fn add_yul_block(
         &mut self,
-        block: &AssemblyBlock,
+        block: &YulBlock,
         mut parent: usize,
         parent_rel: String,
-        avail_functions: &[AssemblyFunction],
+        avail_functions: &[YulFunction],
         symtable: &Symtable,
         ns: &Namespace,
     ) -> usize {
@@ -2126,10 +2124,10 @@ impl Dot {
         &mut self,
         loc: &Loc,
         func_no: &usize,
-        args: &[AssemblyExpression],
+        args: &[YulExpression],
         parent: usize,
         parent_rel: String,
-        avail_functions: &[AssemblyFunction],
+        avail_functions: &[YulFunction],
         symtable: &Symtable,
         ns: &Namespace,
     ) -> usize {
@@ -2161,11 +2159,11 @@ impl Dot {
     fn add_yul_builtin_call(
         &mut self,
         loc: &Loc,
-        builtin_ty: &AssemblyBuiltInFunction,
-        args: &[AssemblyExpression],
+        builtin_ty: &YulBuiltInFunction,
+        args: &[YulExpression],
         parent: usize,
         parent_rel: String,
-        avail_functions: &[AssemblyFunction],
+        avail_functions: &[YulFunction],
         symtable: &Symtable,
         ns: &Namespace,
     ) -> usize {

+ 1 - 1
src/sema/mod.rs

@@ -7,7 +7,6 @@ use num_traits::Zero;
 use std::{collections::HashMap, ffi::OsStr};
 
 mod address;
-mod assembly;
 pub mod ast;
 pub mod builtin;
 pub mod contracts;
@@ -26,6 +25,7 @@ mod tests;
 mod types;
 mod unused_variable;
 mod variables;
+mod yul;
 
 use self::contracts::visit_bases;
 use self::eval::eval_const_number;

+ 1 - 1
src/sema/statements.rs

@@ -10,10 +10,10 @@ use crate::parser::pt;
 use crate::parser::pt::CatchClause;
 use crate::parser::pt::CodeLocation;
 use crate::parser::pt::OptionalCodeLocation;
-use crate::sema::assembly::resolve_inline_assembly;
 use crate::sema::builtin;
 use crate::sema::symtable::{VariableInitializer, VariableUsage};
 use crate::sema::unused_variable::{assigned_variable, check_function_call, used_variable};
+use crate::sema::yul::resolve_inline_assembly;
 use std::collections::{BTreeMap, HashMap, HashSet};
 use std::sync::Arc;
 

+ 3 - 3
src/sema/symtable.rs

@@ -24,14 +24,14 @@ pub struct Variable {
 #[derive(Clone, Debug)]
 pub enum VariableInitializer {
     Solidity(Option<Arc<Expression>>),
-    Assembly(bool),
+    Yul(bool),
 }
 
 impl VariableInitializer {
     pub fn has_initializer(&self) -> bool {
         match self {
             VariableInitializer::Solidity(expr) => expr.is_some(),
-            VariableInitializer::Assembly(initialized) => *initialized,
+            VariableInitializer::Yul(initialized) => *initialized,
         }
     }
 }
@@ -71,7 +71,7 @@ pub enum VariableUsage {
     TryCatchReturns,
     TryCatchErrorString,
     TryCatchErrorBytes,
-    AssemblyLocalVariable,
+    YulLocalVariable,
 }
 
 #[derive(Debug, Clone)]

+ 1 - 1
src/sema/tests/mod.rs

@@ -1,7 +1,7 @@
 #![cfg(test)]
 use crate::ast::{Expression, Parameter, Statement, TryCatch, Type};
-use crate::sema::assembly::ast::InlineAssembly;
 use crate::sema::expression::unescape;
+use crate::sema::yul::ast::InlineAssembly;
 use solang_parser::pt::Loc;
 use solang_parser::Diagnostic;
 

+ 3 - 6
src/sema/unused_variable.rs

@@ -341,23 +341,20 @@ pub fn emit_warning_local_variable(variable: &symtable::Variable) -> Option<Diag
 
             None
         }
-        VariableUsage::AssemblyLocalVariable => {
+        VariableUsage::YulLocalVariable => {
             let has_value = variable.assigned || variable.initializer.has_initializer();
             if !variable.read && !has_value {
                 return Some(Diagnostic::warning(
                     variable.id.loc,
                     format!(
-                        "assembly variable ‘{}‘ has never been read or assigned",
+                        "yul variable ‘{}‘ has never been read or assigned",
                         variable.id.name
                     ),
                 ));
             } else if !variable.read {
                 return Some(Diagnostic::warning(
                     variable.id.loc,
-                    format!(
-                        "assembly variable ‘{}‘ has never been read",
-                        variable.id.name
-                    ),
+                    format!("yul variable ‘{}‘ has never been read", variable.id.name),
                 ));
             }
             None

+ 125 - 0
src/sema/yul/ast.rs

@@ -0,0 +1,125 @@
+use crate::ast::Type;
+use crate::sema::symtable::Symtable;
+use crate::sema::yul::builtin::YulBuiltInFunction;
+use num_bigint::BigInt;
+use solang_parser::pt;
+use solang_parser::pt::{CodeLocation, StorageLocation};
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub struct InlineAssembly {
+    pub loc: pt::Loc,
+    pub body: Vec<(YulStatement, bool)>,
+    pub functions: Vec<YulFunction>,
+}
+
+#[derive(Debug, Clone)]
+pub struct YulBlock {
+    pub loc: pt::Loc,
+    pub body: Vec<(YulStatement, bool)>,
+}
+
+#[derive(PartialEq, Debug, Clone)]
+pub enum YulExpression {
+    BoolLiteral(pt::Loc, bool, Type),
+    NumberLiteral(pt::Loc, BigInt, Type),
+    StringLiteral(pt::Loc, Vec<u8>, Type),
+    YulLocalVariable(pt::Loc, Type, usize),
+    SolidityLocalVariable(pt::Loc, Type, Option<StorageLocation>, usize),
+    ConstantVariable(pt::Loc, Type, Option<usize>, usize),
+    StorageVariable(pt::Loc, Type, usize, usize),
+    BuiltInCall(pt::Loc, YulBuiltInFunction, Vec<YulExpression>),
+    FunctionCall(pt::Loc, usize, Vec<YulExpression>),
+    MemberAccess(pt::Loc, Box<YulExpression>, YulSuffix),
+}
+
+#[derive(PartialEq, Debug, Clone)]
+pub enum YulSuffix {
+    Offset,
+    Slot,
+    Length,
+    Selector,
+    Address,
+}
+
+impl ToString for YulSuffix {
+    fn to_string(&self) -> String {
+        let name = match self {
+            YulSuffix::Offset => "offset",
+            YulSuffix::Slot => "slot",
+            YulSuffix::Length => "length",
+            YulSuffix::Selector => "selector",
+            YulSuffix::Address => "address",
+        };
+
+        name.to_string()
+    }
+}
+
+impl CodeLocation for YulExpression {
+    fn loc(&self) -> pt::Loc {
+        match self {
+            YulExpression::BoolLiteral(loc, ..)
+            | YulExpression::NumberLiteral(loc, ..)
+            | YulExpression::StringLiteral(loc, ..)
+            | YulExpression::YulLocalVariable(loc, ..)
+            | YulExpression::SolidityLocalVariable(loc, ..)
+            | YulExpression::ConstantVariable(loc, ..)
+            | YulExpression::StorageVariable(loc, ..)
+            | YulExpression::BuiltInCall(loc, ..)
+            | YulExpression::MemberAccess(loc, ..)
+            | YulExpression::FunctionCall(loc, ..) => *loc,
+        }
+    }
+}
+
+#[derive(Debug, Clone)]
+pub struct YulFunction {
+    pub loc: pt::Loc,
+    pub name: String,
+    pub params: Arc<Vec<YulFunctionParameter>>,
+    pub returns: Arc<Vec<YulFunctionParameter>>,
+    pub body: Vec<(YulStatement, bool)>,
+    pub symtable: Symtable,
+    pub called: bool,
+}
+
+#[derive(Debug, Clone)]
+pub struct YulFunctionParameter {
+    pub loc: pt::Loc,
+    pub id: pt::Identifier,
+    pub ty: Type,
+}
+
+#[derive(Clone, Debug)]
+pub enum YulStatement {
+    FunctionCall(pt::Loc, usize, Vec<YulExpression>),
+    BuiltInCall(pt::Loc, YulBuiltInFunction, Vec<YulExpression>),
+    Block(Box<YulBlock>),
+    VariableDeclaration(pt::Loc, Vec<usize>, Option<YulExpression>),
+    Assignment(pt::Loc, Vec<YulExpression>, YulExpression),
+    IfBlock(pt::Loc, YulExpression, Box<YulBlock>),
+    Switch {
+        loc: pt::Loc,
+        condition: YulExpression,
+        cases: Vec<CaseBlock>,
+        default: Option<YulBlock>,
+    },
+    For {
+        loc: pt::Loc,
+        init_block: YulBlock,
+        condition: YulExpression,
+        post_block: YulBlock,
+        execution_block: YulBlock,
+    },
+    Leave(pt::Loc),
+    Break(pt::Loc),
+    Continue(pt::Loc),
+}
+
+#[derive(Debug, Clone)]
+pub struct CaseBlock {
+    pub loc: pt::Loc,
+    pub condition: YulExpression,
+    pub block: YulBlock,
+}

+ 19 - 20
src/sema/assembly/block.rs → src/sema/yul/block.rs

@@ -1,25 +1,25 @@
 use crate::ast::Namespace;
-use crate::sema::assembly::ast::{AssemblyBlock, AssemblyStatement};
-use crate::sema::assembly::functions::{
-    process_function_header, resolve_function_definition, FunctionsTable,
-};
-use crate::sema::assembly::statements::resolve_assembly_statement;
 use crate::sema::expression::ExprContext;
 use crate::sema::symtable::{LoopScopes, Symtable};
+use crate::sema::yul::ast::{YulBlock, YulStatement};
+use crate::sema::yul::functions::{
+    process_function_header, resolve_function_definition, FunctionsTable,
+};
+use crate::sema::yul::statements::resolve_yul_statement;
 use solang_parser::{pt, Diagnostic};
 
-/// Resolve an assembly block.
+/// Resolve an yul block.
 /// Returns the resolved block and a boolean that tells us if the next statement is reachable.
-pub fn resolve_assembly_block(
+pub fn resolve_yul_block(
     loc: &pt::Loc,
-    statements: &[pt::AssemblyStatement],
+    statements: &[pt::YulStatement],
     context: &ExprContext,
     mut reachable: bool,
     loop_scope: &mut LoopScopes,
     function_table: &mut FunctionsTable,
     symtable: &mut Symtable,
     ns: &mut Namespace,
-) -> (AssemblyBlock, bool) {
+) -> (YulBlock, bool) {
     function_table.new_scope();
     symtable.new_scope();
 
@@ -38,31 +38,31 @@ pub fn resolve_assembly_block(
     symtable.leave_scope();
     function_table.leave_scope(ns);
 
-    (AssemblyBlock { loc: *loc, body }, reachable)
+    (YulBlock { loc: *loc, body }, reachable)
 }
 
-/// Resolves an array of assembly statements.
+/// Resolves an array of yul statements.
 /// Returns a vector of tuples (resolved_statement, reachable) and a boolean that tells us if the
 /// next statement is reachable
 pub(crate) fn process_statements(
-    statements: &[pt::AssemblyStatement],
+    statements: &[pt::YulStatement],
     context: &ExprContext,
     mut reachable: bool,
     symtable: &mut Symtable,
     loop_scope: &mut LoopScopes,
     functions_table: &mut FunctionsTable,
     ns: &mut Namespace,
-) -> (Vec<(AssemblyStatement, bool)>, bool) {
+) -> (Vec<(YulStatement, bool)>, bool) {
     let mut func_count: usize = 0;
     for item in statements {
-        if let pt::AssemblyStatement::FunctionDefinition(fun_def) = item {
+        if let pt::YulStatement::FunctionDefinition(fun_def) = item {
             process_function_header(fun_def, functions_table, ns);
             func_count += 1;
         }
     }
 
     for item in statements {
-        if let pt::AssemblyStatement::FunctionDefinition(func_def) = item {
+        if let pt::YulStatement::FunctionDefinition(func_def) = item {
             if let Ok(resolved_func) =
                 resolve_function_definition(func_def, functions_table, context, ns)
             {
@@ -71,11 +71,10 @@ pub(crate) fn process_statements(
         }
     }
 
-    let mut body: Vec<(AssemblyStatement, bool)> =
-        Vec::with_capacity(statements.len() - func_count);
+    let mut body: Vec<(YulStatement, bool)> = Vec::with_capacity(statements.len() - func_count);
     let mut has_unreachable = false;
     for item in statements {
-        match resolve_assembly_statement(
+        match resolve_yul_statement(
             item,
             context,
             reachable,
@@ -96,11 +95,11 @@ pub(crate) fn process_statements(
                 */
                 if !reachable
                     && !has_unreachable
-                    && !matches!(item, pt::AssemblyStatement::FunctionDefinition(..))
+                    && !matches!(item, pt::YulStatement::FunctionDefinition(..))
                 {
                     ns.diagnostics.push(Diagnostic::warning(
                         item.loc(),
-                        "unreachable assembly statement".to_string(),
+                        "unreachable yul statement".to_string(),
                     ));
                     has_unreachable = true;
                 }

+ 242 - 242
src/sema/assembly/builtin.rs → src/sema/yul/builtin.rs

@@ -1,18 +1,18 @@
 use phf::{phf_map, phf_set};
 
-pub struct AssemblyBuiltinPrototype {
+pub struct YulBuiltinPrototype {
     pub name: &'static str,
     pub no_args: u8,
     pub no_returns: u8,
     pub doc: &'static str,
-    pub ty: AssemblyBuiltInFunction,
+    pub ty: YulBuiltInFunction,
     pub stops_execution: bool,
 }
 
 // The enums declaration order should match that of the static vector containing the builtins
 #[derive(Clone, Debug, PartialEq, Copy)]
 #[repr(u8)]
-pub enum AssemblyBuiltInFunction {
+pub enum YulBuiltInFunction {
     Stop = 0,
     Add = 1,
     Sub = 2,
@@ -98,726 +98,726 @@ static UNSUPPORTED_BUILTINS: phf::Set<&'static str> = phf_set! {
 };
 
 /// Checks if bultin function is unsupported
-pub(crate) fn assembly_unsupported_builtin(name: &str) -> bool {
+pub(crate) fn yul_unsupported_builtin(name: &str) -> bool {
     UNSUPPORTED_BUILTINS.contains(name)
 }
 
-static BUILTIN_ASSEMBLY_FUNCTIONS: phf::Map<&'static str, AssemblyBuiltInFunction> = phf_map! {
-    "stop" => AssemblyBuiltInFunction::Stop,
-    "add" => AssemblyBuiltInFunction::Add,
-    "sub" => AssemblyBuiltInFunction::Sub,
-    "mul" => AssemblyBuiltInFunction::Mul,
-    "div" => AssemblyBuiltInFunction::Div,
-    "sdiv" => AssemblyBuiltInFunction::SDiv,
-    "mod" => AssemblyBuiltInFunction::Mod,
-    "smod" => AssemblyBuiltInFunction::SMod,
-    "exp" => AssemblyBuiltInFunction::Exp,
-    "not" => AssemblyBuiltInFunction::Not,
-    "lt" => AssemblyBuiltInFunction::Lt,
-    "gt" => AssemblyBuiltInFunction::Gt,
-    "slt" => AssemblyBuiltInFunction::Slt,
-    "sgt" => AssemblyBuiltInFunction::Sgt,
-    "eq" => AssemblyBuiltInFunction::Eq,
-    "iszero" => AssemblyBuiltInFunction::IsZero,
-    "and" => AssemblyBuiltInFunction::And,
-    "or" => AssemblyBuiltInFunction::Or,
-    "xor" => AssemblyBuiltInFunction::Xor,
-    "byte" => AssemblyBuiltInFunction::Byte,
-    "shl" => AssemblyBuiltInFunction::Shl,
-    "shr" => AssemblyBuiltInFunction::Shr,
-    "sar" => AssemblyBuiltInFunction::Sar,
-    "addmod" => AssemblyBuiltInFunction::AddMod,
-    "mulmod" => AssemblyBuiltInFunction::MulMod,
-    "signextend" => AssemblyBuiltInFunction::SignExtend,
-    "keccak256" => AssemblyBuiltInFunction::Keccak256,
-    "pc" => AssemblyBuiltInFunction::Pc,
-    "pop" => AssemblyBuiltInFunction::Pop,
-    "mload" => AssemblyBuiltInFunction::MLoad,
-    "mstore" => AssemblyBuiltInFunction::MStore,
-    "mstore8" => AssemblyBuiltInFunction::MStore8,
-    "sload" => AssemblyBuiltInFunction::SLoad,
-    "sstore" => AssemblyBuiltInFunction::SStore,
-    "msize" => AssemblyBuiltInFunction::MSize,
-    "gas" => AssemblyBuiltInFunction::Gas,
-    "address" => AssemblyBuiltInFunction::Address,
-    "balance" => AssemblyBuiltInFunction::Balance,
-    "selfbalance" => AssemblyBuiltInFunction::SelfBalance,
-    "caller" => AssemblyBuiltInFunction::Caller,
-    "callvalue" => AssemblyBuiltInFunction::CallValue,
-    "calldataload" => AssemblyBuiltInFunction::CallDataLoad,
-    "calldatasize" => AssemblyBuiltInFunction::CallDataSize,
-    "calldatacopy" => AssemblyBuiltInFunction::CallDataCopy,
-    "codesize" => AssemblyBuiltInFunction::CodeSize,
-    "codecopy" => AssemblyBuiltInFunction::CodeCopy,
-    "extcodesize" => AssemblyBuiltInFunction::ExtCodeSize,
-    "extcodecopy" => AssemblyBuiltInFunction::ExtCodeCopy,
-    "returndatasize" => AssemblyBuiltInFunction::ReturnDataSize,
-    "returndatacopy" => AssemblyBuiltInFunction::ReturnDataCopy,
-    "extcodehash" => AssemblyBuiltInFunction::ExtCodeHash,
-    "create" => AssemblyBuiltInFunction::Create,
-    "create2" => AssemblyBuiltInFunction::Create2,
-    "call" => AssemblyBuiltInFunction::Call,
-    "callcode" => AssemblyBuiltInFunction::CallCode,
-    "delegatecall" => AssemblyBuiltInFunction::DelegateCall,
-    "staticcall" => AssemblyBuiltInFunction::StaticCall,
-    "return" => AssemblyBuiltInFunction::Return,
-    "revert" => AssemblyBuiltInFunction::Revert,
-    "selfdestruct" => AssemblyBuiltInFunction::SelfDestruct,
-    "invalid" => AssemblyBuiltInFunction::Invalid,
-    "log0" => AssemblyBuiltInFunction::Log0,
-    "log1" => AssemblyBuiltInFunction::Log1,
-    "log2" => AssemblyBuiltInFunction::Log2,
-    "log3" => AssemblyBuiltInFunction::Log3,
-    "log4" => AssemblyBuiltInFunction::Log4,
-    "chainid" => AssemblyBuiltInFunction::ChainId,
-    "basefee" => AssemblyBuiltInFunction::BaseFee,
-    "origin" => AssemblyBuiltInFunction::Origin,
-    "gasprice" => AssemblyBuiltInFunction::GasPrice,
-    "blockhash" => AssemblyBuiltInFunction::BlockHash,
-    "coinbase" => AssemblyBuiltInFunction::CoinBase,
-    "timestamp" => AssemblyBuiltInFunction::Timestamp,
-    "number" => AssemblyBuiltInFunction::Number,
-    "difficulty" => AssemblyBuiltInFunction::Difficulty,
-    "gaslimit" => AssemblyBuiltInFunction::GasLimit,
+static BUILTIN_YUL_FUNCTIONS: phf::Map<&'static str, YulBuiltInFunction> = phf_map! {
+    "stop" => YulBuiltInFunction::Stop,
+    "add" => YulBuiltInFunction::Add,
+    "sub" => YulBuiltInFunction::Sub,
+    "mul" => YulBuiltInFunction::Mul,
+    "div" => YulBuiltInFunction::Div,
+    "sdiv" => YulBuiltInFunction::SDiv,
+    "mod" => YulBuiltInFunction::Mod,
+    "smod" => YulBuiltInFunction::SMod,
+    "exp" => YulBuiltInFunction::Exp,
+    "not" => YulBuiltInFunction::Not,
+    "lt" => YulBuiltInFunction::Lt,
+    "gt" => YulBuiltInFunction::Gt,
+    "slt" => YulBuiltInFunction::Slt,
+    "sgt" => YulBuiltInFunction::Sgt,
+    "eq" => YulBuiltInFunction::Eq,
+    "iszero" => YulBuiltInFunction::IsZero,
+    "and" => YulBuiltInFunction::And,
+    "or" => YulBuiltInFunction::Or,
+    "xor" => YulBuiltInFunction::Xor,
+    "byte" => YulBuiltInFunction::Byte,
+    "shl" => YulBuiltInFunction::Shl,
+    "shr" => YulBuiltInFunction::Shr,
+    "sar" => YulBuiltInFunction::Sar,
+    "addmod" => YulBuiltInFunction::AddMod,
+    "mulmod" => YulBuiltInFunction::MulMod,
+    "signextend" => YulBuiltInFunction::SignExtend,
+    "keccak256" => YulBuiltInFunction::Keccak256,
+    "pc" => YulBuiltInFunction::Pc,
+    "pop" => YulBuiltInFunction::Pop,
+    "mload" => YulBuiltInFunction::MLoad,
+    "mstore" => YulBuiltInFunction::MStore,
+    "mstore8" => YulBuiltInFunction::MStore8,
+    "sload" => YulBuiltInFunction::SLoad,
+    "sstore" => YulBuiltInFunction::SStore,
+    "msize" => YulBuiltInFunction::MSize,
+    "gas" => YulBuiltInFunction::Gas,
+    "address" => YulBuiltInFunction::Address,
+    "balance" => YulBuiltInFunction::Balance,
+    "selfbalance" => YulBuiltInFunction::SelfBalance,
+    "caller" => YulBuiltInFunction::Caller,
+    "callvalue" => YulBuiltInFunction::CallValue,
+    "calldataload" => YulBuiltInFunction::CallDataLoad,
+    "calldatasize" => YulBuiltInFunction::CallDataSize,
+    "calldatacopy" => YulBuiltInFunction::CallDataCopy,
+    "codesize" => YulBuiltInFunction::CodeSize,
+    "codecopy" => YulBuiltInFunction::CodeCopy,
+    "extcodesize" => YulBuiltInFunction::ExtCodeSize,
+    "extcodecopy" => YulBuiltInFunction::ExtCodeCopy,
+    "returndatasize" => YulBuiltInFunction::ReturnDataSize,
+    "returndatacopy" => YulBuiltInFunction::ReturnDataCopy,
+    "extcodehash" => YulBuiltInFunction::ExtCodeHash,
+    "create" => YulBuiltInFunction::Create,
+    "create2" => YulBuiltInFunction::Create2,
+    "call" => YulBuiltInFunction::Call,
+    "callcode" => YulBuiltInFunction::CallCode,
+    "delegatecall" => YulBuiltInFunction::DelegateCall,
+    "staticcall" => YulBuiltInFunction::StaticCall,
+    "return" => YulBuiltInFunction::Return,
+    "revert" => YulBuiltInFunction::Revert,
+    "selfdestruct" => YulBuiltInFunction::SelfDestruct,
+    "invalid" => YulBuiltInFunction::Invalid,
+    "log0" => YulBuiltInFunction::Log0,
+    "log1" => YulBuiltInFunction::Log1,
+    "log2" => YulBuiltInFunction::Log2,
+    "log3" => YulBuiltInFunction::Log3,
+    "log4" => YulBuiltInFunction::Log4,
+    "chainid" => YulBuiltInFunction::ChainId,
+    "basefee" => YulBuiltInFunction::BaseFee,
+    "origin" => YulBuiltInFunction::Origin,
+    "gasprice" => YulBuiltInFunction::GasPrice,
+    "blockhash" => YulBuiltInFunction::BlockHash,
+    "coinbase" => YulBuiltInFunction::CoinBase,
+    "timestamp" => YulBuiltInFunction::Timestamp,
+    "number" => YulBuiltInFunction::Number,
+    "difficulty" => YulBuiltInFunction::Difficulty,
+    "gaslimit" => YulBuiltInFunction::GasLimit,
 };
 
 /// Retrieved the builtin function type from an identifier name
-pub fn parse_builtin_keyword(keyword: &str) -> Option<&AssemblyBuiltInFunction> {
-    BUILTIN_ASSEMBLY_FUNCTIONS.get(keyword)
+pub fn parse_builtin_keyword(keyword: &str) -> Option<&YulBuiltInFunction> {
+    BUILTIN_YUL_FUNCTIONS.get(keyword)
 }
 
-impl AssemblyBuiltInFunction {
+impl YulBuiltInFunction {
     /// Retrieve the prototype from the enum type
-    pub(crate) fn get_prototype_info(self) -> &'static AssemblyBuiltinPrototype {
+    pub(crate) fn get_prototype_info(self) -> &'static YulBuiltinPrototype {
         let index = self as usize;
-        &ASSEMBLY_BUILTIN[index]
+        &YUL_BUILTIN[index]
     }
 }
 
-impl ToString for AssemblyBuiltInFunction {
+impl ToString for YulBuiltInFunction {
     fn to_string(&self) -> String {
         let prototype = self.get_prototype_info();
         prototype.name.to_owned()
     }
 }
 
-// Assembly built-in functions.
+// Yul built-in functions.
 // Descriptions copied and slightly modified from: https://docs.soliditylang.org/en/v0.8.12/yul.html
-static ASSEMBLY_BUILTIN: [AssemblyBuiltinPrototype; 76] =
+static YUL_BUILTIN: [YulBuiltinPrototype; 76] =
     [
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "stop",
             no_args: 0,
             no_returns: 0,
             doc: "Stop execution",
-            ty: AssemblyBuiltInFunction::Stop,
+            ty: YulBuiltInFunction::Stop,
             stops_execution: true,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "add",
             no_args: 2,
             no_returns: 1,
             doc: "add(x, y) returns x + y",
-            ty: AssemblyBuiltInFunction::Add,
+            ty: YulBuiltInFunction::Add,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "sub",
             no_args: 2,
             no_returns: 1,
             doc: "sub(x, y) returns x - y",
-            ty: AssemblyBuiltInFunction::Sub,
+            ty: YulBuiltInFunction::Sub,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "mul",
             no_args: 2,
             no_returns: 1,
             doc: "mul(x, y) returns x*y",
-            ty: AssemblyBuiltInFunction::Mul,
+            ty: YulBuiltInFunction::Mul,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "div",
             no_args: 2,
             no_returns: 1,
             doc: "div(x, y) returns x/y or 0 if y == 0",
-            ty: AssemblyBuiltInFunction::Div,
+            ty: YulBuiltInFunction::Div,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "sdiv",
             no_args: 2,
             no_returns: 1,
             doc: "sdiv(x, y) returns x/y or 0 if y==0. Used for signed numbers in two's complement",
-            ty: AssemblyBuiltInFunction::SDiv,
+            ty: YulBuiltInFunction::SDiv,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "mod",
             no_args: 2,
             no_returns: 1,
             doc: "mod(x, y) returns x % y or 0 if y == 0",
-            ty: AssemblyBuiltInFunction::Mod,
+            ty: YulBuiltInFunction::Mod,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "smod",
             no_args: 2,
             no_returns: 1,
             doc: "smod(x, y) returns x % y or 0 if y == 0. Used for signed numbers in two's complement",
-            ty: AssemblyBuiltInFunction::SMod,
+            ty: YulBuiltInFunction::SMod,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "exp",
             no_args: 2,
             no_returns: 1,
             doc: "exp(x, y) returns x to the power of y",
-            ty: AssemblyBuiltInFunction::Exp,
+            ty: YulBuiltInFunction::Exp,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "not",
             no_args: 1,
             no_returns: 1,
             doc: "not(x): bitwise \"not\" of x (every bit is negated)",
-            ty: AssemblyBuiltInFunction::Not,
+            ty: YulBuiltInFunction::Not,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "lt",
             no_args: 2,
             no_returns: 1,
             doc: "lt(x, y) returns 1 if x < y, 0 otherwise",
-            ty: AssemblyBuiltInFunction::Lt,
+            ty: YulBuiltInFunction::Lt,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "gt",
             no_args: 2,
             no_returns: 1,
             doc: "gt(x, y) returns 1 if x > y, 0 otherwise",
-            ty: AssemblyBuiltInFunction::Gt,
+            ty: YulBuiltInFunction::Gt,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "slt",
             no_args: 2,
             no_returns: 1,
             doc: "slt(x, y) returns 1 if x > y, 0 otherwise. Used for signed numbers in two's complement",
-            ty: AssemblyBuiltInFunction::Slt,
+            ty: YulBuiltInFunction::Slt,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "sgt",
             no_args: 2,
             no_returns: 1,
             doc: "sgt(x, y) returns 1 if x > y, 0 otherwise. Used for signed numbers in two's complement",
-            ty: AssemblyBuiltInFunction::Sgt,
+            ty: YulBuiltInFunction::Sgt,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "eq",
             no_args: 2,
             no_returns: 1,
             doc: "eq(x, y) returns 1 if x == y, 0 otherwise",
-            ty: AssemblyBuiltInFunction::Eq,
+            ty: YulBuiltInFunction::Eq,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "iszero",
             no_args: 1,
             no_returns: 1,
             doc: "iszero(x) returns 1 if x == 0, 0 otherwise",
-            ty: AssemblyBuiltInFunction::IsZero,
+            ty: YulBuiltInFunction::IsZero,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "and",
             no_args: 2,
             no_returns: 1,
             doc: "and(x, y) returns the bitwise \"and\" between x and y",
-            ty: AssemblyBuiltInFunction::And,
+            ty: YulBuiltInFunction::And,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "or",
             no_args: 2,
             no_returns: 1,
             doc: "or(x, y) returns the bitwise \"or\" between x and y",
-            ty: AssemblyBuiltInFunction::Or,
+            ty: YulBuiltInFunction::Or,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "xor",
             no_args: 2,
             no_returns: 1,
             doc: "xor(x, y) returns the bitwise \"xor\" between x and y",
-            ty: AssemblyBuiltInFunction::Xor,
+            ty: YulBuiltInFunction::Xor,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "byte",
             no_args: 2,
             no_returns: 1,
             doc: "byte(n, x) returns the nth byte of x, where the most significant byt is the 0th",
-            ty: AssemblyBuiltInFunction::Byte,
+            ty: YulBuiltInFunction::Byte,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "shl",
             no_args: 2,
             no_returns: 1,
             doc: "shl(x, y) returns the logical shift left of y by x bits",
-            ty: AssemblyBuiltInFunction::Shl,
+            ty: YulBuiltInFunction::Shl,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "shr",
             no_args: 2,
             no_returns: 1,
             doc: "shr(x, y) returns the logical shift right of y by x bits",
-            ty: AssemblyBuiltInFunction::Shr,
+            ty: YulBuiltInFunction::Shr,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "sar",
             no_args: 2,
             no_returns: 1,
             doc: "signed arithmetic shift right y by x bits",
-            ty: AssemblyBuiltInFunction::Sar,
+            ty: YulBuiltInFunction::Sar,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "addmod",
             no_args: 3,
             no_returns: 1,
             doc: "addmod(x, y, m) returns (x + y) % m or 0 if m == 0",
-            ty: AssemblyBuiltInFunction::AddMod,
+            ty: YulBuiltInFunction::AddMod,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "mulmod",
             no_args: 3,
             no_returns: 1,
             doc: "mulmod(x, y, m) returns (x * y) % m or 0 if m == 0",
-            ty: AssemblyBuiltInFunction::MulMod,
+            ty: YulBuiltInFunction::MulMod,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "signextend",
             no_args: 2,
             no_returns: 1,
             doc: "signextend(i, x) sign extends from (i*8+7)th bit counting from least significant",
-            ty: AssemblyBuiltInFunction::SignExtend,
+            ty: YulBuiltInFunction::SignExtend,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "keccak256",
             no_args: 2,
             no_returns: 1,
             doc: "keccak256(p, n) performs keccak(mem[p...(p+n)])",
-            ty: AssemblyBuiltInFunction::Keccak256,
+            ty: YulBuiltInFunction::Keccak256,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "pc",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the current position in code, i.e. the program counter",
-            ty: AssemblyBuiltInFunction::Pc,
+            ty: YulBuiltInFunction::Pc,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "pop",
             no_args: 1,
             no_returns: 0,
             doc: "pop(x) discard value x",
-            ty: AssemblyBuiltInFunction::Pop,
+            ty: YulBuiltInFunction::Pop,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "mload",
             no_args: 1,
             no_returns: 1,
             doc: "mload(p) returns mem[p...(p+32)]",
-            ty: AssemblyBuiltInFunction::MLoad,
+            ty: YulBuiltInFunction::MLoad,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "mstore",
             no_args: 2,
             no_returns: 0,
             doc: "mstore(p, v) stores v into mem[p...(p+32)]",
-            ty: AssemblyBuiltInFunction::MStore,
+            ty: YulBuiltInFunction::MStore,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "mstore8",
             no_args: 2,
             no_returns: 0,
             doc: "mstore8(p, v) stores (v & 0xff) into mem[p] (modified a single byte of v)",
-            ty: AssemblyBuiltInFunction::MStore8,
+            ty: YulBuiltInFunction::MStore8,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "sload",
             no_args: 1,
             no_returns: 1,
             doc: "sload(p) returns storage[p], i.e. memory on contract's storage",
-            ty: AssemblyBuiltInFunction::SLoad,
+            ty: YulBuiltInFunction::SLoad,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "sstore",
             no_args: 2,
             no_returns: 0,
             doc: "sstore(p) stores v into storage[p]",
-            ty: AssemblyBuiltInFunction::SStore,
+            ty: YulBuiltInFunction::SStore,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "msize",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the size of memory, i.e largest accessed memory index",
-            ty: AssemblyBuiltInFunction::MSize,
+            ty: YulBuiltInFunction::MSize,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "gas",
             no_args: 0,
             no_returns: 1,
             doc: "Returns gas still available to execution",
-            ty: AssemblyBuiltInFunction::Gas,
+            ty: YulBuiltInFunction::Gas,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "address",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the address of the current contract / execution context",
-            ty: AssemblyBuiltInFunction::Address,
+            ty: YulBuiltInFunction::Address,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "balance",
             no_args: 2,
             no_returns: 1,
             doc: "balance(a) returns the wei balance at address a",
-            ty: AssemblyBuiltInFunction::Balance,
+            ty: YulBuiltInFunction::Balance,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "selfbalance",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the wei balance at the address of the current contract / execution context",
-            ty: AssemblyBuiltInFunction::SelfBalance,
+            ty: YulBuiltInFunction::SelfBalance,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "caller",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the call sender",
-            ty: AssemblyBuiltInFunction::Caller,
+            ty: YulBuiltInFunction::Caller,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "callvalue",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the wei sent together with the current call",
-            ty: AssemblyBuiltInFunction::CallValue,
+            ty: YulBuiltInFunction::CallValue,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "calldataload",
             no_args: 1,
             no_returns: 1,
             doc: "calldataload(p) returns call data starting from position p (32 bytes)",
-            ty: AssemblyBuiltInFunction::CallDataLoad,
+            ty: YulBuiltInFunction::CallDataLoad,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "calldatasize",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the size of call data in bytes",
-            ty: AssemblyBuiltInFunction::CallDataSize,
+            ty: YulBuiltInFunction::CallDataSize,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "calldatacopy",
             no_args: 3,
             no_returns: 0,
             doc: "calldatacopy(t, f, s) copies s bytes from calldata at position f to mem at position t",
-            ty: AssemblyBuiltInFunction::CallDataCopy,
+            ty: YulBuiltInFunction::CallDataCopy,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "codesize",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the size of the current contract / execution context",
-            ty: AssemblyBuiltInFunction::CodeSize,
+            ty: YulBuiltInFunction::CodeSize,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "codecopy",
             no_args: 3,
             no_returns: 0,
             doc: "codecopy(t, f, s) copies s bytes from code at position f to mem at position t",
-            ty: AssemblyBuiltInFunction::CodeCopy,
+            ty: YulBuiltInFunction::CodeCopy,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "extcodesize",
             no_args: 1,
             no_returns: 1,
             doc: "extcodesize(a) returns the size of the code at address a",
-            ty: AssemblyBuiltInFunction::ExtCodeSize,
+            ty: YulBuiltInFunction::ExtCodeSize,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "extcodecopy",
             no_args: 4,
             no_returns: 0,
             doc: "extcodecopy(a, t, f, s) copies s bytes from code located at address a at position f to mem at position t",
-            ty: AssemblyBuiltInFunction::ExtCodeCopy,
+            ty: YulBuiltInFunction::ExtCodeCopy,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "returndatasize",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the size of the last returndata",
-            ty: AssemblyBuiltInFunction::ReturnDataSize,
+            ty: YulBuiltInFunction::ReturnDataSize,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "returndatacopy",
             no_args: 3,
             no_returns: 0,
             doc: "returndatacopy(t, f, s) copy s bytes from return data at position f to mem at position t",
-            ty: AssemblyBuiltInFunction::ReturnDataCopy,
+            ty: YulBuiltInFunction::ReturnDataCopy,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "extcodehash",
             no_args: 1,
             no_returns: 1,
             doc: "extcodehash(a) returns the code hash of address a",
-            ty: AssemblyBuiltInFunction::ExtCodeHash,
+            ty: YulBuiltInFunction::ExtCodeHash,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "create",
             no_args: 3,
             no_returns: 1,
             doc: "create(v, p, n) creates new contract with code mem[p..(p+n)] and sends v wei. It returns the new address or 0 on error",
-            ty: AssemblyBuiltInFunction::Create,
+            ty: YulBuiltInFunction::Create,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "create2",
             no_args: 4,
             no_returns: 1,
             doc: "create2(v, p, n, s) new contract with code mem[p...(p+n)] at address keccak256(0xff . this . s . keccak256(mem[p...(p+n)]) and sends v wei.\n 0xff is a 1 byte value, 'this' is the current contract's address as a 20 byte value and 's' is a big endian 256-bit value. it returns 0 on error.",
-            ty: AssemblyBuiltInFunction::Create2,
+            ty: YulBuiltInFunction::Create2,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "call",
             no_args: 7,
             no_returns: 1,
             doc: "call(g, a, v, in, insize, out, outsize) calls contract at address a with input mem[in...(in+insize)] providing f cas and v wei and outputs area mem[out...(out+outsize)]. It returns 0 on error and 1 on success",
-            ty: AssemblyBuiltInFunction::Call,
+            ty: YulBuiltInFunction::Call,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "callcode",
             no_args: 7,
             no_returns: 1,
             doc: "Identical to call(g, a, v, in, insize, out, outsize), but only use the code from a and stay in the context of the current contract otherwise",
-            ty: AssemblyBuiltInFunction::CallCode,
+            ty: YulBuiltInFunction::CallCode,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "delegatecall",
             no_args: 6,
             no_returns: 1,
             doc: "Identical to 'callcode' but also keep caller and callvalue",
-            ty: AssemblyBuiltInFunction::DelegateCall,
+            ty: YulBuiltInFunction::DelegateCall,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "staticcall",
             no_args: 6,
             no_returns: 1,
             doc: "Identical to call(g, a, 0, in, insize, out, outsize), but do not allow state modifications",
-            ty: AssemblyBuiltInFunction::StaticCall,
+            ty: YulBuiltInFunction::StaticCall,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "return",
             no_args: 2,
             no_returns: 0,
             doc: "return(p, s) ends execution and returns data mem[p...(p+s)]",
-            ty: AssemblyBuiltInFunction::Return,
+            ty: YulBuiltInFunction::Return,
             stops_execution: true,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "revert",
             no_args: 2,
             no_returns: 0,
             doc: "revert(p, s) ends execution, reverts state changes and returns data mem[p...(p+s)]",
-            ty: AssemblyBuiltInFunction::Revert,
+            ty: YulBuiltInFunction::Revert,
             stops_execution: true,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "selfdestruct",
             no_args: 1,
             no_returns: 0,
             doc: "selfdestruct(a) ends execution, destroy current contract and sends funds to a",
-            ty: AssemblyBuiltInFunction::SelfDestruct,
+            ty: YulBuiltInFunction::SelfDestruct,
             stops_execution: true,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "invalid",
             no_args: 0,
             no_returns: 0,
             doc: "Ends execution with invalid instruction",
-            ty: AssemblyBuiltInFunction::Invalid,
+            ty: YulBuiltInFunction::Invalid,
             stops_execution: true,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "log0",
             no_args: 2,
             no_returns: 0,
             doc: "log(p, s): log without topics and data mem[p...(p+s)]",
-            ty: AssemblyBuiltInFunction::Log0,
+            ty: YulBuiltInFunction::Log0,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "log1",
             no_args: 3,
             no_returns: 0,
             doc: "log1(p, s, t1): log with topic t1 and data mem[p...(p+s)]",
-            ty: AssemblyBuiltInFunction::Log1,
+            ty: YulBuiltInFunction::Log1,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "log2",
             no_args: 4,
             no_returns: 0,
             doc: "log2(p, s, t1, t2): log with topics t1, t2 and data mem[p...(p+s)]",
-            ty: AssemblyBuiltInFunction::Log2,
+            ty: YulBuiltInFunction::Log2,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "log3",
             no_args: 5,
             no_returns: 0,
             doc: "log3(p, s, t1, t2, t3): log with topics t1, t2, t3 and data mem[p...(p+s)]",
-            ty: AssemblyBuiltInFunction::Log3,
+            ty: YulBuiltInFunction::Log3,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "log4",
             no_args: 6,
             no_returns: 0,
             doc: "log4(p, s, t1, t2, t3, t4): log with topics t1, t2, t3, t4 with data mem[p...(p+s)]",
-            ty: AssemblyBuiltInFunction::Log4,
+            ty: YulBuiltInFunction::Log4,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "chainid",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the ID of the executing chain",
-            ty: AssemblyBuiltInFunction::ChainId,
+            ty: YulBuiltInFunction::ChainId,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "basefee",
             no_args: 0,
             no_returns: 1,
             doc: "Return the current block's base fee",
-            ty: AssemblyBuiltInFunction::BaseFee,
+            ty: YulBuiltInFunction::BaseFee,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "origin",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the transaction sender",
-            ty: AssemblyBuiltInFunction::Origin,
+            ty: YulBuiltInFunction::Origin,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "gasprice",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the gas price of the transaction",
-            ty: AssemblyBuiltInFunction::GasPrice,
+            ty: YulBuiltInFunction::GasPrice,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "blockhash",
             no_args: 1,
             no_returns: 1,
             doc: "blockhash(b) return the hash of block #b - only valid for the last 256 executing block excluding current",
-            ty: AssemblyBuiltInFunction::BlockHash,
+            ty: YulBuiltInFunction::BlockHash,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "coinbase",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the current mining beneficiary",
-            ty: AssemblyBuiltInFunction::CoinBase,
+            ty: YulBuiltInFunction::CoinBase,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "timestamp",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the timestamp of the current block in seconds since the epoch",
-            ty: AssemblyBuiltInFunction::Timestamp,
+            ty: YulBuiltInFunction::Timestamp,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "number",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the current block's number",
-            ty: AssemblyBuiltInFunction::Number,
+            ty: YulBuiltInFunction::Number,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "difficulty",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the difficulty of the current block",
-            ty: AssemblyBuiltInFunction::Difficulty,
+            ty: YulBuiltInFunction::Difficulty,
             stops_execution: false,
         },
-        AssemblyBuiltinPrototype{
+        YulBuiltinPrototype {
             name: "gaslimit",
             no_args: 0,
             no_returns: 1,
             doc: "Returns the current block's gas limit",
-            ty: AssemblyBuiltInFunction::GasLimit,
+            ty: YulBuiltInFunction::GasLimit,
             stops_execution: false,
         },
     ];
 
 #[test]
 fn test_builtin_indexes() {
-    for item in &ASSEMBLY_BUILTIN {
+    for item in &YUL_BUILTIN {
         let name = item.name;
         let ty = item.ty;
 

+ 89 - 110
src/sema/assembly/expression.rs → src/sema/yul/expression.rs

@@ -1,52 +1,50 @@
 use crate::ast::{Namespace, Symbol, Type};
-use crate::sema::assembly::ast::{AssemblyExpression, AssemblyFunctionParameter, AssemblySuffix};
-use crate::sema::assembly::builtin::{assembly_unsupported_builtin, parse_builtin_keyword};
-use crate::sema::assembly::functions::FunctionsTable;
-use crate::sema::assembly::types::{
-    get_default_type_from_identifier, get_type_from_string, verify_type_from_expression,
-};
-use crate::sema::assembly::unused_variable::{assigned_variable, used_variable};
 use crate::sema::expression::{unescape, ExprContext};
 use crate::sema::symtable::{Symtable, VariableUsage};
+use crate::sema::yul::ast::{YulExpression, YulFunctionParameter, YulSuffix};
+use crate::sema::yul::builtin::{parse_builtin_keyword, yul_unsupported_builtin};
+use crate::sema::yul::functions::FunctionsTable;
+use crate::sema::yul::types::{
+    get_default_type_from_identifier, get_type_from_string, verify_type_from_expression,
+};
+use crate::sema::yul::unused_variable::{assigned_variable, used_variable};
 use num_bigint::{BigInt, Sign};
 use num_traits::Num;
 use solang_parser::diagnostics::{ErrorType, Level};
-use solang_parser::pt::{AssemblyFunctionCall, CodeLocation, Identifier, Loc, StorageLocation};
+use solang_parser::pt::{CodeLocation, Identifier, Loc, StorageLocation, YulFunctionCall};
 use solang_parser::{pt, Diagnostic};
 
 /// Given a keyword, returns the suffix it represents in YUL
-fn get_suffix_from_string(suffix_name: &str) -> Option<AssemblySuffix> {
+fn get_suffix_from_string(suffix_name: &str) -> Option<YulSuffix> {
     match suffix_name {
-        "offset" => Some(AssemblySuffix::Offset),
-        "slot" => Some(AssemblySuffix::Slot),
-        "length" => Some(AssemblySuffix::Length),
-        "selector" => Some(AssemblySuffix::Selector),
-        "address" => Some(AssemblySuffix::Address),
+        "offset" => Some(YulSuffix::Offset),
+        "slot" => Some(YulSuffix::Slot),
+        "length" => Some(YulSuffix::Length),
+        "selector" => Some(YulSuffix::Selector),
+        "address" => Some(YulSuffix::Address),
         _ => None,
     }
 }
 
-/// Resolve an assembly expression.
-pub(crate) fn resolve_assembly_expression(
-    expr: &pt::AssemblyExpression,
+/// Resolve an yul expression.
+pub(crate) fn resolve_yul_expression(
+    expr: &pt::YulExpression,
     context: &ExprContext,
     symtable: &mut Symtable,
     function_table: &mut FunctionsTable,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     match expr {
-        pt::AssemblyExpression::BoolLiteral(loc, value, ty) => {
-            resolve_bool_literal(loc, value, ty, ns)
-        }
+        pt::YulExpression::BoolLiteral(loc, value, ty) => resolve_bool_literal(loc, value, ty, ns),
 
-        pt::AssemblyExpression::NumberLiteral(loc, value, ty) => {
+        pt::YulExpression::NumberLiteral(loc, value, ty) => {
             resolve_number_literal(loc, value, ty, ns)
         }
 
-        pt::AssemblyExpression::HexNumberLiteral(loc, value, ty) => {
+        pt::YulExpression::HexNumberLiteral(loc, value, ty) => {
             resolve_hex_literal(loc, value, ty, ns)
         }
-        pt::AssemblyExpression::HexStringLiteral(value, ty) => {
+        pt::YulExpression::HexStringLiteral(value, ty) => {
             if (value.hex.len() % 2) != 0 {
                 ns.diagnostics.push(Diagnostic {
                     pos: value.loc,
@@ -64,7 +62,7 @@ pub(crate) fn resolve_assembly_expression(
             resolve_string_literal(&value.loc, byte_array, ty, ns)
         }
 
-        pt::AssemblyExpression::StringLiteral(value, ty) => {
+        pt::YulExpression::StringLiteral(value, ty) => {
             let unescaped_string = unescape(
                 &value.string[..],
                 0,
@@ -74,15 +72,13 @@ pub(crate) fn resolve_assembly_expression(
             resolve_string_literal(&value.loc, unescaped_string, ty, ns)
         }
 
-        pt::AssemblyExpression::Variable(id) => {
-            resolve_variable_reference(id, ns, symtable, context)
-        }
+        pt::YulExpression::Variable(id) => resolve_variable_reference(id, ns, symtable, context),
 
-        pt::AssemblyExpression::FunctionCall(func_call) => {
+        pt::YulExpression::FunctionCall(func_call) => {
             resolve_function_call(function_table, func_call, context, symtable, ns)
         }
 
-        pt::AssemblyExpression::Member(loc, expr, id) => {
+        pt::YulExpression::Member(loc, expr, id) => {
             resolve_member_access(loc, expr, id, context, symtable, function_table, ns)
         }
     }
@@ -101,7 +97,7 @@ fn resolve_bool_literal(
     value: &bool,
     ty: &Option<pt::Identifier>,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     let new_type = if let Some(type_id) = ty {
         if let Some(asm_type) = get_type_from_string(&type_id.name) {
             asm_type
@@ -116,7 +112,7 @@ fn resolve_bool_literal(
         Type::Bool
     };
 
-    Ok(AssemblyExpression::BoolLiteral(*loc, *value, new_type))
+    Ok(YulExpression::BoolLiteral(*loc, *value, new_type))
 }
 
 fn resolve_number_literal(
@@ -124,7 +120,7 @@ fn resolve_number_literal(
     value: &BigInt,
     ty: &Option<pt::Identifier>,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     let new_type = if let Some(type_id) = ty {
         if let Some(asm_type) = get_type_from_string(&type_id.name) {
             if matches!(asm_type, Type::Uint(_)) && matches!(value.sign(), Sign::Minus) {
@@ -169,11 +165,7 @@ fn resolve_number_literal(
         });
     }
 
-    Ok(AssemblyExpression::NumberLiteral(
-        *loc,
-        value.clone(),
-        new_type,
-    ))
+    Ok(YulExpression::NumberLiteral(*loc, value.clone(), new_type))
 }
 
 fn resolve_hex_literal(
@@ -181,7 +173,7 @@ fn resolve_hex_literal(
     value: &str,
     ty: &Option<pt::Identifier>,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     let new_type = get_default_type_from_identifier(ty, ns)?;
 
     let s: String = value.chars().skip(2).filter(|v| *v != '_').collect();
@@ -201,7 +193,7 @@ fn resolve_hex_literal(
         });
     }
 
-    Ok(AssemblyExpression::NumberLiteral(*loc, val, new_type))
+    Ok(YulExpression::NumberLiteral(*loc, val, new_type))
 }
 
 fn resolve_string_literal(
@@ -209,7 +201,7 @@ fn resolve_string_literal(
     byte_array: Vec<u8>,
     ty: &Option<pt::Identifier>,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     let new_type = get_default_type_from_identifier(ty, ns)?;
     let type_size = new_type.get_type_size();
 
@@ -227,9 +219,7 @@ fn resolve_string_literal(
         });
     }
 
-    Ok(AssemblyExpression::StringLiteral(
-        *loc, byte_array, new_type,
-    ))
+    Ok(YulExpression::StringLiteral(*loc, byte_array, new_type))
 }
 
 fn resolve_variable_reference(
@@ -237,21 +227,17 @@ fn resolve_variable_reference(
     ns: &mut Namespace,
     symtable: &Symtable,
     context: &ExprContext,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     if let Some(v) = symtable.find(&id.name) {
         match &v.usage_type {
-            VariableUsage::AssemblyLocalVariable => {
-                return Ok(AssemblyExpression::AssemblyLocalVariable(
-                    id.loc,
-                    v.ty.clone(),
-                    v.pos,
-                ))
+            VariableUsage::YulLocalVariable => {
+                return Ok(YulExpression::YulLocalVariable(id.loc, v.ty.clone(), v.pos))
             }
             VariableUsage::AnonymousReturnVariable => {
                 unreachable!("Anonymous returns variables cannot be accessed from assembly blocks")
             }
             _ => {
-                return Ok(AssemblyExpression::SolidityLocalVariable(
+                return Ok(YulExpression::SolidityLocalVariable(
                     id.loc,
                     v.ty.clone(),
                     v.storage_location.clone(),
@@ -275,14 +261,14 @@ fn resolve_variable_reference(
                 }
 
                 if var.constant {
-                    Ok(AssemblyExpression::ConstantVariable(
+                    Ok(YulExpression::ConstantVariable(
                         id.loc,
                         var.ty.clone(),
                         Some(*var_contract_no),
                         *var_no,
                     ))
                 } else {
-                    Ok(AssemblyExpression::StorageVariable(
+                    Ok(YulExpression::StorageVariable(
                         id.loc,
                         var.ty.clone(),
                         *var_contract_no,
@@ -292,7 +278,7 @@ fn resolve_variable_reference(
             }
             Some(Symbol::Variable(_, None, var_no)) => {
                 let var = &ns.constants[*var_no];
-                Ok(AssemblyExpression::ConstantVariable(
+                Ok(YulExpression::ConstantVariable(
                     id.loc,
                     var.ty.clone(),
                     None,
@@ -326,18 +312,18 @@ fn resolve_variable_reference(
 
 pub(crate) fn resolve_function_call(
     function_table: &mut FunctionsTable,
-    func_call: &AssemblyFunctionCall,
+    func_call: &YulFunctionCall,
     context: &ExprContext,
     symtable: &mut Symtable,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     if func_call.id.name.starts_with("verbatim") {
         ns.diagnostics.push(Diagnostic::error(
             func_call.id.loc,
             "verbatim functions are not yet supported in Solang".to_string(),
         ));
         return Err(());
-    } else if assembly_unsupported_builtin(func_call.id.name.as_str()) {
+    } else if yul_unsupported_builtin(func_call.id.name.as_str()) {
         ns.diagnostics.push(Diagnostic::error(
             func_call.id.loc,
             format!(
@@ -348,11 +334,9 @@ pub(crate) fn resolve_function_call(
         return Err(());
     }
 
-    let mut resolved_arguments: Vec<AssemblyExpression> =
-        Vec::with_capacity(func_call.arguments.len());
+    let mut resolved_arguments: Vec<YulExpression> = Vec::with_capacity(func_call.arguments.len());
     for item in &func_call.arguments {
-        let resolved_expr =
-            resolve_assembly_expression(item, context, symtable, function_table, ns)?;
+        let resolved_expr = resolve_yul_expression(item, context, symtable, function_table, ns)?;
 
         if let Some(diagnostic) = check_type(&resolved_expr, context, ns, symtable) {
             ns.diagnostics.push(diagnostic);
@@ -380,7 +364,7 @@ pub(crate) fn resolve_function_call(
             return Err(());
         }
 
-        let default_builtin_parameter = AssemblyFunctionParameter {
+        let default_builtin_parameter = YulFunctionParameter {
             loc: Loc::Builtin,
             id: Identifier {
                 loc: Loc::Builtin,
@@ -393,7 +377,7 @@ pub(crate) fn resolve_function_call(
             check_function_argument(&default_builtin_parameter, item, function_table, ns);
         }
 
-        return Ok(AssemblyExpression::BuiltInCall(
+        return Ok(YulExpression::BuiltInCall(
             func_call.loc,
             *built_in,
             resolved_arguments,
@@ -419,7 +403,7 @@ pub(crate) fn resolve_function_call(
         }
 
         let fn_no = func.function_no;
-        let resolved_fn = Ok(AssemblyExpression::FunctionCall(
+        let resolved_fn = Ok(YulExpression::FunctionCall(
             func_call.id.loc,
             fn_no,
             resolved_arguments,
@@ -438,8 +422,8 @@ pub(crate) fn resolve_function_call(
 
 /// Check if the provided argument is compatible with the declared parameters of a function.
 fn check_function_argument(
-    parameter: &AssemblyFunctionParameter,
-    argument: &AssemblyExpression,
+    parameter: &YulFunctionParameter,
+    argument: &YulExpression,
     function_table: &FunctionsTable,
     ns: &mut Namespace,
 ) {
@@ -490,13 +474,13 @@ fn check_function_argument(
 /// Resolve variables accessed with suffixes (e.g. 'var.slot', 'var.offset')
 fn resolve_member_access(
     loc: &pt::Loc,
-    expr: &pt::AssemblyExpression,
+    expr: &pt::YulExpression,
     id: &Identifier,
     context: &ExprContext,
     symtable: &mut Symtable,
     function_table: &mut FunctionsTable,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     let suffix_type = match get_suffix_from_string(&id.name[..]) {
         Some(suffix) => suffix,
         None => {
@@ -508,9 +492,9 @@ fn resolve_member_access(
         }
     };
 
-    let resolved_expr = resolve_assembly_expression(expr, context, symtable, function_table, ns)?;
+    let resolved_expr = resolve_yul_expression(expr, context, symtable, function_table, ns)?;
     match resolved_expr {
-        AssemblyExpression::ConstantVariable(_, _, Some(_), _) => {
+        YulExpression::ConstantVariable(_, _, Some(_), _) => {
             ns.diagnostics.push(Diagnostic::error(
                 resolved_expr.loc(),
                 "the suffixes .offset and .slot can only be used in non-constant storage variables"
@@ -519,7 +503,7 @@ fn resolve_member_access(
             return Err(());
         }
 
-        AssemblyExpression::SolidityLocalVariable(
+        YulExpression::SolidityLocalVariable(
             _,
             Type::Array(_, ref dims),
             Some(StorageLocation::Calldata(_)),
@@ -534,9 +518,9 @@ fn resolve_member_access(
             }
         }
 
-        AssemblyExpression::SolidityLocalVariable(_, Type::InternalFunction { .. }, ..)
-        | AssemblyExpression::ConstantVariable(_, Type::InternalFunction { .. }, ..)
-        | AssemblyExpression::StorageVariable(_, Type::InternalFunction { .. }, ..) => {
+        YulExpression::SolidityLocalVariable(_, Type::InternalFunction { .. }, ..)
+        | YulExpression::ConstantVariable(_, Type::InternalFunction { .. }, ..)
+        | YulExpression::StorageVariable(_, Type::InternalFunction { .. }, ..) => {
             ns.diagnostics.push(Diagnostic::error(
                 resolved_expr.loc(),
                 "only variables of type external function pointer support suffixes".to_string(),
@@ -544,9 +528,9 @@ fn resolve_member_access(
             return Err(());
         }
 
-        AssemblyExpression::SolidityLocalVariable(_, Type::ExternalFunction { .. }, ..)
-        | AssemblyExpression::ConstantVariable(_, Type::ExternalFunction { .. }, ..)
-        | AssemblyExpression::StorageVariable(_, Type::ExternalFunction { .. }, ..) => {
+        YulExpression::SolidityLocalVariable(_, Type::ExternalFunction { .. }, ..)
+        | YulExpression::ConstantVariable(_, Type::ExternalFunction { .. }, ..)
+        | YulExpression::StorageVariable(_, Type::ExternalFunction { .. }, ..) => {
             if id.name != "selector" && id.name != "address" {
                 ns.diagnostics.push(Diagnostic::error(
                     id.loc,
@@ -556,8 +540,8 @@ fn resolve_member_access(
             }
         }
 
-        AssemblyExpression::SolidityLocalVariable(_, _, Some(StorageLocation::Storage(_)), _)
-        | AssemblyExpression::StorageVariable(_, _, _, _) => {
+        YulExpression::SolidityLocalVariable(_, _, Some(StorageLocation::Storage(_)), _)
+        | YulExpression::StorageVariable(_, _, _, _) => {
             if id.name != "slot" && id.name != "offset" {
                 ns.diagnostics.push(Diagnostic::error(
                     id.loc,
@@ -567,7 +551,7 @@ fn resolve_member_access(
             }
         }
 
-        AssemblyExpression::MemberAccess(..) => {
+        YulExpression::MemberAccess(..) => {
             ns.diagnostics.push(Diagnostic::error(
                 id.loc,
                 "there cannot be multiple suffixes to a name".to_string(),
@@ -575,13 +559,13 @@ fn resolve_member_access(
             return Err(());
         }
 
-        AssemblyExpression::BoolLiteral(..)
-        | AssemblyExpression::NumberLiteral(..)
-        | AssemblyExpression::StringLiteral(..)
-        | AssemblyExpression::AssemblyLocalVariable(..)
-        | AssemblyExpression::BuiltInCall(..)
-        | AssemblyExpression::FunctionCall(..)
-        | AssemblyExpression::ConstantVariable(_, _, None, _) => {
+        YulExpression::BoolLiteral(..)
+        | YulExpression::NumberLiteral(..)
+        | YulExpression::StringLiteral(..)
+        | YulExpression::YulLocalVariable(..)
+        | YulExpression::BuiltInCall(..)
+        | YulExpression::FunctionCall(..)
+        | YulExpression::ConstantVariable(_, _, None, _) => {
             ns.diagnostics.push(Diagnostic::error(
                 resolved_expr.loc(),
                 "the given expression does not support suffixes".to_string(),
@@ -592,68 +576,63 @@ fn resolve_member_access(
         _ => (),
     }
 
-    Ok(AssemblyExpression::MemberAccess(
+    Ok(YulExpression::MemberAccess(
         *loc,
         Box::new(resolved_expr),
         suffix_type,
     ))
 }
 
-/// Check if an assembly expression has been used correctly in a assignment or if the member access
+/// Check if an yul expression has been used correctly in a assignment or if the member access
 /// has a valid expression given the context.
 pub(crate) fn check_type(
-    expr: &AssemblyExpression,
+    expr: &YulExpression,
     context: &ExprContext,
     ns: &mut Namespace,
     symtable: &mut Symtable,
 ) -> Option<Diagnostic> {
     if context.lvalue {
         match expr {
-            AssemblyExpression::SolidityLocalVariable(
-                _,
-                _,
-                Some(StorageLocation::Storage(_)),
-                ..,
-            )
-            | AssemblyExpression::StorageVariable(..) => {
+            YulExpression::SolidityLocalVariable(_, _, Some(StorageLocation::Storage(_)), ..)
+            | YulExpression::StorageVariable(..) => {
                 return Some(Diagnostic::error(
                     expr.loc(),
                     "storage variables cannot be assigned any value in assembly. You may use ‘sstore()‘".to_string()
                 ));
             }
 
-            AssemblyExpression::StringLiteral(..)
-            | AssemblyExpression::NumberLiteral(..)
-            | AssemblyExpression::BoolLiteral(..)
-            | AssemblyExpression::ConstantVariable(..) => {
+            YulExpression::StringLiteral(..)
+            | YulExpression::NumberLiteral(..)
+            | YulExpression::BoolLiteral(..)
+            | YulExpression::ConstantVariable(..) => {
                 return Some(Diagnostic::error(
                     expr.loc(),
                     "cannot assigned a value to a constant".to_string(),
                 ));
             }
 
-            AssemblyExpression::BuiltInCall(..) | AssemblyExpression::FunctionCall(..) => {
+            YulExpression::BuiltInCall(..) | YulExpression::FunctionCall(..) => {
                 return Some(Diagnostic::error(
                     expr.loc(),
                     "cannot assign a value to a function".to_string(),
                 ));
             }
 
-            AssemblyExpression::MemberAccess(_, _, AssemblySuffix::Length) => {
+            YulExpression::MemberAccess(_, _, YulSuffix::Length) => {
                 return Some(Diagnostic::error(
                     expr.loc(),
                     "cannot assign a value to length".to_string(),
                 ));
             }
 
-            AssemblyExpression::MemberAccess(_, _, AssemblySuffix::Offset) => {
+            YulExpression::MemberAccess(_, _, YulSuffix::Offset) => {
                 return Some(Diagnostic::error(
                     expr.loc(),
                     "cannot assign a value to offset".to_string(),
                 ));
             }
-            AssemblyExpression::MemberAccess(_, exp, AssemblySuffix::Slot) => {
-                if matches!(**exp, AssemblyExpression::StorageVariable(..)) {
+            YulExpression::MemberAccess(_, exp, YulSuffix::Slot) => {
+                if matches!(**exp, YulExpression::StorageVariable(..)) {
                     return Some(Diagnostic::error(
                         exp.loc(),
                         "cannot assign to slot of storage variable".to_string(),
@@ -670,15 +649,15 @@ pub(crate) fn check_type(
     }
 
     match expr {
-        AssemblyExpression::SolidityLocalVariable(_, _, Some(StorageLocation::Storage(_)), ..)
-        | AssemblyExpression::StorageVariable(..) => {
+        YulExpression::SolidityLocalVariable(_, _, Some(StorageLocation::Storage(_)), ..)
+        | YulExpression::StorageVariable(..) => {
             return Some(Diagnostic::error(
                 expr.loc(),
                 "Storage variables must be accessed with ‘.slot‘ or ‘.offset‘".to_string(),
             ));
         }
 
-        AssemblyExpression::SolidityLocalVariable(
+        YulExpression::SolidityLocalVariable(
             _,
             Type::Array(_, ref dims),
             Some(StorageLocation::Calldata(_)),

+ 21 - 26
src/sema/assembly/for_loop.rs → src/sema/yul/for_loop.rs

@@ -1,28 +1,28 @@
 use crate::ast::Namespace;
-use crate::sema::assembly::ast::{AssemblyBlock, AssemblyStatement};
-use crate::sema::assembly::block::{process_statements, resolve_assembly_block};
-use crate::sema::assembly::functions::FunctionsTable;
-use crate::sema::assembly::switch::resolve_condition;
 use crate::sema::expression::ExprContext;
 use crate::sema::symtable::{LoopScopes, Symtable};
+use crate::sema::yul::ast::{YulBlock, YulStatement};
+use crate::sema::yul::block::{process_statements, resolve_yul_block};
+use crate::sema::yul::functions::FunctionsTable;
+use crate::sema::yul::switch::resolve_condition;
 use solang_parser::{pt, Diagnostic};
 
 /// Resolve a for-loop statement
 /// Returns the resolved block and a bool to indicate if the next statement is reachable.
 pub(crate) fn resolve_for_loop(
-    assembly_for: &pt::AssemblyFor,
+    yul_for: &pt::YulFor,
     context: &ExprContext,
     mut reachable: bool,
     loop_scope: &mut LoopScopes,
     symtable: &mut Symtable,
     function_table: &mut FunctionsTable,
     ns: &mut Namespace,
-) -> Result<(AssemblyStatement, bool), ()> {
+) -> Result<(YulStatement, bool), ()> {
     symtable.new_scope();
     function_table.new_scope();
 
     let resolved_init_block = resolve_for_init_block(
-        &assembly_for.init_block,
+        &yul_for.init_block,
         context,
         loop_scope,
         symtable,
@@ -31,19 +31,14 @@ pub(crate) fn resolve_for_loop(
     )?;
     reachable &= resolved_init_block.1;
 
-    let resolved_cond = resolve_condition(
-        &assembly_for.condition,
-        context,
-        symtable,
-        function_table,
-        ns,
-    )?;
+    let resolved_cond =
+        resolve_condition(&yul_for.condition, context, symtable, function_table, ns)?;
 
     loop_scope.new_scope();
 
-    let resolved_exec_block = resolve_assembly_block(
-        &assembly_for.execution_block.loc,
-        &assembly_for.execution_block.statements,
+    let resolved_exec_block = resolve_yul_block(
+        &yul_for.execution_block.loc,
+        &yul_for.execution_block.statements,
         context,
         reachable,
         loop_scope,
@@ -55,9 +50,9 @@ pub(crate) fn resolve_for_loop(
 
     loop_scope.leave_scope();
 
-    let resolved_post_block = resolve_assembly_block(
-        &assembly_for.post_block.loc,
-        &assembly_for.post_block.statements,
+    let resolved_post_block = resolve_yul_block(
+        &yul_for.post_block.loc,
+        &yul_for.post_block.statements,
         context,
         reachable,
         loop_scope,
@@ -70,8 +65,8 @@ pub(crate) fn resolve_for_loop(
     function_table.leave_scope(ns);
 
     Ok((
-        AssemblyStatement::For {
-            loc: assembly_for.loc,
+        YulStatement::For {
+            loc: yul_for.loc,
             init_block: resolved_init_block.0,
             condition: resolved_cond,
             post_block: resolved_post_block.0,
@@ -84,15 +79,15 @@ pub(crate) fn resolve_for_loop(
 /// Resolve for initialization block.
 /// Returns the resolved block and a bool to indicate if the next statement is reachable.
 fn resolve_for_init_block(
-    init_block: &pt::AssemblyBlock,
+    init_block: &pt::YulBlock,
     context: &ExprContext,
     loop_scope: &mut LoopScopes,
     symtable: &mut Symtable,
     function_table: &mut FunctionsTable,
     ns: &mut Namespace,
-) -> Result<(AssemblyBlock, bool), ()> {
+) -> Result<(YulBlock, bool), ()> {
     for item in &init_block.statements {
-        if matches!(item, pt::AssemblyStatement::FunctionDefinition(_)) {
+        if matches!(item, pt::YulStatement::FunctionDefinition(_)) {
             ns.diagnostics.push(Diagnostic::error(
                 item.loc(),
                 "function definitions are not allowed inside for-init block".to_string(),
@@ -112,7 +107,7 @@ fn resolve_for_init_block(
     );
 
     Ok((
-        AssemblyBlock {
+        YulBlock {
             loc: init_block.loc,
             body,
         },

+ 26 - 26
src/sema/assembly/functions.rs → src/sema/yul/functions.rs

@@ -1,12 +1,12 @@
 use crate::ast::{Namespace, Type};
-use crate::sema::assembly::ast::{AssemblyFunction, AssemblyFunctionParameter};
-use crate::sema::assembly::block::process_statements;
-use crate::sema::assembly::builtin::{assembly_unsupported_builtin, parse_builtin_keyword};
-use crate::sema::assembly::types::get_type_from_string;
 use crate::sema::expression::ExprContext;
 use crate::sema::symtable::{LoopScopes, Symtable, VariableInitializer, VariableUsage};
+use crate::sema::yul::ast::{YulFunction, YulFunctionParameter};
+use crate::sema::yul::block::process_statements;
+use crate::sema::yul::builtin::{parse_builtin_keyword, yul_unsupported_builtin};
+use crate::sema::yul::types::get_type_from_string;
 use solang_parser::diagnostics::{ErrorType, Level, Note};
-use solang_parser::pt::AssemblyFunctionDefinition;
+use solang_parser::pt::YulFunctionDefinition;
 use solang_parser::{pt, Diagnostic};
 use std::collections::{HashMap, LinkedList};
 use std::sync::Arc;
@@ -15,8 +15,8 @@ use std::sync::Arc;
 /// resolving the function's body
 pub struct FunctionHeader {
     pub id: pt::Identifier,
-    pub params: Arc<Vec<AssemblyFunctionParameter>>,
-    pub returns: Arc<Vec<AssemblyFunctionParameter>>,
+    pub params: Arc<Vec<YulFunctionParameter>>,
+    pub returns: Arc<Vec<YulFunctionParameter>>,
     pub function_no: usize,
     called: bool,
 }
@@ -26,7 +26,7 @@ pub struct FunctionsTable {
     scopes: LinkedList<HashMap<String, usize>>,
     lookup: Vec<FunctionHeader>,
     counter: usize,
-    pub resolved_functions: Vec<AssemblyFunction>,
+    pub resolved_functions: Vec<YulFunction>,
 }
 
 impl FunctionsTable {
@@ -71,8 +71,8 @@ impl FunctionsTable {
         &self,
         name: &str,
     ) -> (
-        Arc<Vec<AssemblyFunctionParameter>>,
-        Arc<Vec<AssemblyFunctionParameter>>,
+        Arc<Vec<YulFunctionParameter>>,
+        Arc<Vec<YulFunctionParameter>>,
     ) {
         let header = self.find(name).unwrap();
         (header.params.clone(), header.returns.clone())
@@ -85,8 +85,8 @@ impl FunctionsTable {
     pub fn add_function_header(
         &mut self,
         id: &pt::Identifier,
-        params: Vec<AssemblyFunctionParameter>,
-        returns: Vec<AssemblyFunctionParameter>,
+        params: Vec<YulFunctionParameter>,
+        returns: Vec<YulFunctionParameter>,
     ) -> Option<Diagnostic> {
         if let Some(func) = self.find(&id.name) {
             return Some(Diagnostic {
@@ -125,10 +125,10 @@ impl FunctionsTable {
 
 /// Resolve the parameters of a function declaration
 fn process_parameters(
-    parameters: &[pt::AssemblyTypedIdentifier],
+    parameters: &[pt::YulTypedIdentifier],
     ns: &mut Namespace,
-) -> Vec<AssemblyFunctionParameter> {
-    let mut params: Vec<AssemblyFunctionParameter> = Vec::with_capacity(parameters.len());
+) -> Vec<YulFunctionParameter> {
+    let mut params: Vec<YulFunctionParameter> = Vec::with_capacity(parameters.len());
     for item in parameters {
         let ty = match &item.ty {
             Some(identifier) => {
@@ -137,7 +137,7 @@ fn process_parameters(
                 } else {
                     ns.diagnostics.push(Diagnostic::error(
                         identifier.loc,
-                        format!("unrecognized assembly type: {}", identifier.name),
+                        format!("unrecognized yul type: {}", identifier.name),
                     ));
 
                     Type::Uint(256)
@@ -146,7 +146,7 @@ fn process_parameters(
             None => Type::Uint(256),
         };
 
-        params.push(AssemblyFunctionParameter {
+        params.push(YulFunctionParameter {
             loc: item.loc,
             id: item.id.clone(),
             ty,
@@ -158,7 +158,7 @@ fn process_parameters(
 
 /// Resolve the function header of a declaration and add it to the functions table
 pub(crate) fn process_function_header(
-    func_def: &AssemblyFunctionDefinition,
+    func_def: &YulFunctionDefinition,
     functions_table: &mut FunctionsTable,
     ns: &mut Namespace,
 ) {
@@ -175,7 +175,7 @@ pub(crate) fn process_function_header(
         });
         return;
     } else if parse_builtin_keyword(&func_def.id.name).is_some()
-        || assembly_unsupported_builtin(&func_def.id.name)
+        || yul_unsupported_builtin(&func_def.id.name)
     {
         ns.diagnostics.push(Diagnostic::error(
             func_def.loc,
@@ -203,11 +203,11 @@ pub(crate) fn process_function_header(
 
 /// Semantic analysis of function definitions
 pub(crate) fn resolve_function_definition(
-    func_def: &pt::AssemblyFunctionDefinition,
+    func_def: &pt::YulFunctionDefinition,
     functions_table: &mut FunctionsTable,
     context: &ExprContext,
     ns: &mut Namespace,
-) -> Result<AssemblyFunction, ()> {
+) -> Result<YulFunction, ()> {
     let mut symtable = Symtable::new();
     let mut local_ctx = context.clone();
     local_ctx.yul_function = true;
@@ -220,8 +220,8 @@ pub(crate) fn resolve_function_definition(
             &item.id,
             item.ty.clone(),
             ns,
-            VariableInitializer::Assembly(true),
-            VariableUsage::AssemblyLocalVariable,
+            VariableInitializer::Yul(true),
+            VariableUsage::YulLocalVariable,
             None,
         );
     }
@@ -231,8 +231,8 @@ pub(crate) fn resolve_function_definition(
             &item.id,
             item.ty.clone(),
             ns,
-            VariableInitializer::Assembly(false),
-            VariableUsage::AssemblyLocalVariable,
+            VariableInitializer::Yul(false),
+            VariableUsage::YulLocalVariable,
             None,
         );
     }
@@ -250,7 +250,7 @@ pub(crate) fn resolve_function_definition(
     );
 
     functions_table.leave_scope(ns);
-    Ok(AssemblyFunction {
+    Ok(YulFunction {
         loc: func_def.loc,
         name: func_def.id.name.clone(),
         params,

+ 4 - 4
src/sema/assembly/mod.rs → src/sema/yul/mod.rs

@@ -1,9 +1,9 @@
 use crate::ast::Namespace;
-use crate::sema::assembly::ast::InlineAssembly;
-use crate::sema::assembly::block::process_statements;
-use crate::sema::assembly::functions::FunctionsTable;
 use crate::sema::expression::ExprContext;
 use crate::sema::symtable::{LoopScopes, Symtable};
+use crate::sema::yul::ast::InlineAssembly;
+use crate::sema::yul::block::process_statements;
+use crate::sema::yul::functions::FunctionsTable;
 use solang_parser::pt;
 
 pub mod ast;
@@ -22,7 +22,7 @@ mod unused_variable;
 /// Returns the resolved block and a bool to indicate if the next statement is reachable.
 pub fn resolve_inline_assembly(
     loc: &pt::Loc,
-    statements: &[pt::AssemblyStatement],
+    statements: &[pt::YulStatement],
     context: &ExprContext,
     symtable: &mut Symtable,
     ns: &mut Namespace,

+ 59 - 68
src/sema/assembly/statements.rs → src/sema/yul/statements.rs

@@ -1,42 +1,40 @@
 use crate::ast::Namespace;
-use crate::sema::assembly::ast::{AssemblyExpression, AssemblyStatement};
-use crate::sema::assembly::block::resolve_assembly_block;
-use crate::sema::assembly::builtin::{assembly_unsupported_builtin, parse_builtin_keyword};
-use crate::sema::assembly::expression::{
-    check_type, resolve_assembly_expression, resolve_function_call,
-};
-use crate::sema::assembly::for_loop::resolve_for_loop;
-use crate::sema::assembly::functions::FunctionsTable;
-use crate::sema::assembly::switch::{resolve_condition, resolve_switch};
-use crate::sema::assembly::types::get_default_type_from_identifier;
 use crate::sema::expression::ExprContext;
 use crate::sema::symtable::{LoopScopes, Symtable, VariableInitializer, VariableUsage};
+use crate::sema::yul::ast::{YulExpression, YulStatement};
+use crate::sema::yul::block::resolve_yul_block;
+use crate::sema::yul::builtin::{parse_builtin_keyword, yul_unsupported_builtin};
+use crate::sema::yul::expression::{check_type, resolve_function_call, resolve_yul_expression};
+use crate::sema::yul::for_loop::resolve_for_loop;
+use crate::sema::yul::functions::FunctionsTable;
+use crate::sema::yul::switch::{resolve_condition, resolve_switch};
+use crate::sema::yul::types::get_default_type_from_identifier;
 use solang_parser::diagnostics::{ErrorType, Level, Note};
-use solang_parser::pt::AssemblyTypedIdentifier;
+use solang_parser::pt::YulTypedIdentifier;
 use solang_parser::{pt, Diagnostic};
 
-/// Resolves an assembly statement. Returns a boolean that indicates if the next statement is reachable.
-pub(crate) fn resolve_assembly_statement(
-    statement: &pt::AssemblyStatement,
+/// Resolves an yul statement. Returns a boolean that indicates if the next statement is reachable.
+pub(crate) fn resolve_yul_statement(
+    statement: &pt::YulStatement,
     context: &ExprContext,
     reachable: bool,
     loop_scope: &mut LoopScopes,
     symtable: &mut Symtable,
-    resolved_statements: &mut Vec<(AssemblyStatement, bool)>,
+    resolved_statements: &mut Vec<(YulStatement, bool)>,
     function_table: &mut FunctionsTable,
     ns: &mut Namespace,
 ) -> Result<bool, ()> {
     match statement {
-        pt::AssemblyStatement::FunctionDefinition(_) => Ok(true),
-        pt::AssemblyStatement::FunctionCall(func_call) => {
+        pt::YulStatement::FunctionDefinition(_) => Ok(true),
+        pt::YulStatement::FunctionCall(func_call) => {
             let data =
                 resolve_top_level_function_call(func_call, function_table, context, symtable, ns)?;
             resolved_statements.push((data.0, reachable));
             Ok(data.1)
         }
 
-        pt::AssemblyStatement::Block(block) => {
-            let data = resolve_assembly_block(
+        pt::YulStatement::Block(block) => {
+            let data = resolve_yul_block(
                 &block.loc,
                 &block.statements,
                 context,
@@ -46,11 +44,11 @@ pub(crate) fn resolve_assembly_statement(
                 symtable,
                 ns,
             );
-            resolved_statements.push((AssemblyStatement::Block(Box::new(data.0)), reachable));
+            resolved_statements.push((YulStatement::Block(Box::new(data.0)), reachable));
             Ok(data.1)
         }
 
-        pt::AssemblyStatement::VariableDeclaration(loc, variables, initializer) => {
+        pt::YulStatement::VariableDeclaration(loc, variables, initializer) => {
             resolved_statements.push((
                 resolve_variable_declaration(
                     loc,
@@ -66,7 +64,7 @@ pub(crate) fn resolve_assembly_statement(
             Ok(true)
         }
 
-        pt::AssemblyStatement::Assign(loc, lhs, rhs) => {
+        pt::YulStatement::Assign(loc, lhs, rhs) => {
             resolved_statements.push((
                 resolve_assignment(loc, lhs, rhs, context, function_table, symtable, ns)?,
                 reachable,
@@ -74,7 +72,7 @@ pub(crate) fn resolve_assembly_statement(
             Ok(true)
         }
 
-        pt::AssemblyStatement::If(loc, condition, body) => {
+        pt::YulStatement::If(loc, condition, body) => {
             resolved_statements.push((
                 resolve_if_block(
                     loc,
@@ -92,7 +90,7 @@ pub(crate) fn resolve_assembly_statement(
             Ok(true)
         }
 
-        pt::AssemblyStatement::Switch(switch_statement) => {
+        pt::YulStatement::Switch(switch_statement) => {
             let resolved_switch = resolve_switch(
                 switch_statement,
                 context,
@@ -106,9 +104,9 @@ pub(crate) fn resolve_assembly_statement(
             Ok(resolved_switch.1)
         }
 
-        pt::AssemblyStatement::Break(loc) => {
+        pt::YulStatement::Break(loc) => {
             if loop_scope.do_break() {
-                resolved_statements.push((AssemblyStatement::Break(*loc), reachable));
+                resolved_statements.push((YulStatement::Break(*loc), reachable));
                 Ok(false)
             } else {
                 ns.diagnostics.push(Diagnostic::error(
@@ -119,9 +117,9 @@ pub(crate) fn resolve_assembly_statement(
             }
         }
 
-        pt::AssemblyStatement::Continue(loc) => {
+        pt::YulStatement::Continue(loc) => {
             if loop_scope.do_continue() {
-                resolved_statements.push((AssemblyStatement::Continue(*loc), reachable));
+                resolved_statements.push((YulStatement::Continue(*loc), reachable));
                 Ok(false)
             } else {
                 ns.diagnostics.push(Diagnostic::error(
@@ -132,7 +130,7 @@ pub(crate) fn resolve_assembly_statement(
             }
         }
 
-        pt::AssemblyStatement::Leave(loc) => {
+        pt::YulStatement::Leave(loc) => {
             if !context.yul_function {
                 ns.diagnostics.push(Diagnostic::error(
                     *loc,
@@ -140,11 +138,11 @@ pub(crate) fn resolve_assembly_statement(
                 ));
                 return Err(());
             }
-            resolved_statements.push((AssemblyStatement::Leave(*loc), reachable));
+            resolved_statements.push((YulStatement::Leave(*loc), reachable));
             Ok(false)
         }
 
-        pt::AssemblyStatement::For(for_statement) => {
+        pt::YulStatement::For(for_statement) => {
             let resolved_for = resolve_for_loop(
                 for_statement,
                 context,
@@ -162,14 +160,14 @@ pub(crate) fn resolve_assembly_statement(
 
 /// Top-leve function calls must not return anything, so there is a special function to handle them.
 fn resolve_top_level_function_call(
-    func_call: &pt::AssemblyFunctionCall,
+    func_call: &pt::YulFunctionCall,
     function_table: &mut FunctionsTable,
     context: &ExprContext,
     symtable: &mut Symtable,
     ns: &mut Namespace,
-) -> Result<(AssemblyStatement, bool), ()> {
+) -> Result<(YulStatement, bool), ()> {
     match resolve_function_call(function_table, func_call, context, symtable, ns) {
-        Ok(AssemblyExpression::BuiltInCall(loc, ty, args)) => {
+        Ok(YulExpression::BuiltInCall(loc, ty, args)) => {
             let func_prototype = ty.get_prototype_info();
             if func_prototype.no_returns != 0 {
                 ns.diagnostics.push(Diagnostic::error(
@@ -179,11 +177,11 @@ fn resolve_top_level_function_call(
                 return Err(());
             }
             Ok((
-                AssemblyStatement::BuiltInCall(loc, ty, args),
+                YulStatement::BuiltInCall(loc, ty, args),
                 !func_prototype.stops_execution,
             ))
         }
-        Ok(AssemblyExpression::FunctionCall(loc, function_no, args)) => {
+        Ok(YulExpression::FunctionCall(loc, function_no, args)) => {
             let func = function_table.get(function_no).unwrap();
             if !func.returns.is_empty() {
                 ns.diagnostics.push(Diagnostic::error(
@@ -192,14 +190,11 @@ fn resolve_top_level_function_call(
                 ));
                 return Err(());
             }
-            Ok((
-                AssemblyStatement::FunctionCall(loc, function_no, args),
-                true,
-            ))
+            Ok((YulStatement::FunctionCall(loc, function_no, args), true))
         }
 
         Ok(_) => {
-            unreachable!("sema::assembly::resolve_function_call can only return resolved calls")
+            unreachable!("sema::yul::resolve_function_call can only return resolved calls")
         }
 
         Err(_) => Err(()),
@@ -208,13 +203,13 @@ fn resolve_top_level_function_call(
 
 fn resolve_variable_declaration(
     loc: &pt::Loc,
-    variables: &[AssemblyTypedIdentifier],
-    initializer: &Option<pt::AssemblyExpression>,
+    variables: &[YulTypedIdentifier],
+    initializer: &Option<pt::YulExpression>,
     function_table: &mut FunctionsTable,
     context: &ExprContext,
     symtable: &mut Symtable,
     ns: &mut Namespace,
-) -> Result<AssemblyStatement, ()> {
+) -> Result<YulStatement, ()> {
     let mut added_variables: Vec<usize> = Vec::with_capacity(variables.len());
     for item in variables {
         if let Some(func) = function_table.find(&item.id.name) {
@@ -229,7 +224,7 @@ fn resolve_variable_declaration(
                 }],
             });
             return Err(());
-        } else if assembly_unsupported_builtin(&item.id.name)
+        } else if yul_unsupported_builtin(&item.id.name)
             || parse_builtin_keyword(&item.id.name).is_some()
         {
             ns.diagnostics.push(Diagnostic::error(
@@ -254,8 +249,8 @@ fn resolve_variable_declaration(
             &item.id,
             ty,
             ns,
-            VariableInitializer::Assembly(initializer.is_some()),
-            VariableUsage::AssemblyLocalVariable,
+            VariableInitializer::Yul(initializer.is_some()),
+            VariableUsage::YulLocalVariable,
             None,
         ) {
             added_variables.push(pos);
@@ -266,7 +261,7 @@ fn resolve_variable_declaration(
 
     let resolved_init = if let Some(init_expr) = &initializer {
         let resolved_expr =
-            resolve_assembly_expression(init_expr, context, symtable, function_table, ns)?;
+            resolve_yul_expression(init_expr, context, symtable, function_table, ns)?;
         check_assignment_compatibility(
             loc,
             variables,
@@ -281,7 +276,7 @@ fn resolve_variable_declaration(
         None
     };
 
-    Ok(AssemblyStatement::VariableDeclaration(
+    Ok(YulStatement::VariableDeclaration(
         *loc,
         added_variables,
         resolved_init,
@@ -290,18 +285,18 @@ fn resolve_variable_declaration(
 
 fn resolve_assignment(
     loc: &pt::Loc,
-    lhs: &[pt::AssemblyExpression],
-    rhs: &pt::AssemblyExpression,
+    lhs: &[pt::YulExpression],
+    rhs: &pt::YulExpression,
     context: &ExprContext,
     function_table: &mut FunctionsTable,
     symtable: &mut Symtable,
     ns: &mut Namespace,
-) -> Result<AssemblyStatement, ()> {
-    let mut resolved_lhs: Vec<AssemblyExpression> = Vec::with_capacity(lhs.len());
+) -> Result<YulStatement, ()> {
+    let mut resolved_lhs: Vec<YulExpression> = Vec::with_capacity(lhs.len());
     let mut local_ctx = context.clone();
     local_ctx.lvalue = true;
     for item in lhs {
-        let resolved = resolve_assembly_expression(item, &local_ctx, symtable, function_table, ns)?;
+        let resolved = resolve_yul_expression(item, &local_ctx, symtable, function_table, ns)?;
         if let Some(diagnostic) = check_type(&resolved, &local_ctx, ns, symtable) {
             ns.diagnostics.push(diagnostic);
             return Err(());
@@ -310,7 +305,7 @@ fn resolve_assignment(
     }
 
     local_ctx.lvalue = false;
-    let resolved_rhs = resolve_assembly_expression(rhs, &local_ctx, symtable, function_table, ns)?;
+    let resolved_rhs = resolve_yul_expression(rhs, &local_ctx, symtable, function_table, ns)?;
     check_assignment_compatibility(
         loc,
         &resolved_lhs,
@@ -321,25 +316,21 @@ fn resolve_assignment(
         ns,
     );
 
-    Ok(AssemblyStatement::Assignment(
-        *loc,
-        resolved_lhs,
-        resolved_rhs,
-    ))
+    Ok(YulStatement::Assignment(*loc, resolved_lhs, resolved_rhs))
 }
 
 /// Checks the the left hand side of an assignment is compatible with it right hand side
 fn check_assignment_compatibility<T>(
     loc: &pt::Loc,
     lhs: &[T],
-    rhs: &AssemblyExpression,
+    rhs: &YulExpression,
     context: &ExprContext,
     function_table: &FunctionsTable,
     symtable: &mut Symtable,
     ns: &mut Namespace,
 ) {
     match rhs {
-        AssemblyExpression::FunctionCall(_, function_no, ..) => {
+        YulExpression::FunctionCall(_, function_no, ..) => {
             let func = function_table.get(*function_no).unwrap();
             if func.returns.len() != lhs.len() {
                 ns.diagnostics.push(Diagnostic::error(
@@ -353,7 +344,7 @@ fn check_assignment_compatibility<T>(
             }
         }
 
-        AssemblyExpression::BuiltInCall(_, ty, _) => {
+        YulExpression::BuiltInCall(_, ty, _) => {
             let prototype = ty.get_prototype_info();
             if prototype.no_returns as usize != lhs.len() {
                 ns.diagnostics.push(Diagnostic::error(
@@ -382,18 +373,18 @@ fn check_assignment_compatibility<T>(
 
 fn resolve_if_block(
     loc: &pt::Loc,
-    condition: &pt::AssemblyExpression,
-    if_block: &[pt::AssemblyStatement],
+    condition: &pt::YulExpression,
+    if_block: &[pt::YulStatement],
     context: &ExprContext,
     reachable: bool,
     loop_scope: &mut LoopScopes,
     function_table: &mut FunctionsTable,
     symtable: &mut Symtable,
     ns: &mut Namespace,
-) -> Result<AssemblyStatement, ()> {
+) -> Result<YulStatement, ()> {
     let resolved_condition = resolve_condition(condition, context, symtable, function_table, ns)?;
 
-    let resolved_block = resolve_assembly_block(
+    let resolved_block = resolve_yul_block(
         loc,
         if_block,
         context,
@@ -404,7 +395,7 @@ fn resolve_if_block(
         ns,
     );
 
-    Ok(AssemblyStatement::IfBlock(
+    Ok(YulStatement::IfBlock(
         *loc,
         resolved_condition,
         Box::new(resolved_block.0),

+ 34 - 39
src/sema/assembly/switch.rs → src/sema/yul/switch.rs

@@ -1,35 +1,30 @@
 use crate::ast::Namespace;
-use crate::sema::assembly::ast::{AssemblyBlock, AssemblyExpression, AssemblyStatement, CaseBlock};
-use crate::sema::assembly::block::resolve_assembly_block;
-use crate::sema::assembly::expression::{check_type, resolve_assembly_expression};
-use crate::sema::assembly::functions::FunctionsTable;
-use crate::sema::assembly::types::verify_type_from_expression;
 use crate::sema::expression::ExprContext;
 use crate::sema::symtable::{LoopScopes, Symtable};
-use solang_parser::pt::{AssemblySwitchOptions, CodeLocation};
+use crate::sema::yul::ast::{CaseBlock, YulBlock, YulExpression, YulStatement};
+use crate::sema::yul::block::resolve_yul_block;
+use crate::sema::yul::expression::{check_type, resolve_yul_expression};
+use crate::sema::yul::functions::FunctionsTable;
+use crate::sema::yul::types::verify_type_from_expression;
+use solang_parser::pt::{CodeLocation, YulSwitchOptions};
 use solang_parser::{pt, Diagnostic};
 
 /// Resolve switch statement
 /// Returns the resolved block and a bool to indicate if the next statement is reachable.
 pub(crate) fn resolve_switch(
-    assembly_switch: &pt::AssemblySwitch,
+    yul_switch: &pt::YulSwitch,
     context: &ExprContext,
     mut reachable: bool,
     function_table: &mut FunctionsTable,
     loop_scope: &mut LoopScopes,
     symtable: &mut Symtable,
     ns: &mut Namespace,
-) -> Result<(AssemblyStatement, bool), ()> {
-    let resolved_condition = resolve_condition(
-        &assembly_switch.condition,
-        context,
-        symtable,
-        function_table,
-        ns,
-    )?;
-    let mut default_block: Option<AssemblyBlock> = None;
-    let mut case_blocks: Vec<CaseBlock> = Vec::with_capacity(assembly_switch.cases.len());
-    for item in &assembly_switch.cases {
+) -> Result<(YulStatement, bool), ()> {
+    let resolved_condition =
+        resolve_condition(&yul_switch.condition, context, symtable, function_table, ns)?;
+    let mut default_block: Option<YulBlock> = None;
+    let mut case_blocks: Vec<CaseBlock> = Vec::with_capacity(yul_switch.cases.len());
+    for item in &yul_switch.cases {
         let block_reachable = resolve_case_or_default(
             item,
             &mut default_block,
@@ -44,13 +39,13 @@ pub(crate) fn resolve_switch(
         reachable |= block_reachable;
     }
 
-    if assembly_switch.default.is_some() && default_block.is_some() {
+    if yul_switch.default.is_some() && default_block.is_some() {
         ns.diagnostics.push(Diagnostic::error(
-            assembly_switch.default.as_ref().unwrap().loc(),
+            yul_switch.default.as_ref().unwrap().loc(),
             "Only one default block is allowed".to_string(),
         ));
         return Err(());
-    } else if let Some(default_unwrapped) = &assembly_switch.default {
+    } else if let Some(default_unwrapped) = &yul_switch.default {
         let block_reachable = resolve_case_or_default(
             default_unwrapped,
             &mut default_block,
@@ -63,13 +58,13 @@ pub(crate) fn resolve_switch(
             ns,
         )?;
         reachable |= block_reachable;
-    } else if assembly_switch.default.is_none() && default_block.is_none() {
+    } else if yul_switch.default.is_none() && default_block.is_none() {
         reachable |= true;
     }
 
     Ok((
-        AssemblyStatement::Switch {
-            loc: assembly_switch.loc,
+        YulStatement::Switch {
+            loc: yul_switch.loc,
             condition: resolved_condition,
             cases: case_blocks,
             default: default_block,
@@ -80,14 +75,14 @@ pub(crate) fn resolve_switch(
 
 /// Resolves condition statements for either if-statement and switch-statements
 pub(crate) fn resolve_condition(
-    condition: &pt::AssemblyExpression,
+    condition: &pt::YulExpression,
     context: &ExprContext,
     symtable: &mut Symtable,
     function_table: &mut FunctionsTable,
     ns: &mut Namespace,
-) -> Result<AssemblyExpression, ()> {
+) -> Result<YulExpression, ()> {
     let resolved_condition =
-        resolve_assembly_expression(condition, context, symtable, function_table, ns)?;
+        resolve_yul_expression(condition, context, symtable, function_table, ns)?;
     if let Err(diagnostic) = verify_type_from_expression(&resolved_condition, function_table) {
         ns.diagnostics.push(diagnostic);
         return Err(());
@@ -101,8 +96,8 @@ pub(crate) fn resolve_condition(
 
 /// Resolve case or default from a switch statements
 fn resolve_case_or_default(
-    switch_case: &pt::AssemblySwitchOptions,
-    default_block: &mut Option<AssemblyBlock>,
+    switch_case: &pt::YulSwitchOptions,
+    default_block: &mut Option<YulBlock>,
     case_blocks: &mut Vec<CaseBlock>,
     context: &ExprContext,
     reachable: bool,
@@ -112,7 +107,7 @@ fn resolve_case_or_default(
     ns: &mut Namespace,
 ) -> Result<bool, ()> {
     match switch_case {
-        AssemblySwitchOptions::Case(loc, expr, block) => {
+        YulSwitchOptions::Case(loc, expr, block) => {
             let resolved_case = resolve_case_block(
                 loc,
                 default_block.is_some(),
@@ -129,8 +124,8 @@ fn resolve_case_or_default(
             Ok(resolved_case.1)
         }
 
-        AssemblySwitchOptions::Default(loc, block) => {
-            let resolved_default = resolve_assembly_block(
+        YulSwitchOptions::Default(loc, block) => {
+            let resolved_default = resolve_yul_block(
                 loc,
                 &block.statements,
                 context,
@@ -150,8 +145,8 @@ fn resolve_case_or_default(
 fn resolve_case_block(
     loc: &pt::Loc,
     has_default: bool,
-    condition: &pt::AssemblyExpression,
-    block: &[pt::AssemblyStatement],
+    condition: &pt::YulExpression,
+    block: &[pt::YulStatement],
     context: &ExprContext,
     reachable: bool,
     function_table: &mut FunctionsTable,
@@ -167,11 +162,11 @@ fn resolve_case_block(
         return Err(());
     }
     let resolved_condition =
-        resolve_assembly_expression(condition, context, symtable, function_table, ns)?;
+        resolve_yul_expression(condition, context, symtable, function_table, ns)?;
     match resolved_condition {
-        AssemblyExpression::NumberLiteral(..)
-        | AssemblyExpression::StringLiteral(..)
-        | AssemblyExpression::BoolLiteral(..) => (),
+        YulExpression::NumberLiteral(..)
+        | YulExpression::StringLiteral(..)
+        | YulExpression::BoolLiteral(..) => (),
 
         _ => {
             ns.diagnostics.push(Diagnostic::error(
@@ -182,7 +177,7 @@ fn resolve_case_block(
         }
     }
 
-    let case_block = resolve_assembly_block(
+    let case_block = resolve_yul_block(
         loc,
         block,
         context,

+ 7 - 7
src/sema/assembly/tests/block.rs → src/sema/yul/tests/block.rs

@@ -1,4 +1,4 @@
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 
 #[test]
 fn unreachable_leave() {
@@ -22,7 +22,7 @@ fn unreachable_leave() {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
 
     let file = r#"
@@ -83,7 +83,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
 
     let file = r#"
@@ -141,7 +141,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
 
     let file = r#"
@@ -211,7 +211,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
 
     let file = r#"
@@ -328,10 +328,10 @@ contract testTypes {
     ));
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "assembly variable ‘x‘ has never been read"
+        "yul variable ‘x‘ has never been read"
     ));
 }

+ 125 - 166
src/sema/assembly/tests/expression.rs → src/sema/yul/tests/expression.rs

@@ -1,20 +1,20 @@
 #![cfg(test)]
 
 use crate::ast::{Namespace, Symbol, Type, Variable};
-use crate::sema::assembly::ast::{AssemblyExpression, AssemblyFunctionParameter, AssemblySuffix};
-use crate::sema::assembly::builtin::AssemblyBuiltInFunction;
-use crate::sema::assembly::expression::{check_type, resolve_assembly_expression};
-use crate::sema::assembly::functions::FunctionsTable;
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
 use crate::sema::expression::ExprContext;
 use crate::sema::symtable::{Symtable, VariableInitializer, VariableUsage};
+use crate::sema::yul::ast::{YulExpression, YulFunctionParameter, YulSuffix};
+use crate::sema::yul::builtin::YulBuiltInFunction;
+use crate::sema::yul::expression::{check_type, resolve_yul_expression};
+use crate::sema::yul::functions::FunctionsTable;
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 use crate::{ast, Target};
 use num_bigint::BigInt;
 use num_traits::FromPrimitive;
 use solang_parser::pt;
 use solang_parser::pt::{
-    AssemblyFunctionCall, ContractTy, HexLiteral, Identifier, Loc, StorageLocation, StringLiteral,
-    Visibility,
+    ContractTy, HexLiteral, Identifier, Loc, StorageLocation, StringLiteral, Visibility,
+    YulFunctionCall,
 };
 
 #[test]
@@ -32,7 +32,7 @@ fn resolve_bool_literal() {
     let mut function_table = FunctionsTable::new();
 
     let mut ns = Namespace::new(Target::Solana);
-    let expr = pt::AssemblyExpression::BoolLiteral(
+    let expr = pt::YulExpression::BoolLiteral(
         Loc::File(0, 3, 5),
         false,
         Some(pt::Identifier {
@@ -42,26 +42,26 @@ fn resolve_bool_literal() {
     );
 
     let resolved_type =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+        resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(resolved_type.is_ok());
     assert!(ns.diagnostics.is_empty());
     let unwrapped = resolved_type.unwrap();
 
     assert_eq!(
         unwrapped,
-        AssemblyExpression::BoolLiteral(Loc::File(0, 3, 5), false, Type::Uint(32))
+        YulExpression::BoolLiteral(Loc::File(0, 3, 5), false, Type::Uint(32))
     );
 
-    let expr = pt::AssemblyExpression::BoolLiteral(Loc::File(0, 3, 5), true, None);
+    let expr = pt::YulExpression::BoolLiteral(Loc::File(0, 3, 5), true, None);
     let resolved_type =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+        resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
 
     assert!(resolved_type.is_ok());
     assert!(ns.diagnostics.is_empty());
     let unwrapped = resolved_type.unwrap();
     assert_eq!(
         unwrapped,
-        AssemblyExpression::BoolLiteral(Loc::File(0, 3, 5), true, Type::Bool)
+        YulExpression::BoolLiteral(Loc::File(0, 3, 5), true, Type::Bool)
     );
 }
 
@@ -81,7 +81,7 @@ fn resolve_number_literal() {
 
     let loc = Loc::File(0, 3, 5);
     let mut ns = Namespace::new(Target::Solana);
-    let expr = pt::AssemblyExpression::NumberLiteral(
+    let expr = pt::YulExpression::NumberLiteral(
         loc,
         BigInt::from_u128(0xffffffffffffffffff).unwrap(),
         Some(Identifier {
@@ -89,8 +89,7 @@ fn resolve_number_literal() {
             name: "u64".to_string(),
         }),
     );
-    let parsed =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let parsed = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(parsed.is_ok());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -99,7 +98,7 @@ fn resolve_number_literal() {
     );
 
     ns.diagnostics.clear();
-    let expr = pt::AssemblyExpression::NumberLiteral(
+    let expr = pt::YulExpression::NumberLiteral(
         loc,
         BigInt::from_i32(-50).unwrap(),
         Some(Identifier {
@@ -107,8 +106,7 @@ fn resolve_number_literal() {
             name: "u128".to_string(),
         }),
     );
-    let parsed =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let parsed = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(parsed.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -117,14 +115,13 @@ fn resolve_number_literal() {
     );
 
     ns.diagnostics.clear();
-    let expr = pt::AssemblyExpression::NumberLiteral(loc, BigInt::from(20), None);
-    let parsed =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let expr = pt::YulExpression::NumberLiteral(loc, BigInt::from(20), None);
+    let parsed = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(parsed.is_ok());
     assert!(ns.diagnostics.is_empty());
     assert_eq!(
         parsed.unwrap(),
-        AssemblyExpression::NumberLiteral(loc, BigInt::from(20), Type::Uint(256))
+        YulExpression::NumberLiteral(loc, BigInt::from(20), Type::Uint(256))
     );
 }
 
@@ -144,7 +141,7 @@ fn resolve_hex_number_literal() {
 
     let mut ns = Namespace::new(Target::Ewasm);
     let loc = Loc::File(0, 3, 5);
-    let expr = pt::AssemblyExpression::HexNumberLiteral(
+    let expr = pt::YulExpression::HexNumberLiteral(
         loc,
         "0xf23456789a".to_string(),
         Some(Identifier {
@@ -153,8 +150,7 @@ fn resolve_hex_number_literal() {
         }),
     );
 
-    let resolved =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let resolved = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(resolved.is_ok());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -163,7 +159,7 @@ fn resolve_hex_number_literal() {
     );
 
     ns.diagnostics.clear();
-    let expr = pt::AssemblyExpression::HexNumberLiteral(
+    let expr = pt::YulExpression::HexNumberLiteral(
         loc,
         "0xff".to_string(),
         Some(Identifier {
@@ -171,13 +167,12 @@ fn resolve_hex_number_literal() {
             name: "s64".to_string(),
         }),
     );
-    let resolved =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let resolved = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(resolved.is_ok());
     assert!(ns.diagnostics.is_empty());
     assert_eq!(
         resolved.unwrap(),
-        AssemblyExpression::NumberLiteral(loc, BigInt::from(255), Type::Int(64))
+        YulExpression::NumberLiteral(loc, BigInt::from(255), Type::Int(64))
     );
 }
 
@@ -197,7 +192,7 @@ fn resolve_hex_string_literal() {
 
     let mut ns = Namespace::new(Target::Ewasm);
     let loc = Loc::File(0, 3, 5);
-    let expr = pt::AssemblyExpression::HexStringLiteral(
+    let expr = pt::YulExpression::HexStringLiteral(
         HexLiteral {
             loc,
             hex: "3ca".to_string(),
@@ -205,8 +200,7 @@ fn resolve_hex_string_literal() {
         None,
     );
 
-    let resolved =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let resolved = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(resolved.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -215,7 +209,7 @@ fn resolve_hex_string_literal() {
     );
 
     ns.diagnostics.clear();
-    let expr = pt::AssemblyExpression::HexStringLiteral(
+    let expr = pt::YulExpression::HexStringLiteral(
         HexLiteral {
             loc,
             hex: "acdf".to_string(),
@@ -225,8 +219,7 @@ fn resolve_hex_string_literal() {
             name: "myType".to_string(),
         }),
     );
-    let resolved =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let resolved = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(resolved.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -235,7 +228,7 @@ fn resolve_hex_string_literal() {
     );
 
     ns.diagnostics.clear();
-    let expr = pt::AssemblyExpression::HexStringLiteral(
+    let expr = pt::YulExpression::HexStringLiteral(
         HexLiteral {
             loc,
             hex: "ffff".to_string(),
@@ -245,13 +238,12 @@ fn resolve_hex_string_literal() {
             name: "u256".to_string(),
         }),
     );
-    let resolved =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let resolved = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(resolved.is_ok());
     assert!(ns.diagnostics.is_empty());
     assert_eq!(
         resolved.unwrap(),
-        AssemblyExpression::StringLiteral(loc, vec![255, 255], Type::Uint(256))
+        YulExpression::StringLiteral(loc, vec![255, 255], Type::Uint(256))
     );
 }
 
@@ -271,7 +263,7 @@ fn resolve_string_literal() {
 
     let mut ns = Namespace::new(Target::Solana);
     let loc = Loc::File(0, 3, 5);
-    let expr = pt::AssemblyExpression::StringLiteral(
+    let expr = pt::YulExpression::StringLiteral(
         StringLiteral {
             loc,
             string: r#"ab\xffa\u00e0g"#.to_string(),
@@ -282,17 +274,12 @@ fn resolve_string_literal() {
         }),
     );
 
-    let resolved =
-        resolve_assembly_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
+    let resolved = resolve_yul_expression(&expr, &ctx, &mut symtable, &mut function_table, &mut ns);
     assert!(resolved.is_ok());
     assert!(ns.diagnostics.is_empty());
     assert_eq!(
         resolved.unwrap(),
-        AssemblyExpression::StringLiteral(
-            loc,
-            vec![97, 98, 255, 97, 0xc3, 0xa0, 103],
-            Type::Uint(128)
-        )
+        YulExpression::StringLiteral(loc, vec![97, 98, 255, 97, 0xc3, 0xa0, 103], Type::Uint(128))
     );
 }
 
@@ -320,8 +307,8 @@ fn resolve_variable_local() {
             },
             Type::Uint(32),
             &mut ns,
-            VariableInitializer::Assembly(false),
-            VariableUsage::AssemblyLocalVariable,
+            VariableInitializer::Yul(false),
+            VariableUsage::YulLocalVariable,
             None,
         )
         .unwrap();
@@ -333,32 +320,32 @@ fn resolve_variable_local() {
             },
             Type::Uint(32),
             &mut ns,
-            VariableInitializer::Assembly(false),
+            VariableInitializer::Yul(false),
             VariableUsage::LocalVariable,
             None,
         )
         .unwrap();
 
-    let expr1 = pt::AssemblyExpression::Variable(Identifier {
+    let expr1 = pt::YulExpression::Variable(Identifier {
         loc,
         name: "var1".to_string(),
     });
-    let expr2 = pt::AssemblyExpression::Variable(Identifier {
+    let expr2 = pt::YulExpression::Variable(Identifier {
         loc,
         name: "var2".to_string(),
     });
 
-    let expected_1 = AssemblyExpression::AssemblyLocalVariable(loc, Type::Uint(32), pos1);
-    let expected_2 = AssemblyExpression::SolidityLocalVariable(loc, Type::Uint(32), None, pos2);
+    let expected_1 = YulExpression::YulLocalVariable(loc, Type::Uint(32), pos1);
+    let expected_2 = YulExpression::SolidityLocalVariable(loc, Type::Uint(32), None, pos2);
 
-    let res1 = resolve_assembly_expression(
+    let res1 = resolve_yul_expression(
         &expr1,
         &context,
         &mut symtable,
         &mut function_table,
         &mut ns,
     );
-    let res2 = resolve_assembly_expression(
+    let res2 = resolve_yul_expression(
         &expr2,
         &context,
         &mut symtable,
@@ -462,48 +449,44 @@ fn resolve_variable_contract() {
     ns.variable_symbols
         .insert((0, Some(0), "func".to_string()), Symbol::Function(vec![]));
 
-    let expr = pt::AssemblyExpression::Variable(Identifier {
+    let expr = pt::YulExpression::Variable(Identifier {
         loc,
         name: "var1".to_string(),
     });
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_ok());
     assert_eq!(
-        AssemblyExpression::ConstantVariable(loc, Type::Bool, Some(0), 0),
+        YulExpression::ConstantVariable(loc, Type::Bool, Some(0), 0),
         res.unwrap()
     );
 
-    let expr = pt::AssemblyExpression::Variable(Identifier {
+    let expr = pt::YulExpression::Variable(Identifier {
         loc,
         name: "var2".to_string(),
     });
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_ok());
     assert_eq!(
-        AssemblyExpression::StorageVariable(loc, Type::Int(128), 0, 1),
+        YulExpression::StorageVariable(loc, Type::Int(128), 0, 1),
         res.unwrap()
     );
 
-    let expr = pt::AssemblyExpression::Variable(Identifier {
+    let expr = pt::YulExpression::Variable(Identifier {
         loc,
         name: "var3".to_string(),
     });
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_ok());
     assert_eq!(
-        AssemblyExpression::ConstantVariable(loc, Type::Uint(32), None, 0),
+        YulExpression::ConstantVariable(loc, Type::Uint(32), None, 0),
         res.unwrap()
     );
 
-    let expr = pt::AssemblyExpression::Variable(Identifier {
+    let expr = pt::YulExpression::Variable(Identifier {
         loc,
         name: "func".to_string(),
     });
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -512,23 +495,21 @@ fn resolve_variable_contract() {
     );
 
     ns.diagnostics.clear();
-    let expr = pt::AssemblyExpression::Variable(Identifier {
+    let expr = pt::YulExpression::Variable(Identifier {
         loc,
         name: "none".to_string(),
     });
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(ns.diagnostics[0].message, "'none' is not found");
 
     ns.diagnostics.clear();
-    let expr = pt::AssemblyExpression::Variable(Identifier {
+    let expr = pt::YulExpression::Variable(Identifier {
         loc,
         name: "imut".to_string(),
     });
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -554,7 +535,7 @@ fn function_call() {
     let mut ns = Namespace::new(Target::Ewasm);
     let loc = Loc::File(0, 2, 3);
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
@@ -562,8 +543,7 @@ fn function_call() {
         },
         arguments: vec![],
     }));
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -572,7 +552,7 @@ fn function_call() {
     );
     ns.diagnostics.clear();
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
@@ -580,8 +560,7 @@ fn function_call() {
         },
         arguments: vec![],
     }));
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -590,7 +569,7 @@ fn function_call() {
     );
     ns.diagnostics.clear();
 
-    let arg = pt::AssemblyExpression::BoolLiteral(
+    let arg = pt::YulExpression::BoolLiteral(
         Loc::File(0, 3, 5),
         false,
         Some(pt::Identifier {
@@ -599,7 +578,7 @@ fn function_call() {
         }),
     );
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
@@ -607,8 +586,7 @@ fn function_call() {
         },
         arguments: vec![arg.clone()],
     }));
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -617,7 +595,7 @@ fn function_call() {
     );
     ns.diagnostics.clear();
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
@@ -625,14 +603,13 @@ fn function_call() {
         },
         arguments: vec![arg.clone()],
     }));
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_ok());
     assert_eq!(
-        AssemblyExpression::BuiltInCall(
+        YulExpression::BuiltInCall(
             loc,
-            AssemblyBuiltInFunction::Not,
-            vec![resolve_assembly_expression(
+            YulBuiltInFunction::Not,
+            vec![resolve_yul_expression(
                 &arg,
                 &context,
                 &mut symtable,
@@ -653,7 +630,7 @@ fn function_call() {
         vec![],
     );
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
@@ -661,8 +638,7 @@ fn function_call() {
         },
         arguments: vec![arg.clone()],
     }));
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -671,7 +647,7 @@ fn function_call() {
     );
     ns.diagnostics.clear();
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
@@ -679,15 +655,11 @@ fn function_call() {
         },
         arguments: vec![],
     }));
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_ok());
-    assert_eq!(
-        AssemblyExpression::FunctionCall(loc, 0, vec![]),
-        res.unwrap()
-    );
+    assert_eq!(YulExpression::FunctionCall(loc, 0, vec![]), res.unwrap());
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
@@ -695,8 +667,7 @@ fn function_call() {
         },
         arguments: vec![],
     }));
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(ns.diagnostics[0].message, "function 'none' is not defined");
@@ -735,7 +706,7 @@ fn check_arguments() {
         },
         vec![],
         vec![
-            AssemblyFunctionParameter {
+            YulFunctionParameter {
                 loc,
                 id: Identifier {
                     loc,
@@ -743,7 +714,7 @@ fn check_arguments() {
                 },
                 ty: Type::Uint(256),
             },
-            AssemblyFunctionParameter {
+            YulFunctionParameter {
                 loc,
                 id: Identifier {
                     loc,
@@ -754,30 +725,27 @@ fn check_arguments() {
         ],
     );
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
             name: "not".to_string(),
         },
-        arguments: vec![pt::AssemblyExpression::FunctionCall(Box::new(
-            AssemblyFunctionCall {
+        arguments: vec![pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
+            loc,
+            id: Identifier {
                 loc,
-                id: Identifier {
-                    loc,
-                    name: "pop".to_string(),
-                },
-                arguments: vec![pt::AssemblyExpression::NumberLiteral(
-                    loc,
-                    BigInt::from(23),
-                    None,
-                )],
+                name: "pop".to_string(),
             },
-        ))],
+            arguments: vec![pt::YulExpression::NumberLiteral(
+                loc,
+                BigInt::from(23),
+                None,
+            )],
+        }))],
     }));
 
-    let _ =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let _ = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(!ns.diagnostics.is_empty());
     assert_eq!(
         ns.diagnostics[0].message,
@@ -785,26 +753,23 @@ fn check_arguments() {
     );
     ns.diagnostics.clear();
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
             name: "not".to_string(),
         },
-        arguments: vec![pt::AssemblyExpression::FunctionCall(Box::new(
-            AssemblyFunctionCall {
+        arguments: vec![pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
+            loc,
+            id: Identifier {
                 loc,
-                id: Identifier {
-                    loc,
-                    name: "func1".to_string(),
-                },
-                arguments: vec![],
+                name: "func1".to_string(),
             },
-        ))],
+            arguments: vec![],
+        }))],
     }));
 
-    let _ =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let _ = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(!ns.diagnostics.is_empty());
     assert_eq!(
         ns.diagnostics[0].message,
@@ -812,26 +777,23 @@ fn check_arguments() {
     );
     ns.diagnostics.clear();
 
-    let expr = pt::AssemblyExpression::FunctionCall(Box::new(AssemblyFunctionCall {
+    let expr = pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
         loc,
         id: Identifier {
             loc,
             name: "not".to_string(),
         },
-        arguments: vec![pt::AssemblyExpression::FunctionCall(Box::new(
-            AssemblyFunctionCall {
+        arguments: vec![pt::YulExpression::FunctionCall(Box::new(YulFunctionCall {
+            loc,
+            id: Identifier {
                 loc,
-                id: Identifier {
-                    loc,
-                    name: "func2".to_string(),
-                },
-                arguments: vec![],
+                name: "func2".to_string(),
             },
-        ))],
+            arguments: vec![],
+        }))],
     }));
 
-    let _ =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let _ = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(!ns.diagnostics.is_empty());
     assert_eq!(
         ns.diagnostics[0].message,
@@ -876,17 +838,16 @@ fn test_member_access() {
         Symbol::Variable(loc, Some(0), 0),
     );
 
-    let expr = pt::AssemblyExpression::Member(
+    let expr = pt::YulExpression::Member(
         loc,
-        Box::new(pt::AssemblyExpression::BoolLiteral(loc, true, None)),
+        Box::new(pt::YulExpression::BoolLiteral(loc, true, None)),
         Identifier {
             loc,
             name: "pineapple".to_string(),
         },
     );
 
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -895,17 +856,16 @@ fn test_member_access() {
     );
     ns.diagnostics.clear();
 
-    let expr = pt::AssemblyExpression::Member(
+    let expr = pt::YulExpression::Member(
         loc,
-        Box::new(pt::AssemblyExpression::BoolLiteral(loc, true, None)),
+        Box::new(pt::YulExpression::BoolLiteral(loc, true, None)),
         Identifier {
             loc,
             name: "slot".to_string(),
         },
     );
 
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_err());
     assert_eq!(ns.diagnostics.len(), 1);
     assert_eq!(
@@ -914,9 +874,9 @@ fn test_member_access() {
     );
     ns.diagnostics.clear();
 
-    let expr = pt::AssemblyExpression::Member(
+    let expr = pt::YulExpression::Member(
         loc,
-        Box::new(pt::AssemblyExpression::Variable(Identifier {
+        Box::new(pt::YulExpression::Variable(Identifier {
             loc,
             name: "var1".to_string(),
         })),
@@ -926,15 +886,14 @@ fn test_member_access() {
         },
     );
 
-    let res =
-        resolve_assembly_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
+    let res = resolve_yul_expression(&expr, &context, &mut symtable, &mut function_table, &mut ns);
     assert!(res.is_ok());
     assert!(ns.diagnostics.is_empty());
     assert_eq!(
-        AssemblyExpression::MemberAccess(
+        YulExpression::MemberAccess(
             loc,
-            Box::new(AssemblyExpression::StorageVariable(loc, Type::Bool, 0, 0)),
-            AssemblySuffix::Slot
+            Box::new(YulExpression::StorageVariable(loc, Type::Bool, 0, 0)),
+            YulSuffix::Slot
         ),
         res.unwrap()
     );
@@ -943,7 +902,7 @@ fn test_member_access() {
 #[test]
 fn test_check_types() {
     let loc = Loc::File(0, 0, 0);
-    let expr = AssemblyExpression::SolidityLocalVariable(
+    let expr = YulExpression::SolidityLocalVariable(
         loc,
         Type::Uint(32),
         Some(StorageLocation::Storage(loc)),
@@ -984,7 +943,7 @@ fn test_check_types() {
         Type::Uint(32),
         &mut ns,
         VariableInitializer::Solidity(None),
-        VariableUsage::AssemblyLocalVariable,
+        VariableUsage::YulLocalVariable,
         None,
     );
     let res = check_type(&expr, &context, &mut ns, &mut symtable);
@@ -994,7 +953,7 @@ fn test_check_types() {
         "Storage variables must be accessed with ‘.slot‘ or ‘.offset‘"
     );
 
-    let expr = AssemblyExpression::StorageVariable(loc, Type::Int(16), 0, 0);
+    let expr = YulExpression::StorageVariable(loc, Type::Int(16), 0, 0);
     let res = check_type(&expr, &context, &mut ns, &mut symtable);
     assert!(res.is_some());
     assert_eq!(
@@ -1002,7 +961,7 @@ fn test_check_types() {
         "Storage variables must be accessed with ‘.slot‘ or ‘.offset‘"
     );
 
-    let expr = AssemblyExpression::SolidityLocalVariable(
+    let expr = YulExpression::SolidityLocalVariable(
         loc,
         Type::Array(Box::new(Type::Int(8)), vec![None]),
         Some(StorageLocation::Calldata(loc)),
@@ -1012,7 +971,7 @@ fn test_check_types() {
     assert!(res.is_some());
     assert_eq!(res.unwrap().message, "Calldata arrays must be accessed with ‘.offset‘, ‘.length‘ and the ‘calldatacopy‘ function");
 
-    let expr = AssemblyExpression::StringLiteral(loc, vec![0, 255, 20], Type::Uint(256));
+    let expr = YulExpression::StringLiteral(loc, vec![0, 255, 20], Type::Uint(256));
     let res = check_type(&expr, &context, &mut ns, &mut symtable);
     assert!(res.is_none());
 }

+ 5 - 5
src/sema/assembly/tests/for_loop.rs → src/sema/yul/tests/for_loop.rs

@@ -1,6 +1,6 @@
 #![cfg(test)]
 
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 
 #[test]
 fn function_inside_init() {
@@ -62,7 +62,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
 
     let file = r#"
@@ -89,7 +89,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
 
     let file = r#"
@@ -116,7 +116,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "unreachable assembly statement"
+        "unreachable yul statement"
     ));
 
     let file = r#"
@@ -152,6 +152,6 @@ contract testTypes {
     ));
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "assembly variable ‘x‘ has never been read"
+        "yul variable ‘x‘ has never been read"
     ));
 }

+ 1 - 1
src/sema/assembly/tests/functions.rs → src/sema/yul/tests/functions.rs

@@ -1,4 +1,4 @@
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 
 #[test]
 fn repeated_names() {

+ 0 - 0
src/sema/assembly/tests/mod.rs → src/sema/yul/tests/mod.rs


+ 1 - 1
src/sema/assembly/tests/statements.rs → src/sema/yul/tests/statements.rs

@@ -1,6 +1,6 @@
 #![cfg(test)]
 
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 
 #[test]
 fn variables_assignment_mismatch() {

+ 1 - 1
src/sema/assembly/tests/switch.rs → src/sema/yul/tests/switch.rs

@@ -1,6 +1,6 @@
 #![cfg(test)]
 
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 
 #[test]
 fn case_not_literal() {

+ 1 - 1
src/sema/assembly/tests/types.rs → src/sema/yul/tests/types.rs

@@ -1,6 +1,6 @@
 #![cfg(test)]
 
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 
 #[test]
 fn type_not_found() {

+ 4 - 4
src/sema/assembly/tests/unused_variable.rs → src/sema/yul/tests/unused_variable.rs

@@ -1,4 +1,4 @@
-use crate::sema::assembly::tests::{assert_message_in_diagnostics, parse};
+use crate::sema::yul::tests::{assert_message_in_diagnostics, parse};
 
 #[test]
 fn unused_variables() {
@@ -25,7 +25,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "assembly variable ‘a‘ has never been read or assigned"
+        "yul variable ‘a‘ has never been read or assigned"
     ));
 
     let file = r#"
@@ -51,7 +51,7 @@ contract testTypes {
     let ns = parse(file);
     assert!(assert_message_in_diagnostics(
         &ns.diagnostics,
-        "assembly variable ‘c‘ has never been read"
+        "yul variable ‘c‘ has never been read"
     ));
 }
 
@@ -91,7 +91,7 @@ fn correct_contracts() {
 
     let ns = parse(file);
     for item in &ns.diagnostics {
-        assert!(!item.message.starts_with("assembly variable has never been"));
+        assert!(!item.message.starts_with("yul variable has never been"));
     }
 
     let file = r#"

+ 14 - 14
src/sema/assembly/types.rs → src/sema/yul/types.rs

@@ -1,7 +1,7 @@
 use crate::ast::{Namespace, Type};
 use crate::pt::CodeLocation;
-use crate::sema::assembly::ast::AssemblyExpression;
-use crate::sema::assembly::functions::FunctionsTable;
+use crate::sema::yul::ast::YulExpression;
+use crate::sema::yul::functions::FunctionsTable;
 use solang_parser::pt::Identifier;
 use solang_parser::Diagnostic;
 
@@ -45,23 +45,23 @@ pub(crate) fn get_default_type_from_identifier(
 
 /// Performs checks on whether it is possible to retrieve a type from an expression
 pub(crate) fn verify_type_from_expression(
-    expr: &AssemblyExpression,
+    expr: &YulExpression,
     function_table: &FunctionsTable,
 ) -> Result<Type, Diagnostic> {
     match expr {
-        AssemblyExpression::BoolLiteral(..) => Ok(Type::Bool),
+        YulExpression::BoolLiteral(..) => Ok(Type::Bool),
 
-        AssemblyExpression::NumberLiteral(_, _, ty)
-        | AssemblyExpression::StringLiteral(_, _, ty)
-        | AssemblyExpression::AssemblyLocalVariable(_, ty, _)
-        | AssemblyExpression::ConstantVariable(_, ty, ..)
-        | AssemblyExpression::SolidityLocalVariable(_, ty, None, _) => Ok(ty.clone()),
+        YulExpression::NumberLiteral(_, _, ty)
+        | YulExpression::StringLiteral(_, _, ty)
+        | YulExpression::YulLocalVariable(_, ty, _)
+        | YulExpression::ConstantVariable(_, ty, ..)
+        | YulExpression::SolidityLocalVariable(_, ty, None, _) => Ok(ty.clone()),
 
-        AssemblyExpression::SolidityLocalVariable(_, _, Some(_), _)
-        | AssemblyExpression::MemberAccess(..)
-        | AssemblyExpression::StorageVariable(..) => Ok(Type::Uint(256)),
+        YulExpression::SolidityLocalVariable(_, _, Some(_), _)
+        | YulExpression::MemberAccess(..)
+        | YulExpression::StorageVariable(..) => Ok(Type::Uint(256)),
 
-        AssemblyExpression::BuiltInCall(_, ty, _) => {
+        YulExpression::BuiltInCall(_, ty, _) => {
             let prototype = ty.get_prototype_info();
             if prototype.no_returns == 0 {
                 Err(Diagnostic::error(
@@ -81,7 +81,7 @@ pub(crate) fn verify_type_from_expression(
             }
         }
 
-        AssemblyExpression::FunctionCall(_, function_no, ..) => {
+        YulExpression::FunctionCall(_, function_no, ..) => {
             let func = function_table.get(*function_no).unwrap();
             if func.returns.is_empty() {
                 Err(Diagnostic::error(

+ 44 - 0
src/sema/yul/unused_variable.rs

@@ -0,0 +1,44 @@
+use crate::ast::Namespace;
+use crate::sema::symtable::Symtable;
+use crate::sema::yul::ast::YulExpression;
+
+pub(crate) fn assigned_variable(ns: &mut Namespace, exp: &YulExpression, symtable: &mut Symtable) {
+    match exp {
+        // Considering that semantic analysis already considered the assignment valid
+        YulExpression::SolidityLocalVariable(_, _, _, var_no)
+        | YulExpression::YulLocalVariable(_, _, var_no) => {
+            let var = symtable.vars.get_mut(var_no).unwrap();
+            (*var).assigned = true;
+        }
+
+        YulExpression::StorageVariable(_, _, contract_no, var_no) => {
+            ns.contracts[*contract_no].variables[*var_no].assigned = true;
+        }
+
+        YulExpression::MemberAccess(_, member, _) => {
+            assigned_variable(ns, member, symtable);
+        }
+
+        _ => (),
+    }
+}
+
+pub(crate) fn used_variable(ns: &mut Namespace, exp: &YulExpression, symtable: &mut Symtable) {
+    match exp {
+        YulExpression::SolidityLocalVariable(_, _, _, var_no)
+        | YulExpression::YulLocalVariable(_, _, var_no) => {
+            let var = symtable.vars.get_mut(var_no).unwrap();
+            (*var).read = true;
+        }
+
+        YulExpression::StorageVariable(_, _, contract_no, var_no) => {
+            ns.contracts[*contract_no].variables[*var_no].read = true;
+        }
+
+        YulExpression::MemberAccess(_, member, _) => {
+            used_variable(ns, member, symtable);
+        }
+
+        _ => (),
+    }
+}

+ 2 - 2
tests/contract_testcases/solana/assembly/function_cal_cond.dot

@@ -72,8 +72,8 @@ strict digraph "tests/contract_testcases/solana/assembly/function_cal_cond.sol"
 	yul_number_literal_72 [label="uint256 literal: 5\ntests/contract_testcases/solana/assembly/function_cal_cond.sol:31:26-27"]
 	diagnostic [label="found contract ‘testTypes’\nlevel Debug\ntests/contract_testcases/solana/assembly/function_cal_cond.sol:1:1-20"]
 	diagnostic_75 [label="evm assembly not supported on target solana\nlevel Error\ntests/contract_testcases/solana/assembly/function_cal_cond.sol:3:9-33:10"]
-	diagnostic_76 [label="unreachable assembly statement\nlevel Warning\ntests/contract_testcases/solana/assembly/function_cal_cond.sol:31:17-27"]
-	diagnostic_77 [label="assembly variable ‘x‘ has never been read\nlevel Warning\ntests/contract_testcases/solana/assembly/function_cal_cond.sol:31:21-22"]
+	diagnostic_76 [label="unreachable yul statement\nlevel Warning\ntests/contract_testcases/solana/assembly/function_cal_cond.sol:31:17-27"]
+	diagnostic_77 [label="yul variable ‘x‘ has never been read\nlevel Warning\ntests/contract_testcases/solana/assembly/function_cal_cond.sol:31:21-22"]
 	contracts -> contract
 	contract -> testAsm [label="function"]
 	testAsm -> inline_assembly [label="body"]