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

Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithmsGanesh Solanke
 
Slides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And GagneSlides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And Gagnesarankumar4445
 
Distributed Shared Memory Systems
Distributed Shared Memory SystemsDistributed Shared Memory Systems
Distributed Shared Memory SystemsAnkit Gupta
 
Deadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikDeadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikSaeed Siddik
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronizationcscarcas
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OSvampugani
 
debugging - system software
debugging - system softwaredebugging - system software
debugging - system softwareVicky Shan
 
Processes and Processors in Distributed Systems
Processes and Processors in Distributed SystemsProcesses and Processors in Distributed Systems
Processes and Processors in Distributed SystemsDr Sandeep Kumar Poonia
 
Chapter 21 - The Linux System
Chapter 21 - The Linux SystemChapter 21 - The Linux System
Chapter 21 - The Linux SystemWayne Jones Jnr
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computingVajira Thambawita
 
Linux and windows file system
Linux and windows  file systemLinux and windows  file system
Linux and windows file systemlin yucheng
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFAkunj desai
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 

What's hot (20)

Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Distributed Operating System_1
Distributed Operating System_1Distributed Operating System_1
Distributed Operating System_1
 
Slides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And GagneSlides For Operating System Concepts By Silberschatz Galvin And Gagne
Slides For Operating System Concepts By Silberschatz Galvin And Gagne
 
Distributed Shared Memory Systems
Distributed Shared Memory SystemsDistributed Shared Memory Systems
Distributed Shared Memory Systems
 
Chapter 14 - Protection
Chapter 14 - ProtectionChapter 14 - Protection
Chapter 14 - Protection
 
Triggers and active database
Triggers and active databaseTriggers and active database
Triggers and active database
 
Deadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddikDeadlock in distribute system by saeed siddik
Deadlock in distribute system by saeed siddik
 
Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Process Management
Process ManagementProcess Management
Process Management
 
debugging - system software
debugging - system softwaredebugging - system software
debugging - system software
 
Processes and Processors in Distributed Systems
Processes and Processors in Distributed SystemsProcesses and Processors in Distributed Systems
Processes and Processors in Distributed Systems
 
Chapter 21 - The Linux System
Chapter 21 - The Linux SystemChapter 21 - The Linux System
Chapter 21 - The Linux System
 
Lecture 1 introduction to parallel and distributed computing
Lecture 1   introduction to parallel and distributed computingLecture 1   introduction to parallel and distributed computing
Lecture 1 introduction to parallel and distributed computing
 
Linux and windows file system
Linux and windows  file systemLinux and windows  file system
Linux and windows file system
 
Unix - An Introduction
Unix - An IntroductionUnix - An Introduction
Unix - An Introduction
 
Context free grammar
Context free grammar Context free grammar
Context free grammar
 
Direct linking loaders
Direct linking loadersDirect linking loaders
Direct linking loaders
 
Minimization of DFA
Minimization of DFAMinimization of DFA
Minimization of DFA
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 

Viewers also liked (20)

Compiler design
Compiler designCompiler design
Compiler design
 
Access to non local names
Access to non local namesAccess to non local names
Access to non local names
 
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
 

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

8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCRashishs7044
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationAnamaria Contreras
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Seta Wicaksana
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyotictsugar
 
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort ServiceCall US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Servicecallgirls2057
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMintel Group
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckHajeJanKamps
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Anamaria Contreras
 
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...ssuserf63bd7
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfJos Voskuil
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menzaictsugar
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfpollardmorgan
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncrdollysharma2066
 
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxContemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxMarkAnthonyAurellano
 
MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?Olivia Kresic
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Kirill Klimov
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03DallasHaselhorst
 

Recently uploaded (20)

8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR8447779800, Low rate Call girls in Rohini Delhi NCR
8447779800, Low rate Call girls in Rohini Delhi NCR
 
PSCC - Capability Statement Presentation
PSCC - Capability Statement PresentationPSCC - Capability Statement Presentation
PSCC - Capability Statement Presentation
 
Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...Ten Organizational Design Models to align structure and operations to busines...
Ten Organizational Design Models to align structure and operations to busines...
 
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCREnjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
Enjoy ➥8448380779▻ Call Girls In Sector 18 Noida Escorts Delhi NCR
 
Investment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy CheruiyotInvestment in The Coconut Industry by Nancy Cheruiyot
Investment in The Coconut Industry by Nancy Cheruiyot
 
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort ServiceCall US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
Call US-88OO1O2216 Call Girls In Mahipalpur Female Escort Service
 
No-1 Call Girls In Goa 93193 VIP 73153 Escort service In North Goa Panaji, Ca...
No-1 Call Girls In Goa 93193 VIP 73153 Escort service In North Goa Panaji, Ca...No-1 Call Girls In Goa 93193 VIP 73153 Escort service In North Goa Panaji, Ca...
No-1 Call Girls In Goa 93193 VIP 73153 Escort service In North Goa Panaji, Ca...
 
Market Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 EditionMarket Sizes Sample Report - 2024 Edition
Market Sizes Sample Report - 2024 Edition
 
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deckPitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
Pitch Deck Teardown: Geodesic.Life's $500k Pre-seed deck
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
 
International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...International Business Environments and Operations 16th Global Edition test b...
International Business Environments and Operations 16th Global Edition test b...
 
Digital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdfDigital Transformation in the PLM domain - distrib.pdf
Digital Transformation in the PLM domain - distrib.pdf
 
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu MenzaYouth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
Youth Involvement in an Innovative Coconut Value Chain by Mwalimu Menza
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
 
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / NcrCall Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
Call Girls in DELHI Cantt, ( Call Me )-8377877756-Female Escort- In Delhi / Ncr
 
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptxContemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
Contemporary Economic Issues Facing the Filipino Entrepreneur (1).pptx
 
Corporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information TechnologyCorporate Profile 47Billion Information Technology
Corporate Profile 47Billion Information Technology
 
MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?MAHA Global and IPR: Do Actions Speak Louder Than Words?
MAHA Global and IPR: Do Actions Speak Louder Than Words?
 
Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024Flow Your Strategy at Flight Levels Day 2024
Flow Your Strategy at Flight Levels Day 2024
 
Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03Cybersecurity Awareness Training Presentation v2024.03
Cybersecurity Awareness Training Presentation v2024.03
 

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.