Changeset 1754

Show
Ignore:
Timestamp:
11/09/08 03:02:45 (2 months ago)
Author:
Chuck.Esterbrook
Message:

Progress towards multiple back-ends.
New BackEnd? and ClrBackEnd? classes.

Location:
cobra/trunk/Source
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/BackEndClr/SharpGenerator.cobra

    r1752 r1754  
    66 
    77## 
     8## BackEnd 
     9## 
     10 
     11class ClrBackEnd 
     12        inherits BackEnd 
     13 
     14        def init(compiler as Compiler) 
     15                base.init(compiler) 
     16 
     17        def generateCode(writeTestInvocation as bool) is override 
     18                .compiler.writeSharp 
     19                if writeTestInvocation 
     20                        .compiler.writeSharpTestInvocation 
     21                        .compiler.compileSharp('/main:RunTests') 
     22                else 
     23                        .compiler.compileSharp 
     24 
     25 
     26## 
    827## Compiler 
    928## 
     
    1534        var _fullExeFileName as String = '' 
    1635        var _moduleFileName_to_sharpToCobraLineNum as Dictionary<of String, Dictionary<of int, int>?>? 
    17  
    18         def generateCode(writeTestInvocation as bool) 
    19                 .writeSharp 
    20                 if writeTestInvocation 
    21                         .writeSharpTestInvocation 
    22                         .compileSharp('/main:RunTests') 
    23                 else 
    24                         .compileSharp 
    2536 
    2637        def writeSharp 
  • cobra/trunk/Source/Compiler.cobra

    r1752 r1754  
    3636 
    3737 
     38class BackEnd 
     39        is abstract 
     40 
     41        def init(compiler as Compiler) 
     42                __compiler = compiler 
     43 
     44        get compiler from __compiler as Compiler 
     45 
     46        def generateCode(writeTestInvocation as bool) is abstract 
     47 
     48 
    3849class Compiler 
    3950        is partial 
     
    4758                * codeMemberStack - methods, properties and inits 
    4859        """ 
     60 
     61        var _backEnd as BackEnd? 
    4962 
    5063        var _nextSerialNum as int is shared 
     
    98111        def init(verbosity as int, initialModules as IList<of Module>?) 
    99112                Node.reset 
     113                _backEnd = ClrBackEnd(this) 
    100114                _nextSerialNum += 1 
    101115                _serialNum = _nextSerialNum 
     
    129143        def toString as String is override 
    130144                return '[.getType.name]([_serialNum])' 
     145 
     146        get backEnd from var 
    131147 
    132148        get verbosity from var 
     
    286302                .bindImp 
    287303                .writeSourceCodeCorrections 
    288                 .generateCode(writeTestInvocation) 
     304                .backEnd.generateCode(writeTestInvocation) 
    289305         
    290306        def testifyFilesNamed(fileNames as IList<of String>, options as OptionValues, resultsWriter as IndentedWriter, verbose as bool)