API's that Suck

January 29, 2011

Foundry – Goal: Build a compiler that will print “Hello World”

Filed under: Uncategorized — Grauenwolf @ 8:52 pm

The goal is to create a CLR compiler for Foundry, my research project for this year.

Source File

Program Test1
    References
    mscorlib
    End References
End Program
Imports 
    System

End Imports
Function Main 
    Let message = “Hello World”
    Console.WriteLine(message)
End Function

Tasks

  1. File level parser. This needs to understand import statements and function blocks, but not the contents of functions.
  2. Level 1 symbol table. Requires reflecting over core assemblies
  3. Parsing let-style variable statements. This will require an abstract syntax tree with nodes that can later be annotated with type information.
  4. Level 3 symbol table for storing locals. (Level 2 is for class-level symbols, which donof’t apply to free functions. Levels 4+ are for nested structures)
  5. Parsing simple function calls.
  6. Emitting a free function as IL code.

Abstract Syntax for File-Level Parser

<Import> <Identifier>

<Function> <Identifier “Main”>

<Function-Body>

<End Function>

The file-level parser doesn’t concern itself with the contents of functions. This allows us some degree of error recovery, as one bad function will not prevent us from parsing the remainder of the file.

Proposed object model (using XML notation because I don’t feel like drawing diagrams tonight)

<File>

    <Imports><Import Namespace=”xxx”></Imports>

    <Free-functions>

        <Function Name=”Main” />

    </Free-functions>

</File>

Deadline: My self-imposed deadline is March 12, which allows for weekly milestones.

January 3, 2011

The Story of UltraBase: Chapter 4

Filed under: UltraBase — Grauenwolf @ 8:35 pm

Fred didn’t like project references. In fact, he absolutely hated project references. So when he started on the middle tier he made sure his team only built their project using assembly references. Moreover, those assembly references all had to point to the golden location, a shared drive where releasable code was posted.

In some cases this makes a lot of sense. Especially when the purpose of each assembly is clearly delineated and low level assemblies are completely unaware of the assemblies that use them. But this situation is a little bit different.

To start with, you need to know about the six assemblies that make up the middle tier. From highest to lowest they are the Adapter, Core, BusinessLogic, DAL, Config, and Data libraries. Each library builds upon the ones before it. For example, in order to add a UserSearch function to the Adapter and BusinessLogic layer you must first add a UserSearch entry to the DataMapperEnum found in the Data Library. And all of the parameters must exist on a UserSearchInput object found in the DAL assembly.

I’ll walk you through the process. First get the UserSearch stored procedure from the database team. Then enter in its name, parameters, and output columns into the UltraBase configuration database. Since databases don’t really work with source control, make sure you kick off a backup.

Open up the Data libraries solution and update the version number. Kick off the code generation process, and then check everything in.

Once the build machine is done, copy the new version of Data into the golden location. Then open config library and update its version number. Change its reference to point to the new version of Data, regenerate the code, and check it in.

Once the build machine is done, copy the new version of Config into the golden location. Then open DAL solution and update its version number. Change its reference to point to the new version of Config and Data. Regenerate the code and check it in.

Once the build machine is done, copy the new version of DAL into the golden location. Then open BusinessLogic solution and update its version number. Change its reference to point to the new version of DAL, Config, and Data. Regenerate the code and check it in.

Once the build machine is done, copy the new version of BusinessLogic into the golden location. Then open Core solution and update its version number. Change its reference to point to the new version of BusinessLogic, DAL, Config, and Data. Regenerate the code and check it in.

Once the build machine is done, copy the new version of Core into the golden location. Then open Adapter solution and update its version number. Change its reference to point to the new version of Core, BusinessLogic, DAL, Config, and Data. Regenerate the code and check it in.

Once the build machine is done, you can deploy the new version of the middle tier.

Once the build machine is done, copy the new version of Core into the golden location. Then open Adapter solution and update its version number. Change its reference to point to the new version of Core, BusinessLogic, DAL, Config, and Data. Regenerate the code and check it in.

With all this done, you can change your website code to use the middle tier.

Create a free website or blog at WordPress.com.