AdaSlicer: An Ada Program Slicer - PowerPoint PPT Presentation

About This Presentation
Title:

AdaSlicer: An Ada Program Slicer

Description:

... Slicer. Ricky E. Sward. Department of Computer Science. USAF Academy, CO ... One option in our tool is to add SPARK annotation --# global mode variable name ... – PowerPoint PPT presentation

Number of Views:139
Avg rating:3.0/5.0
Slides: 25
Provided by: ricky71
Learn more at: http://www.sigada.org
Category:

less

Transcript and Presenter's Notes

Title: AdaSlicer: An Ada Program Slicer


1
AdaSlicer An Ada Program Slicer
  • Ricky E. Sward
  • Department of Computer Science
  • USAF Academy, CO
  • ricky.sward_at_usafa.edu

A.T. Chamillard Computer Science Department
University of Colorado Spring, CO
chamillard_at_cs.uccs.edu
2
Overview
  • Background
  • Global Variables
  • Identifying Globals
  • Annotating Globals
  • Re-engineering Globals
  • ASIS
  • Conclusions

3
Background
  • Identifying global variables is well-defined
  • Discussed in programming language texts
  • Tools available to identify global variables
  • Useful to identify during re-engineering
  • In SPARK, globals are allowed, must annotate
  • Goal is to convert to parameters

4
Overview
  • Background
  • Global Variables
  • Identifying Globals
  • Annotating Globals
  • Re-engineering Globals
  • ASIS
  • Conclusions

5
Global Variables
  • In Ada, each variable must be declared
  • Scope defines where a variable is visible
  • A and B are local variables

procedure Local is A Integer 0 B
Integer 3 begin A B 2 end Local
6
Global Variables
  • A non-local variable is defined outside scope
  • A global variable is non-local and also visible
    to entire program

procedure Outer_Procedure is A Integer
0 procedure Inner_Procedure is B
Integer 1 begin A A
B end Inner_Procedure begin A A
1 end Outer_Procedure
A is global
7
Global Variables
  • A package variable is in package global scope
  • A package variable is a good global

package One_Global is X Integer 10
procedure Outera (A in out Integer) end
One_Global package body One_Global is
procedure Outera (A in out Integer) is
begin X X 1 end Outera end
One_Global
Package var X
8
Overview
  • Background
  • Global Variables
  • Identifying Globals
  • Annotating Globals
  • Re-engineering Globals
  • ASIS
  • Conclusions

9
Identifying Global Variables
  • Using static analysis consider the scope of
    variables
  • Ignore local variables and parameters

package One_Global is X Integer 10
procedure Outera (A in out Integer) end
One_Global package body One_Global is
procedure Outera (A in out Integer) is
Y Integer 0 procedure Innerb (B
in out Integer) is begin
B X X X 1
end Innerb begin Y A
Innerb(A) end Outera end One_Global
Y is local
A is a parameter
10
Identifying Global Variables
  • Using static analysis consider the scope of
    variables
  • Ignore local variables and parameters

package One_Global is X Integer 10
procedure Outera (A in out Integer) end
One_Global package body One_Global is
procedure Outera (A in out Integer) is
Y Integer 0 procedure Innerb (B
in out Integer) is begin
B X X X 1
end Innerb begin Y A
Innerb(A) end Outera end One_Global
X is global
B is a parameter
11
Identifying Global Variables
  • Access declaration information in symbol table
  • Ok if package variable and procedure in outer
    scope

package One_Global is X Integer 10
procedure Outera (A in out Integer) end
One_Global package body One_Global is
procedure Outera (A in out Integer) is
Y Integer 0 procedure Innerb (B
in out Integer) is begin
B X X X 1
end Innerb begin Y A
Innerb(A) end Outera end One_Global
Symbol Table
Variable Scope Nesting
Y Outera 1
X One_Global 0
... ... ...
12
Overview
  • Background
  • Global Variables
  • Identifying Globals
  • Annotating Globals
  • Re-engineering Globals
  • ASIS
  • Conclusions

13
Annotating Global Variables
  • One option in our tool is to add SPARK annotation
  • -- global ltmodegt ltvariable namegt

package One_Global is X Integer 10
procedure Outera (A in out Integer) end
One_Global package body One_Global is
procedure Outera (A in out Integer) is
Y Integer 0 procedure Innerb (B
in out Integer) is -- global in out
X begin B X
X X 1 end Innerb
begin Y A Innerb(A)
end Outera end One_Global
14
Annotating Global Variables
  • To determine mode of global, look at DEF and REF

package One_Global is X Integer 10
procedure Outera (A in out Integer) end
One_Global package body One_Global is
procedure Outera (A in out Integer) is
Y Integer 0 procedure Innerb (B
in out Integer) is -- global in out
X begin B X
X X 1 end Innerb
begin Y A Innerb(A)
end Outera end One_Global
REF set B, X
DEF set B, X
15
Overview
  • Background
  • Global Variables
  • Identifying Globals
  • Annotating Globals
  • Re-engineering Globals
  • ASIS
  • Conclusions

16
Re-engineering Global Variables
  • Add global as formal parameter
  • Add global as actual parameter in call
  • Use the global definition of the variable to
    build the parameter
  • Use the DEF and REF set to build the mode
  • Appears only in REF, build as in parameter
  • Appears only in DEF, build as out parameter
  • Appears in both DEF and REF, build as in out
    using conservative approach
  • For example...

17
Re-engineering Global Variables
package One_Global_New is X Integer
10 procedure Outera (A in out
Integer) end One_Global package body
One_Global_New is procedure Outera (A in
out Integer) is Y Integer 0
procedure Innerb ( B in out
Integer X in out Integer ) is
begin B X
X X 1 end Innerb begin
Y A Innerb(B gt A, X gt
X) end Outera end One_Global_New
Add as formal
Add as actual
18
Re-engineering Global Variables
  • What if a global is nested deeper?
  • May need to change two or more procedures
  • Add global as formal parameter
  • Add global as actual parameter
  • Check to see if actual is global
  • For example...

19
Re-engineering Global Variables
package body Two_Globals is procedure Outera (
A in out Integer ) is procedure Innerb
( B in out Integer ) is
procedure Innerc ( C in out
Integer ) is begin C Y
Y Y 1 end Innerc
begin B B 1 Innerc(C gt
B) end Innerb begin Innerb(B gt
A) end Outera end Two_Globals
Y is a global
20
Re-engineering Global Variables
package body Two_Globals_new is procedure
Outera ( A in out Integer ) is
procedure Innerb ( B in out
Integer) is procedure Innerc (
C in out Integer Y in out
Integer ) is begin C Y
Y Y 1 end Innerc
begin B B 1 Innerc(C gt
B, Y gt Y) end Innerb begin
Innerb(B gt A) end Outera end
Two_Globals_new
Need Y here
Y is a global
21
Re-engineering Global Variables
package body Two_Globals_new is procedure
Outera ( A in out Integer ) is
procedure Innerb ( B in out
Integer Y in out Integer) is
procedure Innerc ( C in out
Integer Y in out Integer ) is
begin C Y Y
Y 1 end Innerc begin
B B 1 Innerc(C gt B, Y gt Y)
end Innerb begin Innerb(B gt A, Y gt
Y) end Outera end Two_Globals_new
Add Y as formal
Add Y as formal
Add Y as actual
Add Y as actual
22
Overview
  • Background
  • Global Variables
  • Identifying Globals
  • Annotating Globals
  • Re-engineering Globals
  • ASIS
  • Conclusions

23
Ada Semantic Interface Specification (ASIS)
  • Procedures for accessing Ada program structure
  • Used ASIS 3.15a1 GNAT Ada Compiler 3.15a1
  • Reasonable learning curve
  • Examples provided with ASIS are great
  • Very powerful tool

24
Conclusions
  • Need to develop a graphical user interface
  • Target re-engineering efforts
  • Also automatic refactoring applications
Write a Comment
User Comments (0)
About PowerShow.com