diff options
author | peter <peter@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2006-02-05 22:24:18 +0000 |
---|---|---|
committer | peter <peter@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2006-02-05 22:24:18 +0000 |
commit | 8d8779efdc3635b35726a48a927b2de506dc8dac (patch) | |
tree | ae973fb2f30b1da437b988336e1382ac3180e7bb /compiler/pbase.pas | |
parent | 0b5a155aae4dc2ceaa7aa9c6e5d950fb50ac6eb9 (diff) | |
download | fpc-8d8779efdc3635b35726a48a927b2de506dc8dac.tar.gz |
* symtablestack cleanup and rewrite
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@2448 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/pbase.pas')
-rw-r--r-- | compiler/pbase.pas | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/compiler/pbase.pas b/compiler/pbase.pas index 54c8e01229..265d2c768b 100644 --- a/compiler/pbase.pas +++ b/compiler/pbase.pas @@ -52,9 +52,6 @@ interface { for operators } optoken : ttoken; - { symtable were unit references are stored } - refsymtable : tsymtable; - { true, if only routine headers should be parsed } parse_only : boolean; @@ -85,6 +82,8 @@ interface and return an errorsym } function consume_sym(var srsym:tsym;var srsymtable:tsymtable):boolean; + function try_consume_unitsym(var srsym:tsym;var srsymtable:tsymtable):boolean; + function try_consume_hintdirective(var symopt:tsymoptions):boolean; { just for an accurate position of the end of a procedure (PM) } @@ -179,43 +178,53 @@ implementation begin { first check for identifier } if token<>_ID then - begin - consume(_ID); - srsym:=generrorsym; - srsymtable:=nil; - consume_sym:=false; - exit; - end; + begin + consume(_ID); + srsym:=generrorsym; + srsymtable:=nil; + result:=false; + exit; + end; searchsym(pattern,srsym,srsymtable); - if assigned(srsym) then - begin - check_hints(srsym,srsym.symoptions); - if (srsym.typ=unitsym) then - begin - if not(srsym.owner.symtabletype in [staticsymtable,globalsymtable]) then - internalerror(200501154); - { only allow unit.symbol access if the name was - found in the current module } - if srsym.owner.iscurrentunit then - begin - consume(_ID); - consume(_POINT); - srsymtable:=tunitsym(srsym).unitsymtable; - srsym:=searchsymonlyin(srsymtable,pattern); - end - else - srsym:=nil; - end; - end; + { handle unit specification like System.Writeln } + try_consume_unitsym(srsym,srsymtable); { if nothing found give error and return errorsym } - if srsym=nil then - begin - identifier_not_found(orgpattern); - srsym:=generrorsym; - srsymtable:=nil; - end; + if assigned(srsym) then + check_hints(srsym,srsym.symoptions) + else + begin + identifier_not_found(orgpattern); + srsym:=generrorsym; + srsymtable:=nil; + end; consume(_ID); - consume_sym:=assigned(srsym); + result:=assigned(srsym); + end; + + + function try_consume_unitsym(var srsym:tsym;var srsymtable:tsymtable):boolean; + begin + result:=false; + if assigned(srsym) and + (srsym.typ=unitsym) then + begin + if not(srsym.owner.symtabletype in [staticsymtable,globalsymtable]) then + internalerror(200501154); + { only allow unit.symbol access if the name was + found in the current module } + if srsym.owner.iscurrentunit then + begin + consume(_ID); + consume(_POINT); + searchsym_in_module(tunitsym(srsym).module,pattern,srsym,srsymtable); + end + else + begin + srsym:=nil; + srsymtable:=nil; + end; + result:=true; + end; end; |