Explorar el Código

* allow unit.identifier in asm readers

peter hace 24 años
padre
commit
60162bf433
Se han modificado 3 ficheros con 91 adiciones y 18 borrados
  1. 25 2
      compiler/i386/ra386att.pas
  2. 24 1
      compiler/i386/ra386int.pas
  3. 42 15
      compiler/rautils.pas

+ 25 - 2
compiler/i386/ra386att.pas

@@ -269,6 +269,8 @@ end;
 Procedure GetToken;
 Procedure GetToken;
 var
 var
   len : longint;
   len : longint;
+  srsym : tsym;
+  srsymtable : tsymtable;
 begin
 begin
   { save old token and reset new token }
   { save old token and reset new token }
   prevasmtoken:=actasmtoken;
   prevasmtoken:=actasmtoken;
@@ -392,7 +394,7 @@ begin
            actasmpattern[0]:=chr(len);
            actasmpattern[0]:=chr(len);
            uppervar(actasmpattern);
            uppervar(actasmpattern);
            { Opcode, can only be when the previous was a prefix }
            { Opcode, can only be when the previous was a prefix }
-           If is_prefix(actopcode) and is_asmopcode(upper(actasmpattern)) then
+           If is_prefix(actopcode) and is_asmopcode(actasmpattern) then
             Begin
             Begin
               uppervar(actasmpattern);
               uppervar(actasmpattern);
               exit;
               exit;
@@ -408,6 +410,24 @@ begin
               actasmtoken:=AS_TYPE;
               actasmtoken:=AS_TYPE;
               exit;
               exit;
             end;
             end;
+           { if next is a '.' and this is a unitsym then we also need to
+             parse the identifier }
+           if (c='.') then
+            begin
+              searchsym(actasmpattern,srsym,srsymtable);
+              if assigned(srsym) and
+                 (srsym.typ=unitsym) and
+                 (srsym.owner.unitid=0) then
+               begin
+                 actasmpattern:=actasmpattern+c;
+                 c:=current_scanner.asmgetchar;
+                 while c in  ['A'..'Z','a'..'z','0'..'9','_','$'] do
+                  begin
+                    actasmpattern:=actasmpattern + upcase(c);
+                    c:=current_scanner.asmgetchar;
+                  end;
+               end;
+            end;
            actasmtoken:=AS_ID;
            actasmtoken:=AS_ID;
            exit;
            exit;
          end;
          end;
@@ -2119,7 +2139,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2001-04-13 18:20:21  peter
+  Revision 1.11  2001-04-13 20:06:05  peter
+    * allow unit.identifier in asm readers
+
+  Revision 1.10  2001/04/13 18:20:21  peter
     * scanner object to class
     * scanner object to class
 
 
   Revision 1.9  2001/04/13 01:22:21  peter
   Revision 1.9  2001/04/13 01:22:21  peter

+ 24 - 1
compiler/i386/ra386int.pas

@@ -258,6 +258,8 @@ Procedure GetToken;
 var
 var
   len : longint;
   len : longint;
   forcelabel : boolean;
   forcelabel : boolean;
+  srsym : tsym;
+  srsymtable : tsymtable;
 begin
 begin
   { save old token and reset new token }
   { save old token and reset new token }
   prevasmtoken:=actasmtoken;
   prevasmtoken:=actasmtoken;
@@ -378,6 +380,24 @@ begin
             exit;
             exit;
            if is_asmoperator(actasmpattern) then
            if is_asmoperator(actasmpattern) then
             exit;
             exit;
+           { if next is a '.' and this is a unitsym then we also need to
+             parse the identifier }
+           if (c='.') then
+            begin
+              searchsym(actasmpattern,srsym,srsymtable);
+              if assigned(srsym) and
+                 (srsym.typ=unitsym) and
+                 (srsym.owner.unitid=0) then
+               begin
+                 actasmpattern:=actasmpattern+c;
+                 c:=current_scanner.asmgetchar;
+                 while c in  ['A'..'Z','a'..'z','0'..'9','_','$'] do
+                  begin
+                    actasmpattern:=actasmpattern + upcase(c);
+                    c:=current_scanner.asmgetchar;
+                  end;
+               end;
+            end;
            actasmtoken:=AS_ID;
            actasmtoken:=AS_ID;
            exit;
            exit;
          end;
          end;
@@ -1948,7 +1968,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.13  2001-04-13 18:20:21  peter
+  Revision 1.14  2001-04-13 20:06:05  peter
+    * allow unit.identifier in asm readers
+
+  Revision 1.13  2001/04/13 18:20:21  peter
     * scanner object to class
     * scanner object to class
 
 
   Revision 1.12  2001/04/13 01:22:21  peter
   Revision 1.12  2001/04/13 01:22:21  peter

+ 42 - 15
compiler/rautils.pas

@@ -28,7 +28,8 @@ Interface
 
 
 Uses
 Uses
   cutils,cclasses,
   cutils,cclasses,
-  globtype,aasm,cpubase,symconst,symdef;
+  globtype,aasm,cpubase,
+  symconst,symbase,symtype,symdef;
 
 
 Const
 Const
   RPNMax = 10;             { I think you only need 4, but just to be safe }
   RPNMax = 10;             { I think you only need 4, but just to be safe }
@@ -97,7 +98,7 @@ type
     Function  SetupResult:boolean;virtual;
     Function  SetupResult:boolean;virtual;
     Function  SetupSelf:boolean;
     Function  SetupSelf:boolean;
     Function  SetupOldEBP:boolean;
     Function  SetupOldEBP:boolean;
-    Function  SetupVar(const hs:string;GetOffset : boolean): Boolean;
+    Function  SetupVar(const s:string;GetOffset : boolean): Boolean;
     Function  SetupDirectVar(const hs:string): Boolean;
     Function  SetupDirectVar(const hs:string): Boolean;
     Procedure InitRef;
     Procedure InitRef;
   end;
   end;
@@ -182,6 +183,7 @@ Function EscapeToPascal(const s:string): string;
                      Symbol helper routines
                      Symbol helper routines
 ---------------------------------------------------------------------}
 ---------------------------------------------------------------------}
 
 
+procedure AsmSearchSym(const s:string;var srsym:tsym;var srsymtable:tsymtable);
 Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):boolean;
 Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):boolean;
 Function SearchType(const hs:string): Boolean;
 Function SearchType(const hs:string): Boolean;
 Function SearchRecordType(const s:string): boolean;
 Function SearchRecordType(const s:string): boolean;
@@ -215,7 +217,7 @@ uses
   strings,
   strings,
 {$endif}
 {$endif}
   types,systems,verbose,globals,
   types,systems,verbose,globals,
-  symbase,symtype,symsym,symtable,cpuasm
+  symsym,symtable,cpuasm
 {$ifdef NEWCG}
 {$ifdef NEWCG}
   ,cgbase;
   ,cgbase;
 {$else}
 {$else}
@@ -781,7 +783,7 @@ Begin
 end;
 end;
 
 
 
 
-Function TOperand.SetupVar(const hs:string;GetOffset : boolean): Boolean;
+Function TOperand.SetupVar(const s:string;GetOffset : boolean): Boolean;
 { search and sets up the correct fields in the Instr record }
 { search and sets up the correct fields in the Instr record }
 { for the NON-constant identifier passed to the routine.    }
 { for the NON-constant identifier passed to the routine.    }
 { if not found returns FALSE.                               }
 { if not found returns FALSE.                               }
@@ -791,9 +793,8 @@ var
   harrdef : tarraydef;
   harrdef : tarraydef;
 Begin
 Begin
   SetupVar:=false;
   SetupVar:=false;
-{ are we in a routine ? }
-  searchsym(hs,sym,srsymtable);
-  if sym=nil then
+  asmsearchsym(s,sym,srsymtable);
+  if sym = nil then
    exit;
    exit;
   case sym.typ of
   case sym.typ of
     varsym :
     varsym :
@@ -851,7 +852,7 @@ Begin
                      (lexlevel>normal_function_level) then
                      (lexlevel>normal_function_level) then
                     opr.ref.base:=procinfo^.parent^.framepointer
                     opr.ref.base:=procinfo^.parent^.framepointer
                   else
                   else
-                    message1(asmr_e_local_para_unreachable,hs);
+                    message1(asmr_e_local_para_unreachable,s);
                 end;
                 end;
               opr.ref.offset:=tvarsym(sym).address;
               opr.ref.offset:=tvarsym(sym).address;
               if (lexlevel=tvarsym(sym).owner.symtablelevel) then
               if (lexlevel=tvarsym(sym).owner.symtablelevel) then
@@ -890,7 +891,7 @@ Begin
                          (lexlevel>normal_function_level) then
                          (lexlevel>normal_function_level) then
                         opr.ref.base:=procinfo^.parent^.framepointer
                         opr.ref.base:=procinfo^.parent^.framepointer
                       else
                       else
-                        message1(asmr_e_local_para_unreachable,hs);
+                        message1(asmr_e_local_para_unreachable,s);
                     end;
                     end;
                   opr.ref.offset:=-(tvarsym(sym).address);
                   opr.ref.offset:=-(tvarsym(sym).address);
                   if (lexlevel=tvarsym(sym).owner.symtablelevel) then
                   if (lexlevel=tvarsym(sym).owner.symtablelevel) then
@@ -1173,12 +1174,35 @@ end;
                       Symbol table helper routines
                       Symbol table helper routines
 ****************************************************************************}
 ****************************************************************************}
 
 
+procedure AsmSearchSym(const s:string;var srsym:tsym;var srsymtable:tsymtable);
+var
+  i : integer;
+begin
+  i:=pos('.',s);
+  { allow unit.identifier }
+  if i>0 then
+   begin
+     searchsym(Copy(s,1,i-1),srsym,srsymtable);
+     if assigned(srsym) then
+      begin
+        if (srsym.typ=unitsym) and
+           (srsym.owner.unitid=0) then
+         srsym:=searchsymonlyin(tunitsym(srsym).unitsymtable,Copy(s,i+1,255))
+        else
+         srsym:=nil;
+      end;
+   end
+  else
+   searchsym(s,srsym,srsymtable);
+end;
+
+
 Function SearchType(const hs:string): Boolean;
 Function SearchType(const hs:string): Boolean;
 var
 var
   srsym : tsym;
   srsym : tsym;
   srsymtable : tsymtable;
   srsymtable : tsymtable;
 begin
 begin
-  searchsym(hs,srsym,srsymtable);
+  asmsearchsym(hs,srsym,srsymtable);
   SearchType:=assigned(srsym) and
   SearchType:=assigned(srsym) and
              (srsym.typ=typesym);
              (srsym.typ=typesym);
 end;
 end;
@@ -1192,7 +1216,7 @@ var
 Begin
 Begin
   SearchRecordType:=false;
   SearchRecordType:=false;
 { Check the constants in symtable }
 { Check the constants in symtable }
-  searchsym(s,srsym,srsymtable);
+  asmsearchsym(s,srsym,srsymtable);
   if srsym <> nil then
   if srsym <> nil then
    Begin
    Begin
      case srsym.typ of
      case srsym.typ of
@@ -1237,7 +1261,7 @@ Begin
      exit;
      exit;
    end;
    end;
 { Check the constants in symtable }
 { Check the constants in symtable }
-  searchsym(s,srsym,srsymtable);
+  asmsearchsym(s,srsym,srsymtable);
   if srsym <> nil then
   if srsym <> nil then
    Begin
    Begin
      case srsym.typ of
      case srsym.typ of
@@ -1286,7 +1310,7 @@ Begin
    st:=procinfo^._class.symtable
    st:=procinfo^._class.symtable
   else
   else
    begin
    begin
-     searchsym(base,sym,srsymtable);
+     asmsearchsym(base,sym,srsymtable);
      st:=nil;
      st:=nil;
      { we can start with a var,type,typedconst }
      { we can start with a var,type,typedconst }
      case sym.typ of
      case sym.typ of
@@ -1376,7 +1400,7 @@ Begin
   SearchLabel:=false;
   SearchLabel:=false;
 { Check for pascal labels, which are case insensetive }
 { Check for pascal labels, which are case insensetive }
   hs:=upper(s);
   hs:=upper(s);
-  searchsym(hs,sym,srsymtable);
+  asmsearchsym(hs,sym,srsymtable);
   if sym=nil then
   if sym=nil then
    exit;
    exit;
   case sym.typ of
   case sym.typ of
@@ -1559,7 +1583,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.18  2001-04-13 01:22:13  peter
+  Revision 1.19  2001-04-13 20:06:05  peter
+    * allow unit.identifier in asm readers
+
+  Revision 1.18  2001/04/13 01:22:13  peter
     * symtable change to classes
     * symtable change to classes
     * range check generation and errors fixed, make cycle DEBUG=1 works
     * range check generation and errors fixed, make cycle DEBUG=1 works
     * memory leaks fixed
     * memory leaks fixed