1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
$FreeBSD$
This patch was checked-out from the boo SVN repository, r3468.
It prevents build failures if an older lang/boo is already installed, more details at:
http://jira.codehaus.org/browse/BOO-1282
Index: src/Boo.Lang.Compiler/Compilation.cs
===================================================================
--- src/Boo.Lang.Compiler/Compilation.cs (révision 3467)
+++ src/Boo.Lang.Compiler/Compilation.cs (révision 3468)
@@ -87,16 +87,26 @@
return compiler.Run(unit);
}
+ public static CompilerContext compile_(CompileUnit unit, params ICompileUnit[] references)
+ {
+ return NewCompilerWithReferences(references).Run(unit);
+ }
+
private static BooCompiler NewCompilerWithReferences(IEnumerable<ICompileUnit> references)
{
- BooCompiler compiler = NewCompiler();
+ BooCompiler compiler = NewCompiler(false);
compiler.Parameters.References.AddAll(references);
return compiler;
}
private static BooCompiler NewCompiler()
{
- BooCompiler compiler = new BooCompiler();
+ return NewCompiler(true);
+ }
+
+ private static BooCompiler NewCompiler(bool loadDefaultReferences)
+ {
+ BooCompiler compiler = new BooCompiler(new CompilerParameters(loadDefaultReferences));
compiler.Parameters.OutputType = CompilerOutputType.Auto;
compiler.Parameters.Pipeline = new Boo.Lang.Compiler.Pipelines.CompileToMemory();
return compiler;
@@ -114,10 +124,5 @@
module.Members.Add(klass);
return module;
}
-
- public static CompilerContext compile_(CompileUnit unit, params ICompileUnit[] references)
- {
- return NewCompilerWithReferences(references).Run(unit);
- }
}
}
Index: src/Boo.Lang.Compiler/Steps/MacroProcessing/MacroCompiler.cs
===================================================================
--- src/Boo.Lang.Compiler/Steps/MacroProcessing/MacroCompiler.cs (révision 3467)
+++ src/Boo.Lang.Compiler/Steps/MacroProcessing/MacroCompiler.cs (révision 3468)
@@ -121,9 +121,7 @@
m.Namespace = CleanClone(node.EnclosingModule.Namespace);
m.Name = node.Name;
foreach (Import i in node.EnclosingModule.Imports)
- {
m.Imports.Add(CleanClone(i));
- }
m.Members.Add(CleanClone(node));
return m;
}
@@ -139,17 +137,13 @@
private void ReportErrors(CompilerErrorCollection errors)
{
foreach (CompilerError e in errors)
- {
Errors.Add(e);
- }
}
private void ReportWarnings(CompilerWarningCollection warnings)
{
foreach (CompilerWarning w in warnings)
- {
Warnings.Add(w);
- }
}
private static void CacheType(TypeDefinition node, Type type)
Index: tests/BooCompiler.Tests/ExtensionsCompilationTest.cs
===================================================================
--- tests/BooCompiler.Tests/ExtensionsCompilationTest.cs (révision 0)
+++ tests/BooCompiler.Tests/ExtensionsCompilationTest.cs (révision 3468)
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using System.IO;
+using Boo.Lang.Compiler;
+using Boo.Lang.Compiler.IO;
+using NUnit.Framework;
+
+namespace BooCompiler.Tests
+{
+ [TestFixture]
+ public class ExtensionsCompilationTest
+ {
+ [Test]
+ public void MacroMacroCompilation()
+ {
+ var parameters = new CompilerParameters(false);
+ parameters.References.Add(typeof(IEnumerable<>).Assembly);
+
+ parameters.Input.Add(BooLangExtensionsSource("Macros/MacroMacro.boo"));
+ parameters.Input.Add(BooLangExtensionsSource("Macros/AssertMacro.boo"));
+
+ parameters.Pipeline = new Boo.Lang.Compiler.Pipelines.ResolveExpressions();
+
+ var compiler = new Boo.Lang.Compiler.BooCompiler(parameters);
+ var results = compiler.Run();
+ Assert.AreEqual(0, results.Errors.Count, results.Errors.ToString());
+ }
+
+ private FileInput BooLangExtensionsSource(string file)
+ {
+ return new FileInput(Path.Combine(BooTestCaseUtil.BasePath, "src/Boo.Lang.Extensions/" + file));
+ }
+ }
+}
Index: tests/BooCompiler.Tests/BooTestCaseUtil.cs
===================================================================
--- tests/BooCompiler.Tests/BooTestCaseUtil.cs (révision 3467)
+++ tests/BooCompiler.Tests/BooTestCaseUtil.cs (révision 3468)
@@ -31,7 +31,6 @@
using System;
using System.IO;
using System.Reflection;
- using System.Xml;
using System.Xml.Serialization;
using Boo.Lang.Compiler.Ast;
using NUnit.Framework;
@@ -43,11 +42,15 @@
{
public static string TestCasesPath
{
+ get { return Path.Combine(BasePath, "tests/testcases"); }
+ }
+
+ public static string BasePath
+ {
get
{
Uri codebase = new Uri(Assembly.GetExecutingAssembly().CodeBase);
- Uri path = new Uri(codebase, "../testcases");
- return path.LocalPath;
+ return new Uri(codebase, "../..").LocalPath;
}
}
|