flat assembler
Message board for the users of flat assembler.
Index
> Main > [solved] Global namespace clash fasmg |
Author |
|
bitRAKE 16 Aug 2020, 18:26
Code: getNextItem = 0 T.#..getNextItem = getNextItem T: namespace T getNextItem = 1 display "0"+getNextItem display "0"+..getNextItem ; value outside of this scope end namespace display "0"+getNextItem https://flatassembler.net/docs.php?article=fasmg_manual#2 (towards the end of section) _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
16 Aug 2020, 18:26 |
|
Tomasz Grysztar 16 Aug 2020, 18:41
I'm not sure if I understood your problem correctly, but it seems that your trouble is simply with defining an alias to a global symbol, so that you would be access it through an alias from inside a namespace where another symbol with the same name exists.
There are actually several ways to do it, you can choose whichever feels the most fitting to your style. For a static label you can simply make an alias using LABEL directive: Code: getNextItem: ; global list: label list.getNextItem at getNextItem table: namespace table getNextItem: ; local call getNextItem ; call to local call list.getNextItem ; call to global end namespace Code: list.getNextItem := getNextItem Code: ; A WRONG EXAMPLE: list: namespace list getNextItem := getNextItem ; this won't work, both identifiers end up referring to local symbol, ; so this is a self-dependent (circular) definition, usually gets resolved with value 0 end namespace Code: getNextItem: ; global define aliasGetNextItem getNextItem list: namespace list getNextItem := aliasGetNextItem end namespace Code: define aliasItem item ; link to global symbol table: namespace table item = 11h db item ; db 11h db aliasItem ; db 1 end namespace item = 2 ; redefinition of global symbol table2: namespace table2 item = 22h db item ; db 22h db aliasItem ; db 2 end namespace |
|||
16 Aug 2020, 18:41 |
|
donn 17 Aug 2020, 03:05
Sorry, realize the best solution here is to just put list's getNextItem in a list namespace and do away with the global getNextItem. I am incurring technical debt by pushing this off. Since this is a compromise, I probably overcomplicated the description of the problem.
Used this: Code: define getNextListItem getNextItem getNextItem: push rbp mov rbp, rsp sub rsp, (8);((8)+(8)) ... ; Function body and called it within table: Code: call getNextListItem leaving the table's getNextItem as it was. Tested it out and it works! I was having some trouble with other flavors of this, each kept saying this: Code: /../../Table/Table.inc [365]: call list.getNextItem call [2] parse_jump_operand [25] parse_operand [38] (CALM) Error: symbol 'getNextItem' is undefined or out of scope. I think in retrospect, this is because table getNextItem is buried beneath TWO namespaces, table and getNextItem. Not sure if not, will study both of your samples and use them as references. |
|||
17 Aug 2020, 03:05 |
|
donn 19 Aug 2020, 04:46
Ah, pretty sure figured out why was getting
Code: /../../Table/Table.inc [365]: call list.getNextItem call [2] parse_jump_operand [25] parse_operand [38] (CALM) Error: symbol 'getNextItem' is undefined or out of scope. In my 'table,' I had local stack vars labeled as so: Code: ; Get each i val at Table's j index ; Should consider caching the j List in the Table so heapfree is not necessary getNextJVals: namespace getNextJVals push rbp mov rbp, rsp sub rsp, (8*14);+(8*6) label heapAddress qword at rbp-8 label handleAllocatedMemory qword at rbp-16 label list qword at rbp-24 label table qword at rbp-32 label index qword at rbp-40 And there was a list local var, so list.getNextItem was probably getting confused. I've run into this before when first converting from fasm to fasmg. Squared away. |
|||
19 Aug 2020, 04:46 |
|
Tomasz Grysztar 23 Aug 2020, 13:39
donn wrote: Ah, pretty sure figured out why was getting |
|||
23 Aug 2020, 13:39 |
|
donn 23 Aug 2020, 17:07
Confirmed, updated..!
|
|||
23 Aug 2020, 17:07 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.