Computing systems have revolutionized the way we work and play. Computing systems come in a wide variety of forms including laptop computers, desktop computers, personal digital assistants, telephones, and even devices that have not been conventionally associated with computing systems such as, for example, refrigerators and automobiles. Computing systems may even comprise a number of constituent computing systems interconnected via a network. Thus, some computing systems may be small enough to fit in the palm of the hand, while others are spread over much of the globe.
Regardless of their physical form, computing systems are composed of hardware and software. The hardware includes most fundamentally at least one processor and memory. The software includes instructions that may be embodied in the memory or in storage, and that can be accessed and executed by the processor(s) to direct the overall functionality of the computing system. Thus, software is critical in enabling and directing computing system functionality.
Software is often initially drafted using “source code” which represents the desired functionality of the software using a programming language that is more human readable. At some point prior to execution of the software, the software is coverted into a form that is readable by the processor(s) of the computing system. there are two fundamental processes that may cause such a conversion; namely, compilation and interpretation.
In compilation or interpretation, a compiler (in the case of compilation) or an interpreter (in the case of interpretation) accesses source code drafted in accordance with a programming language. If the source code complies with the programming language and includes no obvious functional errors, the compiler or interpreter generates executable code that may be executed by the computing system. If the source code includes errors, the compilation and interpretation functions often generate error messages allowing the author to make corrections to the source code. Compilation occurs often well before the executable code is to be run. The compiler simply generates an executable file, which may later be executed at some appropriate time. Interpretation, on the other hand, occurs at run-time, just prior to the executable code being generated.
Sometimes, interpretable code is embedded within compilable code. In that case, the compilable code is compiled into an executable file, but the interpretable code is not interpreted until run-time. Thus, if there are errors in the interpretable code, the functionality of the entire code may be at risk.
Aspects of embodiments of the present invention relate to the facilitation of error detection in interpretable code prior to run-time of the interpretable code. Upon accessing an interpretable command, corresponding construction rules for the interpretable command are used to formulate a compilable linkable representation of the interpretable command that conforms to the construction rules. Source code may be generated that creates and populates an object that links to the compilable linkable representation upon compilation. If compilation errors occur, those errors may be fixed well in advance of run-time if desired. If there are no compilation errors, the object may be executed to thereby invoke the interpretable command. Thus, rather than waiting until run-time to determine if the invocation of the interpretable command will have errors, the corresponding compilable code may be compiled to discover any errors in advance of run-time.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
In order to describe the manner in which the above-recited and other advantages and features of the invention can be obtained, a more particular description of the invention briefly described above will be rendered by reference to specific embodiments thereof which are illustrated in the appended drawings. Understanding that these drawings depict only typical embodiments of the invention and are not therefore to be considered to be limiting of its scope, the invention will be described and explained with additional specificity and detail through the use of the accompanying drawings in which:
The present invention extends to the facilitation of error detection in the invocation of interpretable code prior to run-time of the interpretable code. First, an example computing system in which the principles of the present invention may operate will be described with respect to
Computing systems are now increasingly taking a wide variety of forms. Computing systems may, for example, be handheld devices, appliances, laptop computers, desktop computers, mainframes, or distributed computing systems. In this description and in the claims, the term “computing system” is defined broadly as including any device or system (or combination thereof) that includes at least one processor, and a memory capable of having thereon computer-executable instructions that may be executed by the processor. The memory may take any form and may depend on the nature and form of the computing system. A computing system may be distributed over a network environment and may include multiple constituent computing systems.
Referring to
As used herein, the term “module” or “component” can refer to software objects or routines that execute on the computing system. The different components, modules, engines, and services described herein may be implemented as objects or processes that execute on the computing system (e.g., as separate threads) as part of a protocol. While the system and methods described herein may be implemented in software, implementations in hardware, and in combinations of software and hardware are also possible and contemplated.
In the description that follows, embodiments of the invention are described with reference to acts that are performed by one or more computing systems. If such acts are implemented in software, one or more processors of the associated computing system that performs the act direct the operation of the computing system in response to having executed computer-executable instructions. An example of such an operation involves the manipulation of data. The computer-executable instructions (and the manipulated data) may be stored in the memory 104 of the computing system 100.
Computing system 100 may also contain communication channels 108 that allow the computing system 100 to communicate with other computing systems over, for example, network 110. Communication channels 108 are examples of communications media. Communications media typically embody computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism and include any information-delivery media. By way of example, and not limitation, communications media include wired media, such as wired networks and direct-wired connections, and wireless media such as acoustic, radio, infrared, and other wireless media. The term computer-readable media as used herein includes both storage media and communications media.
Embodiments within the scope of the present invention also include computer-readable media for carrying or having computer-executable instructions or data structures stored thereon. Such computer-readable media can be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to carry or store desired program code means in the form of computer-executable instructions or data structures and which can be accessed by a general purpose or special purpose computer. When information is transferred or provided over a network or another communications connection (either hardwired, wireless, or a combination of hardwired or wireless) to a computer, the computer properly views the connection as a computer-readable medium. Thus, any such connection is properly termed a computer-readable medium. Combinations of the above should also be included within the scope of computer-readable media.
Computer-executable instructions comprise, for example, instructions and data which cause a general purpose computer, special purpose computer, or special purpose processing device to perform a certain function or group of functions. Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.
A linkable library generator 210 may be hardware, software, or a combination of hardware and software. The linkable library generator 210 is a component that accesses interpretable code 201A, and formulates a compilable linkable representation of the interpretable code 211A (see compilable linkable library 211A) using the associated construction rules 202A for that interpretable code 201A. In this description and in the claims, a “linkable library” is any group of one or more representations of class definitions to which objects may be linked during compilation. The linkable library generator 210 may formulate the compilable linkable library 211A automatically, without human intervention, or may allow user intervention to allow a human to participate in the formulation process. The linkable library generator 201 may comprise one or more modules and/or may include portions of modules that are not involved with the linkable library generation.
First, the linkable library generator 210 accesses an interpretable command (act 301). Referring to
Two examples of interpretable commands will now be given, and will be used throughout this description in order to clarify the broader principles of the present invention. In the first example, referring to hereinafter as the “first example”, the interpretable command takes the following form:
Set-location-path “c:\windows”
This interpretable command may be permissible using a command line tool. The command sets a current location in navigating a directory structure. This command would set the current directory in the c:\windows directory. Instead of being entered into a command line tool, however, the interpretable command may be entered programmatically as a parameter into compilable code. For instance, the Set-location command may be embedded programmatically into a ShellExecute command a follows:
ShellExecute(“Set-location-path ‘c:\windows’”)
As a second example referred to hereinafter as the “second example”, consider the following interpretable code represented as a command line entry:
Get-item-path “c:\windows”
The command gets a listing of all files at the location specified in the path property; in this case, “c:\windows”. Once again, instead of being entered into a command line tool, however, the interpretable command may be entered programmatically as a parameter into compilable code as follows:
ShellExecute(“Get-item-path ‘c:\windows’”)
Conventionally, whether the interpretable command is entered into a command line tool for immediate execution, or whether the interpretable command is embedded programmatically within other source code (e.g., ShellExecute(“. . . ”)), the structure of the interpretable code itself is not evaluated until run-time, just prior to when the interpretable code is executed. Such is the nature of interpretable code. Accordingly, if there were any errors in the interpretable code, they would not be discovered until run-time, even if the interpretable code was embedded in other compilable source code.
In accordance with the principles of the present invention, a compilable linkable representation of the interpretable code itself is formulated. Source code may then be formulated that, when compiled, creates and populates an object that is based on the compilable linkable representation. The compiled and linked object, when executed, invokes the corresponding interpretable comment. If the compilation of the source code fails, then there are more likely errors in the source code that invokes the interpretable command. Those errors may thus be fixed well prior to run-time if desired.
Referring back to
For instance, for the first example of “Set-location-path ‘c:\windows’”, the construction rules for the category of commands for “Set-location” may be accessed. Those construction rules may specify the title of the command (e.g., “Set-location”), as well as list the appropriate titles for any properties of the command (e.g., in this case “path”), perhaps whether or not the properties are mandatory or optional, what would be acceptable value types and/or values (e.g., a text string would be an acceptable value type for the property “path”), and any other construction rules. The construction rules may be represented in human-readable form in which case the construction rules may be evaluated by a human. Alternatively, the construction rules may be represented in computer-readable form such as, for example, in an extensible Markup Language (XML) document that conforms to a schema understood by the computing system.
Similarly, for the second example of “Get-item-path ‘c:\windows’”, the construction rules for the category of commands for “Get-item” may be accessed. Those construction rules may specify the title of the command (e.g., “Get-item”), as well as list the appropriate titles for any properties of the command (e.g., in this case, “path”), perhaps whether or not the properties are mandatory of optional, what would be acceptable value types and/or values (e.g., a text string would be an acceptable value type for the property “path”), and so forth. Once again, the construction rules may be interpreted by a human, and/or may be interpreted by a computer.
Referring back to
Once completed, the compilable linkable representation is structured in accordance with the structural rules associated with the interpretable command. Referring to
At any point prior to run-time, code (e.g., source code) may be formulated (act 305) that, when compiled, (act 306), formulates and populates an object that is based on and links to the compilable linkable representation of the interpretable code. For instance, if the compilable linkable representation was a class definition, then the source code may direct the formulation and population of an object that is an instance of the class defined by the class definition. Referring to
If a compilation error is not detected as a result of the compilation, then the interpretation code is more likely structurally sound and would less likely result in a run-time error when executed. Thus, at any point thereafter, the object may be executed to thereby invoke the interpretable command. If a compilation error is detected as a result of the compilation (act 307), then the source code that created the object that invokes the interpretable command may be altered to correct the error (act 308). Accordingly, rather than wait until run-time to detect and correct an error in the or not embedded within compilable code, any errors may be detected well in advance of run-time. The method 300 of
As a specific example in which the compilable linkable representation of the interpretable command is a class definition, the parameters of a class definition may be generated by taking the parameters of the interpretable command and setting properties of the same name in the class definition. An invoke method may be added to the class definition that takes the properties of the class that have been set and runs the command using the values of the properties as arguments to the class' respective parameters. A class may be instantiated to form an object, sets the properties of the parameters to values that correspond to the values provided in the interpretable command. Then, the invoke method may be called.
Referring now to the first example in which the interpretable command “Set-location-path ‘c:\windows’” is provided to the compilable code generator 210. The compilable code generator may generate the following class as represented using C# skeletal code:
The source code that generates the object that, when executed invokes the interpretable “Set-location-path ‘c:\windows’” command may appear as follows in the first example:
The invoke method, when called, executes the interpretable command from which the compilable linkable representation was generated, and returns the results, if any.
If the source code tries to set a parameter that does not exist, there will be a compile-time error. For example, the second line below would cause a failure when the compiler is run since “FullName” is not a defined property of the class “SetLocationCommand”.
In the second example, the interpretable command “Get-item-path ‘c:\windows’” is converted into the following class as represented by pseudo code:
Source code may be generated that, when compiled and executed, instantiates an object instance of the class. For instance, the source code may appear as follows:
Upon compilation, one would know that the corresponding object would more likely successfully execute the interpretable command associated with the command “Get-item-path ‘c:\windows’” at run-time, since the source code compiled and linked to a class which defines the structure of the associated interpretable command. Now suppose that the drafter had instead drafted the following source code:
Here, the user simply missed typing “p” for “path”. When compiling this source code, the compiler will recognize that the “GetltemCommand” class does not have an “ath” property, thereby failing compilation. Accordingly, after compile-time, the error in the source code may be corrected well in advance of run-time.
The present invention may be embodied in other specific forms without departing from its spirit or essential characteristics. The described embodiments are to be considered in all respects only as illustrative and not restrictive. The scope of the invention is, therefore, indicated by the appended claims rather than by the foregoing description. All changes which come within the meaning and range of equivalency of the claims are to be embraced within their scope.