Index: src/Boo.Lang.Compiler/CompilerError.cs
===================================================================
--- src/Boo.Lang.Compiler/CompilerError.cs (revision 1939)
+++ src/Boo.Lang.Compiler/CompilerError.cs (working copy)
@@ -1,30 +1,30 @@
-#region license
-// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-// * Neither the name of Rodrigo B. de Oliveira nor the names of its
-// contributors may be used to endorse or promote products derived from this
-// software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+#region license
+// Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+// * Neither the name of Rodrigo B. de Oliveira nor the names of its
+// contributors may be used to endorse or promote products derived from this
+// software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#endregion
+#endregion
using System;
using System.Text;
@@ -66,16 +66,6 @@
_lexicalInfo = lexicalInfo;
}
- public CompilerError(string code, LexicalInfo lexicalInfo) : base(ResourceManager.GetString(code))
- {
- if (null == lexicalInfo)
- {
- throw new ArgumentNullException("lexicalInfo");
- }
- _code = code;
- _lexicalInfo = lexicalInfo;
- }
-
public CompilerError(string code, LexicalInfo lexicalInfo, string message, Exception cause) : base(message, cause)
{
if (null == lexicalInfo)
@@ -86,7 +76,7 @@
_lexicalInfo = lexicalInfo;
}
- public CompilerError(LexicalInfo lexicalInfo, string message, Exception cause) : this("BCE0040", lexicalInfo, message, cause)
+ public CompilerError(LexicalInfo lexicalInfo, string message, Exception cause) : this("BCE0000", lexicalInfo, message, cause)
{
}
@@ -101,11 +91,16 @@
public CompilerError(LexicalInfo data, string message) : this(data, message, null)
{
}
-
+
public CompilerError(LexicalInfo data, Exception cause) : this(data, cause.Message, cause)
{
}
+ public CompilerError(string message) : this(LexicalInfo.Empty, message, null)
+ {
+ }
+
+
///
/// Error code.
///
Index: src/Boo.Lang.Compiler/CompilerErrorFactory.cs
===================================================================
--- src/Boo.Lang.Compiler/CompilerErrorFactory.cs (revision 1939)
+++ src/Boo.Lang.Compiler/CompilerErrorFactory.cs (working copy)
@@ -38,6 +38,16 @@
{
}
+ public static CompilerError CustomError(LexicalInfo lexicalInfo, string msg)
+ {
+ return new CompilerError(lexicalInfo, msg);
+ }
+
+ public static CompilerError CustomError(string msg)
+ {
+ return new CompilerError(msg);
+ }
+
public static CompilerError ClassAlreadyHasBaseType(Node node, string className, string baseType)
{
return new CompilerError("BCE0001", node.LexicalInfo, className, baseType);
@@ -671,9 +681,9 @@
return new CompilerError("BCE0127", node.LexicalInfo, node.ToString());
}
- public static CompilerError InvalidTryStatement(Node node)
- {
- return new CompilerError("BCE0128", node.LexicalInfo);
+ public static CompilerError InvalidTryStatement(Node node)
+ {
+ return new CompilerError("BCE0128", node.LexicalInfo);
}
public static string ToStringList(System.Collections.IEnumerable names)
Index: src/Boo.Lang.Compiler/CompilerWarning.cs
===================================================================
--- src/Boo.Lang.Compiler/CompilerWarning.cs (revision 1939)
+++ src/Boo.Lang.Compiler/CompilerWarning.cs (working copy)
@@ -44,7 +44,7 @@
LexicalInfo _lexicalInfo;
- public CompilerWarning(string message)
+ public CompilerWarning(LexicalInfo lexicalInfo, string message)
{
if (null == message)
{
@@ -52,10 +52,14 @@
}
_code = "BCW0000";
- _lexicalInfo = LexicalInfo.Empty;
+ _lexicalInfo = lexicalInfo;
_message = message;
}
+ public CompilerWarning(string message) : this(LexicalInfo.Empty, message)
+ {
+ }
+
public CompilerWarning(string code, LexicalInfo lexicalInfo, params object[] args)
{
if (null == code)
Index: src/Boo.Lang.Compiler/CompilerWarningFactory.cs
===================================================================
--- src/Boo.Lang.Compiler/CompilerWarningFactory.cs (revision 1939)
+++ src/Boo.Lang.Compiler/CompilerWarningFactory.cs (working copy)
@@ -39,6 +39,16 @@
{
}
+ public static CompilerWarning CustomWarning(LexicalInfo lexicalInfo, string msg)
+ {
+ return new CompilerWarning(lexicalInfo, msg);
+ }
+
+ public static CompilerWarning CustomWarning(string msg)
+ {
+ return new CompilerWarning(msg);
+ }
+
public static CompilerWarning AbstractMemberNotImplemented(Node node, string typeName, string memberName)
{
return new CompilerWarning("BCW0001", node.LexicalInfo, typeName, memberName);
@@ -62,16 +72,16 @@
public static CompilerWarning InvalidEventUnsubscribe(Node node, string eventName, CallableSignature expected)
{
return new CompilerWarning("BCW0005", node.LexicalInfo, eventName, expected);
- }
-
- public static CompilerWarning AssignmentToTemporary(Node node)
- {
- return new CompilerWarning("BCW0006", node.LexicalInfo);
}
+
+ public static CompilerWarning AssignmentToTemporary(Node node)
+ {
+ return new CompilerWarning("BCW0006", node.LexicalInfo);
+ }
public static CompilerWarning EqualsInsteadOfAssign(BinaryExpression node)
{
return new CompilerWarning("BCW0007", node.LexicalInfo, node.ToCodeString());
- }
+ }
}
}
Index: src/Boo.Lang.Useful/Attributes/OnceAttribute.boo
===================================================================
--- src/Boo.Lang.Useful/Attributes/OnceAttribute.boo (revision 1939)
+++ src/Boo.Lang.Useful/Attributes/OnceAttribute.boo (working copy)
@@ -90,7 +90,9 @@
node
The node to apply the to.
"""
- assert node isa Method
+ if not node isa Method:
+ InvalidNodeForAttribute("Method")
+ return
_method = node
Index: src/Boo.Lang.Useful/Attributes/SingletonAttribute.boo
===================================================================
--- src/Boo.Lang.Useful/Attributes/SingletonAttribute.boo (revision 1939)
+++ src/Boo.Lang.Useful/Attributes/SingletonAttribute.boo (working copy)
@@ -44,7 +44,9 @@
_singletonType as ClassDefinition
override def Apply(node as Node):
- assert node isa ClassDefinition
+ if not node isa ClassDefinition:
+ InvalidNodeForAttribute("Class");
+ return
_singletonType = node
Index: src/Boo.Lang.Useful/Collections/CollectionAttribute.boo
===================================================================
--- src/Boo.Lang.Useful/Collections/CollectionAttribute.boo (revision 1939)
+++ src/Boo.Lang.Useful/Collections/CollectionAttribute.boo (working copy)
@@ -49,10 +49,15 @@
_itemType = SimpleTypeReference(itemType.ToString())
override def Apply(node as Node):
- assert node isa ClassDefinition
+ if not node isa ClassDefinition:
+ InvalidNodeForAttribute("Class")
+ return
classDef as ClassDefinition = node
- assert ExtendsObject(classDef), "cannot introduce AbstractCollection base class"
+ if not ExtendsObject(classDef):
+ Errors.Add(CompilerErrorFactory.CustomError(node.LexicalInfo,
+ "Cannot introduce AbstractCollection base class."))
+ return
RemoveObjectBaseType(classDef)
template = CollectionTemplate.CloneNode()
Index: src/Boo.Lang/Resources/it/strings.txt
===================================================================
--- src/Boo.Lang/Resources/it/strings.txt (revision 1939)
+++ src/Boo.Lang/Resources/it/strings.txt (working copy)
@@ -1,4 +1,5 @@
;Compiler Error Messages
+BCE0000='{0}'
BCE0001=La classe '{0}' eredita gia' da '{1}'.
BCE0002=Il nome del parametro deve essere un dentifier.
BCE0003=Argomenti con nome sono permessi solo nei costruttori.
@@ -129,6 +130,7 @@
BCE0128='try' block must be followed by either 'except' or 'ensure'.
;Compiler warnings
+BCW0000=WARNING: {0}
BCW0001=WARNING: Il tipo '{0}' non fornisce una implementazione per '{1}' e' verra' marcato come abstract
BCW0002=WARNING: I modificatori di statement non hanno effetto nelle label.
BCW0003=WARNING: Variabile locale non utilizzata '{0}'.
Index: src/Boo.Lang/Resources/pt/strings.txt
===================================================================
--- src/Boo.Lang/Resources/pt/strings.txt (revision 1939)
+++ src/Boo.Lang/Resources/pt/strings.txt (working copy)
@@ -1,4 +1,5 @@
;Compiler Error Messages
+BCE0000='{0}'
BCE0001=A classe '{0}' já tem '{1}' como classe base.
BCE0002=Nome do parâmetro deve ser um identificador.
BCE0003=Parâmetros são permitidos apenas com construtores.
@@ -129,6 +130,7 @@
BCE0128='try' block must be followed by either 'except' or 'ensure'.
;Compiler warnings
+BCW0000=AVISO: {0}
BCW0001=AVISO: O tipo '{0}' não possui uma implementação para '{1}' e será marcado como abstrato.
BCW0002=AVISO: Modificadores de sentença não afetam rótulos.
BCW0003=AVISO: Variável local não utilizada '{0}'.
Index: src/Boo.Lang/Resources/strings.txt
===================================================================
--- src/Boo.Lang/Resources/strings.txt (revision 1939)
+++ src/Boo.Lang/Resources/strings.txt (working copy)
@@ -1,4 +1,5 @@
;Compiler Error Messages
+BCE0000='{0}'
BCE0001=The class '{0}' already has '{1}' as its base class.
BCE0002=Parameter name must be an identifier.
BCE0003=Named arguments are only allowed for constructors.
@@ -129,6 +130,7 @@
BCE0128='try' block must be followed by either 'except' or 'ensure'.
;Compiler warnings
+BCW0000=WARNING: {0}
BCW0001=WARNING: Type '{0}' does not provide an implementation for '{1}' and will be marked abstract
BCW0002=WARNING: Statement modifiers have no effect in labels.
BCW0003=WARNING: Unused local variable '{0}'.
Index: tests/testcases/errors/BCE0000-1.boo
===================================================================
--- tests/testcases/errors/BCE0000-1.boo (revision 0)
+++ tests/testcases/errors/BCE0000-1.boo (revision 0)
@@ -0,0 +1,14 @@
+"""
+BCE0000-1.boo(10,7): BCE0000: Cannot introduce AbstractCollection base class.
+"""
+import Useful.Collections from Boo.Lang.Useful
+
+class C:
+ pass
+
+[collection(string)]
+class StringCollection(C):
+ pass
+
+s = StringCollection()
+