From 8b1c270910fce13077864bf39d6e88971a6eb062 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 8 Jan 2025 12:34:47 +0100 Subject: Implement the .include statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This needed some heavy lifting when it comes to how files were located. This means that statements like .include/.incbin now take into consideration a new list made out of SourceInfo, which holds enough information to translate from which file a node comes from. This has also been added into errors, so they are more informative on what went wrong. In order to tests this, besides all the regular unit tests, a new e2e test has been added. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/node.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/xixanta/src/node.rs') diff --git a/lib/xixanta/src/node.rs b/lib/xixanta/src/node.rs index f919ade..1ec2ed9 100644 --- a/lib/xixanta/src/node.rs +++ b/lib/xixanta/src/node.rs @@ -140,6 +140,7 @@ pub enum ControlType { IncBin, StartRepeat, EndRepeat, + IncludeSource, } impl fmt::Display for ControlType { @@ -160,6 +161,7 @@ impl fmt::Display for ControlType { ControlType::IncBin => write!(f, ".incbin"), ControlType::StartRepeat => write!(f, ".repeat"), ControlType::EndRepeat => write!(f, ".endrepeat"), + ControlType::IncludeSource => write!(f, ".include"), } } } @@ -305,7 +307,7 @@ impl NodeType { } } -/// A Position Node. This is a node on a binary tree which holds a PString as a +/// A Positioned Node. This is a node on a tree which holds a PString as a /// value. The node type determines the actual representation of the value and /// both childs (see the `NodeType` enum). Moreover, out of convenience, a node /// also holds an optional list of arguments, which simplifies arrangements such @@ -330,6 +332,10 @@ pub struct PNode { /// Convenience list used by some node types in order to express a list of /// optional arguments. pub args: Option>, + + /// Index on the list of SourceInfo's maintained by both the parser and the + /// assembler. + pub source: usize, } /// Whether there is a body for a given node and whether it starts or ends it. -- cgit v1.2.3