Determining dependencies during macro expansion

In certain embodiments, a parser parses a formula to yield one or more functions, at least one function comprising a dependent value of a dependent object. One or more macro handlers configured to execute the functions are determined. At least one macro handler is instructed to register with one or more dominant objects on behalf of the dependent object, where the dominant objects are used to evaluate the dependent value.

TECHNICAL FIELD

This invention relates generally to the field of computing technology and more specifically to determining dependencies during macro expansion.

BACKGROUND

A modeling product may model a system. The modeling product may use objects to store information about the system. Macro expansion language may be used to calculate the value of an object based on values of one or more other objects. If calculated values are not stored in the model, the values may be calculated as needed.

SUMMARY OF THE DISCLOSURE

In accordance with the present invention, disadvantages and problems associated with previous techniques for determining dependencies may be reduced or eliminated.

In certain embodiments, a parser parses a formula to yield one or more functions, at least one function comprising a dependent value of a dependent object. One or more macro handlers configured to execute the functions are determined. At least one macro handler is instructed to register with one or more dominant objects on behalf of the dependent object, where the dominant objects are used to evaluate the dependent value.

Certain embodiments of the invention may provide one or more technical advantages. A technical advantage of one embodiment may be that a parser can instruct a macro handler to register with one or more dominant objects on behalf of a dependent object. The registration allows a dominant object to notify the dependent object of a change in the dominant object.

DETAILED DESCRIPTION OF THE DRAWINGS

Embodiments of the present invention and its advantages are best understood by referring toFIGS. 1 through 5of the drawings, like numerals being used for like and corresponding parts of the various drawings.

A modeling product may model a system. The modeling product may use objects to store information about the system. In certain situations, a dependent value of a dependent object may depend on one or more dominant values of one or more dominant objects. For example, the dominant values may be needed to calculate the dependent value. Accordingly, a change in a dominant value may yield a change in a dependent value.

Certain known techniques may be used to notify dependent objects of a change in a dominant value. According to certain known techniques, a dependent object may register with a dominant object to receive a notification of changes. In these techniques, the dependent object needs to identify the dominant objects in order to register with them. The dependent object may examine formulas that it has to identify the dominant objects. To examine formulas, the dependent object typically has to perform the operations of a parser and a macro handler. This, however, entails that one object duplicates the operations another object, which breaks encapsulation.

According to other known techniques, heuristic rules derived from real world patterns of dependencies are used to write notification operations for a computer program. For example, a change in a name of a table often changes the names of the columns of the table, so code may be written that instructs a table object to notify a column object of table name changes. The heuristic rules, however, may not capture all dependencies of a computer program. Moreover, the heuristic rules may include dependencies that are not present in the computer program.

FIG. 1illustrates an example of a system10that may be used to determine dependencies during macro expansion. In certain embodiments, system10may include a parser that can instruct a macro handler to register with one or more dominant objects on behalf of a dependent object. The registration allows a dominant object to notify the dependent object of a change in the dominant object.

In the illustrated example, system10includes one or more interfaces (IFs)20, logic22, and one or more memories24. Logic22includes one or more processors26and applications30, such as a parser32and one or more macro handlers34. Memories24store applications30and one or more objects40.

Parser32parses the source code of a computer program language to create an internal representation of the code. In certain embodiments, parser32parses a formula to yield one or more functions and determines one or more macro handlers34configured to execute the functions. Parser32instructs the macro handlers34to register with one or more dominant objects on behalf of one or more dependent objects.

Parser32may update the registrations when a next formula (such as an updated formula or a new formula) is received. For example, parser32parses the next formula to yield a next function. Parser32determines a next macro handler34configured to execute the next function and instructs the next macro handler34to register with a next dominant object on behalf of a next dependent object. The next dominant object may be used to evaluate the next dependent object. Parser32may also instruct a macro handler34to remove the registrations of dominant objects of outdated formulas.

Macro handler34executes functions. For example, a macro handler34may obtain input for a function and then apply operators to the input. In certain situations, the input may include dominant values from dominant objects. Any suitable macro handler may be used, for example, a macro handler as described in U.S. Pat. No. 7,711,685 “Method and System for an Extensible Macro Language”, which is incorporated herein by reference.

In certain embodiments, a macro handler34receives a register instruction to register a dominant object of a formula on behalf of a dependent object. Macro handler identifies the dominant object of the formula and registers with the dominant object on behalf of the dependent object to allow the dominant object to notify the dependent object of a change in the dominant object.

FIG. 2illustrates an example of a representation of a sample table40, andFIG. 3illustrates an example of a tree50of objects of table40. In the example, object tree50includes a dominant object52and one or more dependent objects54(54a-d). A dependent object54depends on a dominant object52. In certain embodiments, the value of a dependant object may depend on one or more values of one or more dominant objects. In the embodiments, the formula for calculating the dependent value may use dominant values as input. For example, the formula may include a function that indicates a dominant value to be used as input and that may be used to obtain the dominant value. The formula may also include operators and strings that may be used to calculate the dependent value.

In the illustrated example, the dominant object52is the table, and the dependent objects54(54a-d) are columns of the table. The names of the dependent objects depend on the name of the dominant object52. The formulas for calculating the column names have the format: TableName( )+string, where TableName( ) is a function that may be used to obtain the table name, + is an operator for concatenation, and string is “_ID” for column name54a, “_NAME” for column name54b, “_ADDRESS” for column name54c, and “_PHONE” for column name54d. In the example, the table name is CUSTOMER, so the column names are CUSTOMER_ID, CUSTOMER_NAME, CUSTOMER_ADDRESS, and CUSTOMER_PHONE.

FIG. 4illustrates an example of a method for calculating a dependent value. In the example, an external component56requests a dependent value from dependent object54at step110. External component56may be a component that is separate from applications30, and may be an interface20, such as a display. The dependent object sends the formula for the dependent value to parser32at step112. Parser32detects a function and selects the appropriate macro handler34to execute the function at step114. Macro handler34determines that dominant values are needed and then requests that the dependent object provides the dominant object at step116.

Macro handler32asks the dominant object52for its dominant value at step118. Macro handler34then returns the dominant value to parser32at step120. Parser inserts the dominant value into the formula and returns the dependent value to dependent object54at step122. Dependent object54returns the dependent value to external component56at step110, and the method terminates.

In certain situations, dependent object54may notify external component56of changes in a dependent value. A change in a dominant value may change a dependent value, so dependent object54may be notified of dominant value changes in order to notify external component56of changes in a dependent value. An example of a method for notifying dependent object54is described with reference toFIG. 5.

FIG. 5illustrates an example of a method for determining dependencies during macro expansion. In the example, when a formula is placed into an object, notification operations are set up. A notification operation instructs a dominant object to notify dependent objects of changes in dominant values.

In the example, dependent object54requests that parser32parses a formula at step70and provides parser32with the address of dependent object54. Parser32requests that macro handlers34execute functions of the formula at step72. Macro handler34registers with dominant objects52on behalf of dependent objects54for dependencies of the functions at step74. The registration instructs dominant objects52to send notification of any changes in dominant values to the dependent object54's address. Dominant object52notifies dependent object54of changes in dominant values at step76. Dependent object54may then notify an external component of the changes.

If the formula is changed, the dependencies may be updated in the following manner. Parser32evaluates the old formula and instructs macro handlers34to remove registrations associated with the old formula. Parser32evaluates the new formula and instructs macro handlers34to add registrations for the new formula.

In certain embodiments, the method may resolve difficulties of breaking encapsulation and/or runtime extensibility. Parser32performs a parsing operations, and macro handlers34execute the functions, so encapsulation is maintained. In addition, new functions can still perform registrations with the address of the dependent object, so no new navigation algorithms are required.

Modifications, additions, or omissions may be made to the systems and apparatuses disclosed herein without departing from the scope of the invention. The components of the systems and apparatuses may be integrated or separated. Moreover, the operations of the systems and apparatuses may be performed by more, fewer, or other components. For example, the operations of parser32and macro handler34may be performed by one component, or the operations of parser32may be performed by more than one component. Additionally, operations of the systems and apparatuses may be performed using any suitable logic comprising software, hardware, and/or other logic. As used in this document, “each” refers to each member of a set or each member of a subset of a set.

In certain embodiments, an entity that performs a first step that precedes (such as leads to) a second step may be regarded as facilitating the second step. For example, if an entity performs step A that precedes step B, the entity also facilitates step B. In certain embodiments, a first entity that performs a first step that precedes a second step that may be performed by a second entity may be regarded as allowing the second entity to perform the second step. For example, if a first entity performs step A that precedes step B that may be performed by a second entity, the first entity also allows the second entity to perform step B.

A component of the systems and apparatuses disclosed herein may include an interface, logic, memory, and/or other suitable element. An interface receives input, sends output, processes the input and/or output, and/or performs other suitable operation. An interface may comprise hardware and/or software.

Logic performs the operations of the component, for example, executes instructions to generate output from input. Logic may include hardware, software, and/or other logic. Logic may be encoded in one or more tangible media and may perform operations when executed by a computer. Certain logic, such as a processor, may manage the operation of a component. Examples of a processor include one or more computers, one or more microprocessors, one or more applications, and/or other logic.

In particular embodiments, the operations of the embodiments may be performed by one or more computer readable media encoded with a computer program, software, computer executable instructions, and/or instructions capable of being executed by a computer. In particular embodiments, the operations of the embodiments may be performed by one or more computer readable media storing, embodied with, and/or encoded with a computer program and/or having a stored and/or an encoded computer program.

A memory stores information. A memory may comprise one or more non-transitory, tangible, computer-readable, and/or computer-executable storage media. Examples of memory include computer memory (for example, Random Access Memory (RAM) or Read Only Memory (ROM)), mass storage media (for example, a hard disk), removable storage media (for example, a Compact Disk (CD) or a Digital Video Disk (DVD)), database and/or network storage (for example, a server), and/or other computer-readable medium.

Components of the systems and apparatuses may be coupled by any suitable communication network. A communication network may comprise all or a portion of one or more of the following: a public switched telephone network (PSTN), a public or private data network, a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a local, regional, or global communication or computer network such as the Internet, a wireline or wireless network, an enterprise intranet, other suitable communication link, or any combination of any of the preceding.