customasm/asm/defs/
symbol.rs1use crate::*;
2
3
4#[derive(Debug)]
5pub struct Symbol
6{
7 pub item_ref: util::ItemRef<Self>,
8 pub no_emit: bool,
9 pub value_statically_known: bool,
10 pub value: expr::Value,
11 pub resolved: bool,
12 pub bankdef_ref: Option<util::ItemRef<asm::Bankdef>>,
13}
14
15
16pub fn define(
17 _report: &mut diagn::Report,
18 opts: &asm::AssemblyOptions,
19 ast: &asm::AstTopLevel,
20 _decls: &asm::ItemDecls,
21 defs: &mut asm::ItemDefs)
22 -> Result<(), ()>
23{
24 for any_node in &ast.nodes
25 {
26 let asm::AstAny::Symbol(node) = any_node
27 else { continue };
28
29 if defs.symbols
30 .maybe_get(node.item_ref.unwrap())
31 .is_some()
32 {
33 continue;
34 }
35
36
37 let item_ref = node.item_ref.unwrap();
38
39 let value_statically_known = {
40 match node.kind
41 {
42 asm::AstSymbolKind::Constant(ref constant) =>
43 {
44 let mut provider = expr::StaticallyKnownProvider::new(opts);
45 provider.query_function = &asm::resolver::resolve_and_get_statically_known_builtin_fn;
46
47 constant.expr.is_value_statically_known(&provider)
48 }
49
50 _ => false,
51 }
52 };
53
54 let symbol = Symbol {
55 item_ref,
56 no_emit: node.no_emit,
57 value_statically_known,
58 value: expr::Value::make_unknown()
59 .with_symbol_ref(item_ref),
60 resolved: false,
61 bankdef_ref: None,
62 };
63
64 defs.symbols.define(item_ref, symbol);
65 }
66
67
68 Ok(())
69}