-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://svn.codehaus.org/boo/trunk@480 2c1201b4-01cd-e047-a400-b836ae1fbc61
- Loading branch information
Showing
19 changed files
with
215 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace BooInBoo.Tests | ||
|
||
import System.IO | ||
import NUnit.Framework | ||
import BooInBoo | ||
import BooInBoo.Pipelines | ||
import BooInBoo.PipelineSteps | ||
|
||
abstract class AbstractCompilerFixture: | ||
virtual def GetTestCasePath(): | ||
return Path.GetDirectoryName(typeof(AbstractCompilerFixture).Assembly.Location) | ||
|
||
virtual def CreatePipeline() as CompilerPipeline: | ||
pass | ||
|
||
[TestFixture] | ||
class CompilerFixture(AbstractCompilerFixture): | ||
override def CreatePipeline(): | ||
pipeline = CompileToFilePipeline() | ||
pipeline.Add(Run()) | ||
return pipeline | ||
|
||
override def GetTestCasePath(): | ||
return Path.Combine(super(), "compilation") | ||
|
||
[TestFixture] | ||
class BooInBooSemanticsTestCase(AbstractCompilerFixture): | ||
override def CreatePipeline(): | ||
pipeline = CompilePipeline() | ||
pipeline.Add(PrintBoo()) | ||
return pipeline | ||
|
||
override def GetTestCasePath(): | ||
return Path.Combine(super(), "semantics") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace BooInBoo | ||
|
||
import System | ||
|
||
interface ICompilerComponent(System.IDisposable): | ||
def Initialize(context as CompilerContext) | ||
|
||
interface ICompilerPipelineStep(ICompilerComponent): | ||
def Run() | ||
|
||
interface ICompilerInput: | ||
Name as string: | ||
get | ||
|
||
def Open() as System.IO.TextReader | ||
|
||
interface ICompilerResource: | ||
Name as string: | ||
get | ||
Description as string: | ||
get | ||
def WriteResources(writer as System.Resources.IResourceWriter) | ||
|
||
class AbstractCompilerPipelineStep(ICompilerPipelineStep): | ||
_context as CompilerContext | ||
|
||
def Initialize(context as CompilerContext): | ||
_context = context | ||
|
||
def Dispose(): | ||
_context = null | ||
|
||
CompileUnit: | ||
get: | ||
return _context.CompileUnit | ||
|
||
class CompilerPipeline: | ||
_steps = [] | ||
|
||
def Add([required] step as ICompilerPipelineStep): | ||
pass | ||
|
||
virtual def Initialize(): | ||
pass | ||
|
||
class CompilerContext: | ||
CompileUnit as Boo.Lang.Compiler.Ast.CompileUnit: | ||
get: | ||
return null | ||
|
||
class Compiler: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace BooInBoo.PipelineSteps | ||
|
||
import BooInBoo | ||
|
||
enum BindingType: | ||
CompileUnit | ||
Module | ||
Class | ||
Interface | ||
Enum | ||
Callable | ||
Constructor | ||
Method | ||
Field | ||
Property | ||
Namespace | ||
|
||
interface IBinding: | ||
ParentNamespace as INamespace: | ||
get | ||
BindingType as BindingType: | ||
get | ||
|
||
interface INamespace(IBinding): | ||
def Resolve(name as string) as IBinding | ||
|
||
interface INameResolutionService(ICompilerComponent): | ||
def EnterNamespace(ns as INamespace) | ||
def LeaveNamespace() | ||
def Resolve(name as string) as List | ||
|
||
class CreateBindings(AbstractCompilerPipelineStep): | ||
|
||
override def Run(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace BooInBoo.PipelineSteps | ||
|
||
import BooInBoo | ||
import Boo.Lang.Compiler.Ast | ||
import Boo.Lang.Compiler.Ast.Visitors | ||
|
||
class PrintBoo(AbstractCompilerPipelineStep): | ||
|
||
override def Run(): | ||
BooPrinterVisitor(System.Console.Out).Switch(self.CompileUnit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace BooInBoo.PipelineSteps | ||
|
||
import BooInBoo | ||
|
||
class Run(AbstractCompilerPipelineStep): | ||
|
||
override def Run(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namespace BooInBoo.Pipelines | ||
|
||
import BooInBoo | ||
|
||
class ParsePipeline(CompilerPipeline): | ||
static _defaultParserStepType = System.Type.GetType("Boo.AntlrParser.BooParsingStep, Boo.AntlrParser", true) | ||
|
||
override def Initialize(): | ||
Add(_defaultParserStepType()) | ||
|
||
class CompilePipeline(ParsePipeline): | ||
override def Initialize(): | ||
pass | ||
/* | ||
pipeline.Add(IntroduceGlobalNamespaces()) | ||
pipeline.Add(IntroduceBindingService()) | ||
pipeline.Add(BindNamespaces()) | ||
pipeline.Add(IntroduceNameResolutionService()) | ||
pipeline.Add(BindAndApplyAttributes()) | ||
pipeline.Add(ExpandMacros()) | ||
pipeline.Add(IntroduceModuleClasses()) | ||
pipeline.Add(NormalizeTypeMembers()) | ||
pipeline.Add(NormalizeStatementModifiers()) | ||
pipeline.Add(BindTypeDefinitions()) | ||
pipeline.Add(BindTypeMembers()) | ||
pipeline.Add(CheckTypeMemberDeclarations()) | ||
pipeline.Add(PreOptimizeExpressions()) | ||
pipeline.Add(IntroduceCallableResolutionService()) | ||
pipeline.Add(ProcessMethodBodies()) | ||
pipeline.Add(ProcessGenerators()) // for and yield | ||
pipeline.Add(CheckInterfaceImplementations()) | ||
pipeline.Add(InjectCasts()) | ||
*/ | ||
|
||
class CompileToFilePipeline(CompilePipeline): | ||
|
||
override def Initialize(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace BooInBoo.Services | ||
|
||
class NameResolutionService: | ||
pass |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters