This page explains how a label in imported source is evaluated from host source.


The import directive doesn't literally include the imported file as-is. The rationale is explained in the user guide.

In particular, host and imported source remains encoded independently. So, a same label name can a have different id in each. Reconcile that for each label would be far too slow, and rather unnecessary. On the other hand, we have to convert id to access a specific imported label.

The assembly is very fast since it only deals with ids, not names. And a label only defined in imported source won't be seen by host source. As for FF Alpha 7, that leads to "undefined label". In this case, before returning the error, we want to try to find if the label is in one of the important source (if it is present in more than one, that's another error: ambiguous label).

Relevant routines

They will be used by asseva.o:

  • When a label is not defined is current source.
  • [todo] For full qualifation.

In pseudo code:

eval_label_in_import(name, import_id):
; In: name= name of label (nt string)
    ; import_id = source # of import (from 0 to 31)
;Out: label value (with flags, e.g. possibly undefined/undeclared/other error) 

; Needed by eval_label_in_any_import()
; Will also be needed when full qualification is available
;    e.g. CRTC.SET(12, &10)
; since in this case we'll know which imported file to check.

   host = get_current_source_id()
   id = get_id_from_name(name)
   res = get_value(id)
   ; Reconnect host
   return res
; In: name= id of label (in host source)
;Out: label value (with flags, e.g. possibly undefined/undeclared/other error) 

   res = None   ; Flag to no result found yet
   name = get_name_from(id)
   for import_id in [0:max_source_id]:

      ; Only checks for sources that are actually imported
      if is_dependency(import_id):
          tmp = eval_label_in_import()
          if is_declared(tmp):
              if res is None:
                  res = tmp
                  exit_error("Defined in both %s and %s" % [get_source_id(tmp), get_source_id(res)])
   return res
Sauf mention contraire, le contenu de cette page est protégé par la licence Creative Commons Attribution-ShareAlike 3.0 License