← Back to Patent Explorer
US5835771A Expired / Lapsed US ⏱️ 0.0 years remaining

Method and apparatus for generating inline code using template metaprograms

Assignee: Rogue Wave Software Inc
•
Filing: 1995-06-07
•
Granted: 1998-11-10
•
Expires: 2015-06-07
📄 Original PDF 🌐 Google Patents 🔄 Sync Now

Abstract

Abstract The present invention provides the capability to generate customized, inlined code or expression objects using template metaprograms. The code or expression object is created at compile time using template parameters, if specified. At compile time, these parameters are used to determine the customized, inline code that is generated by the compiler. A general algorithm is used to convert algorithms into inline pieces of code. An algorithm, or program code segment, is selected for customization. A grammar is written to define the algorithm. A grammar is comprised of a set of production rules. Production rules contain symbols of the grammar. A symbol can be a terminal or non-terminal symbol. A production rule further includes parameters that can be used to further customize an instantiation of a template metaprogram. The algorithm is expressed using the production rules that comprise the grammar. Each production rule is translated into a template class or a specialization. A template metaprogram can further comprise template parameters. At compile time, the compiler uses the template metaprogram reference including template parameters specified to generate code. The template metaprogram that is referenced by the program code is used as a blueprint for the code that is generated by the compiler. The code generated by the compiler is customized, inlined code. Further, the process for creating and generating customized, inlined code provides for the creation and manipulation of objects that encapsulate expressions. Customized, inlined code can replace less efficient code thereby achieving increased run time efficiency. Code generation is done using the end user's compiler.

Inventors

  • 👤 Todd Veldhuizen

Bibliographic Details

Application Number —
Jurisdiction US
Data Source google_patents
Last Synchronized 2026-11-07 14:10
CPC Classifications
G; G06; G06F; G06F8/00; G06F8/40; G06F8/41; G06F8/42; G06F8/423; G06F8/30; G06F8/43; G06F8/436; G06F8/437; G06F8/44; G06F8/443; G06F8/4441; G06F8/4443

Claims Analysis

Total Claims: 17
Claim 1
Independent Claim 121 words
A template creation method for generating program code in a computer system comprising the steps of: identifying one or more steps to be performed in said program code; defining a grammar to represent said one or more steps; defining a template using said grammar, said template including a plurality of template parameters; replacing said one or more steps with a reference to said template in said program code, said reference including values for said template parameters; creating replacement code for said one or more steps in said program code at compile time, said replacement code based on said template parameter values and created using said template and said template parameter values; replacing said reference with said replacement code at compile time.
Claim 2
Dependent Claim 121 words
A template creation method for generating program code in a computer system comprising the steps of: identifying one or more steps to be performed in said program code; defining a grammar to represent said one or more steps; defining a template using said grammar, said template including a plurality of template parameters; replacing said one or more steps with a reference to said template in said program code, said reference including values for said template parameters; creating replacement code for said one or more steps in said program code at compile time, said replacement code based on said template parameter values and created using said template and said template parameter values; replacing said reference with said replacement code at compile time.
Claim 3
Dependent Claim 12 words
The method of claim 1 wherein said compiler is a C++ compiler.
Claim 4
Dependent Claim 18 words
The method of claim 1 wherein said grammar is comprised of a plurality of terminal and non-terminal symbols.
Claim 5
Dependent Claim 19 words
The method of claim 3 wherein each non-terminal symbol is defined using a plurality of terminal and non-terminal symbols.
Claim 6
Dependent Claim 15 words
The method of claim 3 wherein each terminal symbol is defined using programming language constructs.
Claim 7
Dependent Claim 12 words
The method of claim 1 wherein said template defines a template class.
Claim 8
Dependent Claim 11 words
The method of claim 1 wherein said template defines a specialization.
Claim 9
Dependent Claim 23 words
The method of claim 1 wherein said one or more steps is an n-repetition loop that repeats a block of statements n times.
Claim 10
Dependent Claim 29 words
The method of claim 8 wherein said replacement code comprises n versions of said block of statements, each of said n versions executes one iteration of said n-repetition loop.
Claim 11
Independent Claim 134 words
A method for generating optimized expression objects comprising the steps of: identifying one or more steps to be performed in said program code; defining a grammar to represent said one or more steps; defining a template using said grammar, said template including a plurality of template parameters; replacing said one or more steps with a reference to said template in said program code, said reference including values for said template parameters, one of said template parameters being an expression; parsing said expression; inferring an expression type for said expression; creating replacement code for said one or more steps in said program code at compile time, said replacement code based on said template parameter values and created using said template and said template parameter values; replacing said reference with said replacement code at compile time.
Claim 12
Independent Claim 134 words
A method for generating optimized expression objects comprising the steps of: identifying one or more steps to be performed in said program code; defining a grammar to represent said one or more steps; defining a template using said grammar, said template including a plurality of template parameters; replacing said one or more steps with a reference to said template in said program code, said reference including values for said template parameters, one of said template parameters being an expression; parsing said expression; inferring an expression type for said expression; creating replacement code for said one or more steps in said program code at compile time, said replacement code based on said template parameter values and created using said template and said template parameter values; replacing said reference with said replacement code at compile time.
Claim 13
Dependent Claim 20 words
The method of claim 10 further including the step of instantiating an expression object for said expression at run time.
Claim 14
Dependent Claim 11 words
The method of claim 11 wherein said expression object includes code.
Claim 15
Dependent Claim 15 words
The method of claim 11 wherein said replacement code uses said expression object at runtime.
Claim 16
Dependent Claim 13 words
The method of claim 10 wherein said replacement code includes said expression type.
Claim 17
Dependent Claim 17 words
The method of claim 10 wherein said template parameters includes a template parameter for said expression type.

References Cited (Backward Citations)

US3898438A Cited
US4956800A Cited
US5280617A Cited
US5237691A Cited
US5481708A Cited

USPTO Annuity & Maintenance Windows

Annuity Stage Window Opens Payment Deadline Surcharge Period Until Estimated Fee Status
3.5 Years (Year 4) 2001-11-09 2002-05-11 2002-11-10 $2000.00 Window Closed / Lapsed
7.5 Years (Year 8) 2005-11-09 2006-05-11 2006-11-10 $3760.00 Window Closed / Lapsed
11.5 Years (Year 12) 2009-11-09 2010-05-11 2010-11-10 $7700.00 Window Closed / Lapsed

Assigned Categories & Tags

No categories assigned to this patent yet.

Assign Category Tag