Patent Document ID: 9823913
Application ID: 14957626

Base Claim:
1. A computer implemented method of detecting global variables in JAVASCRIPT code, and adding local variables in place of said global variables, comprising: receiving by a processor a JAVASCRIPT code containing at least one of a plurality of globally defined functions; generating by the processor at least one call flow graph for each one of said at least one of globally defined functions; generating by the processor an inter-procedural control flow graph for each one of said call flow graph; generating by the processor an inter-procedural dominator graph for each one of said inter-procedural control flow graph; identifying by the processor each of referenced global variables within each of said inter-procedural dominator graph and determining a JAVASCRIPT scope of each of referenced global variables; identifying by the processor at least one of: one or more confined global variables which receive a value within a first JAVASCRIPT scope of each referenced global variable wherein said value is not referenced outside of said first JAVASCRIPT scope, and one or more repeating global variables accessed repeatedly within a second JAVASCRIPT scope of each referenced global variable; and automatically adding by the processor local variables in place of at least one of said confined global variables and said repeating global variables.

---

Claim 11:
11. The method of claim 1 , further comprising defining a new local variable within said second JAVASCRIPT scope of said repeating global variables, copying a value of said repeating global variables into said new local variable prior to multiple references to said repeating global variables, replacing said repeating global variables with said new local variable within said second JAVASCRIPT scope, and copying a value of said new local variable into said repeating global variables subsequent to said multiple references.