Inferring Function Calls In An Ambiguous Language Computer Program
Abstract
An ambiguous usage of a name in a statement of a computer program is resolved at least partially by adding to an entry statement thereof a definition that includes the ambiguously used name followed by constructing a definition-use graph, followed by checking whether or not an edge from the added definition reaches the statement containing the ambiguously used name. If all edges into the ambiguous statement are from the added definition, then the name is deemed to be a function call. If all edges into the ambiguous statement are not from the added definition, then the name is deemed to be a memory access. If some edges into the ambiguous statement are from the added definition but other edges are not, then the statement is flagged as a dual usage.
Claims
exact text as granted — not AI-modified1 . A method executed in a computer for processing a computer program expressed in a high level language, the method comprising:
translating said computer program into an intermediate representation; wherein said intermediate representation models at least one statement in said computer program, said at least one statement comprising an ambiguous usage of a name as both a function call and an memory access; constructing a graph of definitions and uses for a plurality of names including said name in said computer program, by adding a plurality of edges such that each edge connects a node in the intermediate representation, either directly or indirectly, to another node in the intermediate representation; identifying usage of said name in said statement as a function call, based on at least one edge in said graph reaching said statement; and performing a transformation on said intermediate representation, based on said graph, into another intermediate representation in memory.
2 . The method of claim 1 wherein:
said transformation comprises variable renaming.
3 . The method of claim 1 wherein:
said transformation comprises dead code elimination.
4 . The method of claim 1 wherein:
said transformation comprises constant propagation.
5 . The method of claim 1 further comprising:
performing lexical analysis on said computer program based on a grammar of said high level language; and applying at least one predetermined rule, based on said lexical analysis, to check if said name can be definitively determined to be one of (memory access and function call).
6 . The method of claim 5 wherein application of said predetermined rule comprises determining that said name is definitively a function call by:
checking if said name is not explicitly defined in any statement of said computer program.
7 . The method of claim 5 wherein application of said predetermined rule comprises determining that said name is definitively a function call by:
checking if said name used as a multi-return function, invoked in said statement.
8 . The method of claim 1 further comprising:
adding to said computer program, a temporary definition comprising said name, said adding being performed prior to said constructing; and checking if the temporary definition reaches said statement along each control flow path and if true then performing said identifying.
9 . The method of claim 8 further comprising:
automatically propagating said temporary definition along each control flow path that starts from said temporary definition in said computer program until a permanent definition of said name is reached.
10 . The method of claim 9 wherein during said automatically propagating:
said temporary definition reaches said statement along a first control flow path; and said temporary definition reaches said permanent definition in another statement along a second control flow path; and wherein said another statement occurs in a sequence of statements between said temporary definition and said statement.
11 . The method of claim 9 wherein during said automatically propagating:
said temporary definition reaches said statement along a first control flow path; said temporary definition reaches said permanent definition in another statement along a second control flow path; and said permanent definition reaches said statement from said another statement along a continuation of the second control flow path.
12 . The method of claim 1 wherein:
said transformation is performed prior to said identifying.
13 . The method of claim 1 wherein:
said transformation is performed after said identifying.
14 . A method executed in a computer for processing a computer program expressed in a high level language, the method comprising:
translating said computer program into an intermediate representation; wherein said intermediate representation models at least one statement in said computer program, said at least one statement comprising an ambiguous usage of a name as both a function call and an memory access; constructing a graph of definitions and uses for a plurality of names including said name in said computer program, by adding a plurality of edges such that each edge connects a node in the intermediate representation, either directly or indirectly, to another node in the intermediate representation; identifying usage of said name in said statement as a function call, based on finding no permanent definition of said name in said computer program; and performing a transformation on said intermediate representation, based on said graph, into another intermediate representation in memory.
15 . The method of claim 14 wherein:
said transformation comprises variable renaming.
16 . The method of claim 14 wherein:
said transformation comprises dead code elimination.
17 . The method of claim 14 wherein:
said transformation comprises constant propagation.
18 . The method of claim 14 further comprising:
performing lexical analysis on said computer program based on a grammar of said high level language; and applying at least one predetermined rule, based on said lexical analysis, to check if said name can be definitively determined to be one of (memory access and function call).
19 . The method of claim 14 wherein:
said transformation is performed prior to said identifying.
20 . A computer programmed to process a computer program, the computer being programmed to:
translate the computer program into an intermediate representation, wherein said intermediate representation models at least one statement in said computer program, said at least one statement comprising an ambiguous usage of a name as both a function call and an memory access; construct a graph of definitions and uses for a plurality of names including said name in said computer program, by adding a plurality of edges such that each edge connects a node in the intermediate representation, either directly or indirectly, to another node in the intermediate representation; identify usage of said name in said statement as a function call, based on said graph; and perform a transformation on said intermediate representation, based on said graph, to generate another intermediate representation in a memory.Join the waitlist — get patent alerts
Track US2008216061A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.