SlideShare a Scribd company logo
1 of 18
ACCESS TO NONLOCAL
NAMES
Shashwat Shriparv
dwivedishashwat@gmail.com
InfinitySoft
Access Links
• A direct implementation of lexical scope for
nested procedures is obtained by adding a
pointer called an access link to each
activation record.
• If procedure p is nested immediately within
q in the source text,then the access link in
an activation record for p points to the
access link in the record for the most recent
activation of q.
Nesting
Depth=3
Nesting
Depth=2
Nesting
Depth=1
Nesting
Depth=2
Access Links (Static Links)
s
a x
q(1,9)
access
k v
s
a x
q(1,9)
access
k v
q(1,3)
access
k v
s
a x
q(1,9)
access
k v
q(1,3)
access
k v
p(1,3)
access
i j
s
a x
q(1,9)
access
k v
q(1,3)
access
k v
p(1,3)
access
i j
e(1,3)
access
The access link points to the
activation record of the static
parent procedure:
s is parent of r, e, and q
q is parent of p
Suppose procedure p at nesting depth np
refers to a non local a with nesting depth
na<=np.The storage for ‘a’ can be found as
follows.
1. When control is in p, an activation record
for p is at the top of the stack. Follow np –na
access links from the record at the top of the
stack. The value of np –na can be
precomputed at compile time
2. After following np –na links, we reach an
activation record for the procedure that a is
local to.
DISPLAYS
Faster access to nonlocals than with
access links can be obtained using an array
d of pointers to activation records,called a
display. We maintain the display so that
storage for a nonlocal ‘a’ at nesting depth i
is in the activation record pointed to by
display element d[i].
Using a display is generally faster than
following access links because the
activation record holding a nonlocal is
found by accessing an element of d and then
following just one pointer.
The display changes when a new
activation occurs,and it must be reset when
control returns from the new activation.
When a new activation record for a
procedure at nesting depth i is set up,we
1.Save the value of d[i] in the new
activation record and
2.Set d[i] to point to the new activation
record.
Just before an activation ends,d[i] is reset
to the saved value.
Suppose a procedure at nesting depth j calls
a procedure at depth i.There are two
cases,depending on whether or not the
called procedure is nested within the caller
in the source text,as in the discussion of
access links.
1. Case j<i.Then i=j+1 and the called
procedure is nested within the caller.The
first j elements of the display therefore do not need
to be changed,and we set d[i] to the new activation
record.
2.Case j>=i. Again the enclosing procedures at
nesting depths 1,2,…,i-1 of the called and calling
procedure must be the same. Here,we save the old
value of d[i] in the new activation record, and
make d[i] point to the new activation record.
DYNAMIC SCOPE
Under dynamic scope,a new activation
inherits the existing bindings of nonlocal
names to storage.A nonlocal name ‘a’ in the
called activation refers to the same storage
that it did in the calling activation.New
bindings are set up for local names of the
called procedure;the names refer to storage
in the new activation record.
The following two approaches to implementing
dynamic scope bear some resemblance to the use
of access links and displays, respectively in the
implementation of lexical scope.
1.Deep access. Conceptually, dynamic scope results
if access links point to the same activation records
that control links do. The term deep access comes
from the fact that the search goes deep into the
stack.
• Shallow access. Here, the idea is to hold the
current value of each name in statically
allocated storage. When a new activation of
a procedure p occurs, a local name n in p
takes over the storage statically allocated
for n.The previous value of n can be saved
in the activation record for p and must be
restored when the activation of p ends.
The trade-off between the two
approaches is that deep access takes longer
to access a nonlocal,but there is no
overhead associated with beginning and
ending an activation. Shallow access on the
other hand allows nonlocals to be looked up
directly, but time is taken to maintain these
values when activations begin and end.
THANK YOU…
Shashwat Shriparv
dwivedishashwat@gmail.com
InfinitySoft

More Related Content

What's hot (20)

Parse Tree
Parse TreeParse Tree
Parse Tree
 
Divide&Conquer & Dynamic Programming
Divide&Conquer & Dynamic ProgrammingDivide&Conquer & Dynamic Programming
Divide&Conquer & Dynamic Programming
 
COMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time EnvironmentsCOMPILER DESIGN Run-Time Environments
COMPILER DESIGN Run-Time Environments
 
Run time storage
Run time storageRun time storage
Run time storage
 
search strategies in artificial intelligence
search strategies in artificial intelligencesearch strategies in artificial intelligence
search strategies in artificial intelligence
 
symmetric key encryption algorithms
 symmetric key encryption algorithms symmetric key encryption algorithms
symmetric key encryption algorithms
 
NFA or Non deterministic finite automata
NFA or Non deterministic finite automataNFA or Non deterministic finite automata
NFA or Non deterministic finite automata
 
ARTIFICIAL INTELLIGENCE
ARTIFICIAL INTELLIGENCEARTIFICIAL INTELLIGENCE
ARTIFICIAL INTELLIGENCE
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 
Mining Frequent Patterns, Association and Correlations
Mining Frequent Patterns, Association and CorrelationsMining Frequent Patterns, Association and Correlations
Mining Frequent Patterns, Association and Correlations
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Simplification of cfg ppt
Simplification of cfg pptSimplification of cfg ppt
Simplification of cfg ppt
 
String matching algorithm
String matching algorithmString matching algorithm
String matching algorithm
 
Code generation in Compiler Design
Code generation in Compiler DesignCode generation in Compiler Design
Code generation in Compiler Design
 
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prologChaps 1-3-ai-prolog
Chaps 1-3-ai-prolog
 
And or graph
And or graphAnd or graph
And or graph
 
serializability in dbms
serializability in dbmsserializability in dbms
serializability in dbms
 
NLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit DistanceNLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit Distance
 
String matching, naive,
String matching, naive,String matching, naive,
String matching, naive,
 
Little o and little omega
Little o and little omegaLittle o and little omega
Little o and little omega
 

Viewers also liked (20)

Compiler design
Compiler designCompiler design
Compiler design
 
Compiler design
Compiler designCompiler design
Compiler design
 
Erp
ErpErp
Erp
 
Cdma
CdmaCdma
Cdma
 
Linux 4 you
Linux 4 youLinux 4 you
Linux 4 you
 
Fragmentation
FragmentationFragmentation
Fragmentation
 
Email
EmailEmail
Email
 
Apple i phone
Apple i phoneApple i phone
Apple i phone
 
How to Study for Tests
How to Study for TestsHow to Study for Tests
How to Study for Tests
 
Data base design
Data base designData base design
Data base design
 
Cluster computing
Cluster computingCluster computing
Cluster computing
 
History of simulation software
History of simulation softwareHistory of simulation software
History of simulation software
 
File records on disk
File records on diskFile records on disk
File records on disk
 
Grid computing
Grid computingGrid computing
Grid computing
 
Cumulative distribution
Cumulative distributionCumulative distribution
Cumulative distribution
 
Exception handling java
Exception handling javaException handling java
Exception handling java
 
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
Compiler Design - Ambiguous grammar, LMD & RMD, Infix & Postfix, Implementati...
 
Digital water marking
Digital water markingDigital water marking
Digital water marking
 
Type checking in compiler design
Type checking in compiler designType checking in compiler design
Type checking in compiler design
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 

Similar to Access to non local names

Intermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfIntermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfHimanshu883663
 
Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...Aori Nevo, PhD
 
OmniBase Object Database
OmniBase Object DatabaseOmniBase Object Database
OmniBase Object DatabaseESUG
 
System Verilog Functional Coverage
System Verilog Functional CoverageSystem Verilog Functional Coverage
System Verilog Functional Coveragerraimi
 
09 implementing+subprograms
09 implementing+subprograms09 implementing+subprograms
09 implementing+subprogramsbaran19901990
 
Cloudproject
CloudprojectCloudproject
Cloudprojectanushv24
 
Runtimeenvironment
RuntimeenvironmentRuntimeenvironment
RuntimeenvironmentAnusuya123
 

Similar to Access to non local names (11)

Ch7
Ch7Ch7
Ch7
 
Intermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdfIntermediate code optimization Unit-4.pdf
Intermediate code optimization Unit-4.pdf
 
Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...Need to make a horizontal change across 100+ microservices? No worries, Sheph...
Need to make a horizontal change across 100+ microservices? No worries, Sheph...
 
OmniBase Object Database
OmniBase Object DatabaseOmniBase Object Database
OmniBase Object Database
 
Compiler Design Unit 4
Compiler Design Unit 4Compiler Design Unit 4
Compiler Design Unit 4
 
System Verilog Functional Coverage
System Verilog Functional CoverageSystem Verilog Functional Coverage
System Verilog Functional Coverage
 
Run time administration
Run time administrationRun time administration
Run time administration
 
09 implementing+subprograms
09 implementing+subprograms09 implementing+subprograms
09 implementing+subprograms
 
Cloudproject
CloudprojectCloudproject
Cloudproject
 
Runtimeenvironment
RuntimeenvironmentRuntimeenvironment
Runtimeenvironment
 
Helix talk at RelateIQ
Helix talk at RelateIQHelix talk at RelateIQ
Helix talk at RelateIQ
 

More from Shashwat Shriparv

More from Shashwat Shriparv (20)

Learning Linux Series Administrator Commands.pptx
Learning Linux Series Administrator Commands.pptxLearning Linux Series Administrator Commands.pptx
Learning Linux Series Administrator Commands.pptx
 
LibreOffice 7.3.pptx
LibreOffice 7.3.pptxLibreOffice 7.3.pptx
LibreOffice 7.3.pptx
 
Kerberos Architecture.pptx
Kerberos Architecture.pptxKerberos Architecture.pptx
Kerberos Architecture.pptx
 
Suspending a Process in Linux.pptx
Suspending a Process in Linux.pptxSuspending a Process in Linux.pptx
Suspending a Process in Linux.pptx
 
Kerberos Architecture.pptx
Kerberos Architecture.pptxKerberos Architecture.pptx
Kerberos Architecture.pptx
 
Command Seperators.pptx
Command Seperators.pptxCommand Seperators.pptx
Command Seperators.pptx
 
Upgrading hadoop
Upgrading hadoopUpgrading hadoop
Upgrading hadoop
 
Hadoop migration and upgradation
Hadoop migration and upgradationHadoop migration and upgradation
Hadoop migration and upgradation
 
R language introduction
R language introductionR language introduction
R language introduction
 
Hive query optimization infinity
Hive query optimization infinityHive query optimization infinity
Hive query optimization infinity
 
H base introduction & development
H base introduction & developmentH base introduction & development
H base introduction & development
 
Hbase interact with shell
Hbase interact with shellHbase interact with shell
Hbase interact with shell
 
H base development
H base developmentH base development
H base development
 
Hbase
HbaseHbase
Hbase
 
H base
H baseH base
H base
 
My sql
My sqlMy sql
My sql
 
Apache tomcat
Apache tomcatApache tomcat
Apache tomcat
 
Introduction to apache hadoop
Introduction to apache hadoopIntroduction to apache hadoop
Introduction to apache hadoop
 
Next generation technology
Next generation technologyNext generation technology
Next generation technology
 
Configure h base hadoop and hbase client
Configure h base hadoop and hbase clientConfigure h base hadoop and hbase client
Configure h base hadoop and hbase client
 

Recently uploaded

7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessAggregage
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Servicediscovermytutordmt
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdfOrient Homes
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...noida100girls
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyEthan lee
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Tina Ji
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewasmakika9823
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Lviv Startup Club
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒anilsa9823
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...lizamodels9
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 

Recently uploaded (20)

7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
Sales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for SuccessSales & Marketing Alignment: How to Synergize for Success
Sales & Marketing Alignment: How to Synergize for Success
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Call Girls in Gomti Nagar - 7388211116 - With room Service
Call Girls in Gomti Nagar - 7388211116  - With room ServiceCall Girls in Gomti Nagar - 7388211116  - With room Service
Call Girls in Gomti Nagar - 7388211116 - With room Service
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdf
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...BEST ✨ Call Girls In  Indirapuram Ghaziabad  ✔️ 9871031762 ✔️ Escorts Service...
BEST ✨ Call Girls In Indirapuram Ghaziabad ✔️ 9871031762 ✔️ Escorts Service...
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
Nepali Escort Girl Kakori \ 9548273370 Indian Call Girls Service Lucknow ₹,9517
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒VIP Call Girls In Saharaganj ( Lucknow  ) 🔝 8923113531 🔝  Cash Payment (COD) 👒
VIP Call Girls In Saharaganj ( Lucknow ) 🔝 8923113531 🔝 Cash Payment (COD) 👒
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 

Access to non local names

  • 1. ACCESS TO NONLOCAL NAMES Shashwat Shriparv dwivedishashwat@gmail.com InfinitySoft
  • 2. Access Links • A direct implementation of lexical scope for nested procedures is obtained by adding a pointer called an access link to each activation record. • If procedure p is nested immediately within q in the source text,then the access link in an activation record for p points to the access link in the record for the most recent activation of q.
  • 4. Access Links (Static Links) s a x q(1,9) access k v s a x q(1,9) access k v q(1,3) access k v s a x q(1,9) access k v q(1,3) access k v p(1,3) access i j s a x q(1,9) access k v q(1,3) access k v p(1,3) access i j e(1,3) access The access link points to the activation record of the static parent procedure: s is parent of r, e, and q q is parent of p
  • 5. Suppose procedure p at nesting depth np refers to a non local a with nesting depth na<=np.The storage for ‘a’ can be found as follows. 1. When control is in p, an activation record for p is at the top of the stack. Follow np –na access links from the record at the top of the stack. The value of np –na can be precomputed at compile time
  • 6. 2. After following np –na links, we reach an activation record for the procedure that a is local to.
  • 7. DISPLAYS Faster access to nonlocals than with access links can be obtained using an array d of pointers to activation records,called a display. We maintain the display so that storage for a nonlocal ‘a’ at nesting depth i is in the activation record pointed to by display element d[i].
  • 8.
  • 9. Using a display is generally faster than following access links because the activation record holding a nonlocal is found by accessing an element of d and then following just one pointer. The display changes when a new activation occurs,and it must be reset when control returns from the new activation.
  • 10. When a new activation record for a procedure at nesting depth i is set up,we 1.Save the value of d[i] in the new activation record and 2.Set d[i] to point to the new activation record. Just before an activation ends,d[i] is reset to the saved value.
  • 11. Suppose a procedure at nesting depth j calls a procedure at depth i.There are two cases,depending on whether or not the called procedure is nested within the caller in the source text,as in the discussion of access links. 1. Case j<i.Then i=j+1 and the called procedure is nested within the caller.The
  • 12. first j elements of the display therefore do not need to be changed,and we set d[i] to the new activation record. 2.Case j>=i. Again the enclosing procedures at nesting depths 1,2,…,i-1 of the called and calling procedure must be the same. Here,we save the old value of d[i] in the new activation record, and make d[i] point to the new activation record.
  • 13. DYNAMIC SCOPE Under dynamic scope,a new activation inherits the existing bindings of nonlocal names to storage.A nonlocal name ‘a’ in the called activation refers to the same storage that it did in the calling activation.New bindings are set up for local names of the called procedure;the names refer to storage in the new activation record.
  • 14.
  • 15. The following two approaches to implementing dynamic scope bear some resemblance to the use of access links and displays, respectively in the implementation of lexical scope. 1.Deep access. Conceptually, dynamic scope results if access links point to the same activation records that control links do. The term deep access comes from the fact that the search goes deep into the stack.
  • 16. • Shallow access. Here, the idea is to hold the current value of each name in statically allocated storage. When a new activation of a procedure p occurs, a local name n in p takes over the storage statically allocated for n.The previous value of n can be saved in the activation record for p and must be restored when the activation of p ends.
  • 17. The trade-off between the two approaches is that deep access takes longer to access a nonlocal,but there is no overhead associated with beginning and ending an activation. Shallow access on the other hand allows nonlocals to be looked up directly, but time is taken to maintain these values when activations begin and end.