Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

Latest boo improvements including fix to case 459750 #10

Merged
merged 44 commits into from
Jul 24, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b73bb4a
avoid ArithmeticOverflowException (that will occur after fixing handl…
bamboo Mar 12, 2012
c04067f
When multiple properties are found with the same name, attempt to res…
aaronlerch Mar 28, 2012
09d679b
Fix incorrect namespace.
aaronlerch Mar 28, 2012
c8d1829
Merge pull request #21 from aaronlerch/master
bamboo Mar 30, 2012
41e1d15
ensure the right overload is being called
bamboo Mar 30, 2012
2476bfb
migrate project files to VS2010
bamboo Mar 31, 2012
5ec4479
test case for macro produced type used as a generic argument
bamboo Mar 31, 2012
ad5dbf4
docstrings for blockless macro
bamboo Mar 31, 2012
4a2ebae
ParameterDeclaration.Lift(ReferenceExpression | TryCastExpression)
bamboo Apr 1, 2012
4f8045f
GenericParameterDeclaration.Lift(ReferenceExpression | SimpleTypeRefe…
bamboo Apr 3, 2012
d869aea
[booish] fix how external generic types are described
bamboo Apr 8, 2012
393127f
[booish] show descriptions for namespaces and others
bamboo Apr 8, 2012
85c08a0
[booish] allow setting values
bamboo Apr 8, 2012
c4d32e9
introduce EnvironmentBoundValue for threading original environment wi…
bamboo Apr 8, 2012
3fbd680
[booish] fix completion by accessing entities in the correct environment
bamboo Apr 8, 2012
c2cef14
[booish] display IEnumerable[of T] as T*
bamboo Apr 8, 2012
8981b6c
[booish] fix autocomplete behavior
bamboo Apr 8, 2012
2adc9c9
fix test exception handler
bamboo Apr 12, 2012
455022a
don't depend on Tuple (and .net 4) just yet
bamboo Apr 12, 2012
5cd5382
remove unused code
bamboo Apr 12, 2012
32507dc
transient is now an attribute
bamboo Apr 12, 2012
f373173
prefer quasiquotes over ast api
bamboo Apr 12, 2012
fb68b45
Boo.Lang.List.AddRange
bamboo Apr 12, 2012
a21a046
code gardening
bamboo Apr 12, 2012
853b753
embrace System.Func
bamboo Apr 12, 2012
29d60e3
remove method already supported by System.Linq
bamboo Apr 12, 2012
480e518
code gardening
bamboo Apr 12, 2012
5c97526
template gardening
bamboo Apr 12, 2012
e2785d2
Extend => AddRange
bamboo Apr 12, 2012
85195cc
code gardening
bamboo Apr 12, 2012
1cacd1e
update tests to new syntax
bamboo May 4, 2012
bcd95c1
code gardening
bamboo May 4, 2012
5d92426
introducing AstNodePredicates for extension method predicates on ast …
bamboo May 4, 2012
8623f85
extract RuntimeMethodCache out of ProcessMethodBodies
bamboo May 4, 2012
03dbd48
code gardening (move entity predicates to EntityExtensions)
bamboo May 4, 2012
3862e61
SecurityPermissionAttribute is no more
bamboo May 4, 2012
75796ae
check array indices as a separate step (so it also runs for unityscri…
bamboo May 4, 2012
e514377
fix project references
bamboo May 4, 2012
8391756
workaround mono limitation
bamboo May 4, 2012
f9b300c
unnecessary comment removed
bamboo May 5, 2012
d2ee05b
Merge branch 'master' of github.com:bamboo/boo into upstream
bamboo May 7, 2012
386d556
don't embrace System.Func on Boo.Lang just yet
bamboo May 7, 2012
f2eb1a0
minor test cleanup
bamboo May 7, 2012
c5d9aa6
Merge branch 'master' of github.com:bamboo/boo into upstream
bamboo May 7, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
code gardening
  • Loading branch information
bamboo committed May 4, 2012
commit bcd95c193621024bd04323eab0dfbd81ed8a1900
82 changes: 31 additions & 51 deletions src/Boo.Lang.Compiler/Ast/AstUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Boo.Lang.Compiler.Ast
using System.Collections.Generic;
using System.Text.RegularExpressions;

public class AstUtil
public static class AstUtil
{
public static bool IsOverloadableOperator(BinaryOperatorType op)
{
Expand Down Expand Up @@ -72,12 +72,12 @@ public static bool IsOverloadableOperator(BinaryOperatorType op)

public static string GetMethodNameForOperator(BinaryOperatorType op)
{
return "op_" + op.ToString();
return "op_" + op;
}

public static string GetMethodNameForOperator(UnaryOperatorType op)
{
return "op_" + op.ToString();
return "op_" + op;
}

public static bool IsComplexSlicing(SlicingExpression node)
Expand Down Expand Up @@ -329,11 +329,12 @@ public static bool IsLhsOfInPlaceAddSubtract(Expression node)
{
if (NodeType.BinaryExpression == node.ParentNode.NodeType)
{
BinaryExpression be = (BinaryExpression)node.ParentNode;
var be = (BinaryExpression)node.ParentNode;
if (node == be.Left)
{
BinaryOperatorType op = be.Operator;
return op == BinaryOperatorType.InPlaceAddition || op == BinaryOperatorType.InPlaceSubtraction;
var op = be.Operator;
return op == BinaryOperatorType.InPlaceAddition
|| op == BinaryOperatorType.InPlaceSubtraction;
}
}
return false;
Expand All @@ -349,10 +350,7 @@ public static bool IsStandaloneReference(Node node)

public static Constructor CreateConstructor(Node lexicalInfoProvider, TypeMemberModifiers modifiers)
{
Constructor constructor = new Constructor(lexicalInfoProvider.LexicalInfo);
constructor.Modifiers = modifiers;
constructor.IsSynthetic = true;
return constructor;
return new Constructor(lexicalInfoProvider.LexicalInfo) { Modifiers = modifiers, IsSynthetic = true };
}

public static Constructor CreateDefaultConstructor(TypeDefinition type)
Expand Down Expand Up @@ -386,33 +384,27 @@ public static MethodInvocationExpression CreateMethodInvocationExpression(Expres

public static MethodInvocationExpression CreateMethodInvocationExpression(LexicalInfo li, Expression target, Expression arg)
{
MethodInvocationExpression mie = new MethodInvocationExpression(li);
mie.Target = (Expression)target.Clone();
var mie = new MethodInvocationExpression(li) { Target = (Expression) target.Clone(), IsSynthetic = true };
mie.Arguments.Add((Expression)arg.Clone());
mie.IsSynthetic = true;
return mie;
}

public static bool IsExplodeExpression(Node node)
{
UnaryExpression e = node as UnaryExpression;
return null == e ? false : e.Operator == UnaryOperatorType.Explode;
var e = node as UnaryExpression;
return e == null ? false : e.Operator == UnaryOperatorType.Explode;
}

public static bool IsIndirection(Node node)
{
var e = node as UnaryExpression;
return null == e ? false : e.Operator == UnaryOperatorType.Indirection;
}

private AstUtil()
{
return e == null ? false : e.Operator == UnaryOperatorType.Indirection;
}

public static string ToXml(Node node)
{
StringWriter writer = new StringWriter();
XmlSerializer serializer = new XmlSerializer(node.GetType());
var writer = new StringWriter();
var serializer = new XmlSerializer(node.GetType());
serializer.Serialize(writer, node);
return writer.ToString();
}
Expand Down Expand Up @@ -445,20 +437,18 @@ public static string SafeToCodeString(Node node)
//use this to build a type member name unique in the inheritance hierarchy.
public static string BuildUniqueTypeMemberName(TypeDefinition type, string name)
{
if (String.IsNullOrEmpty(name))
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException("name");

StringBuilder nameBuilder = new StringBuilder("$");
var nameBuilder = new StringBuilder("$");
nameBuilder.Append(name);
nameBuilder.Append("__");
nameBuilder.Append(type.QualifiedName);
if (type.HasGenericParameters)
{
nameBuilder.Append("_");
string[] parameterNames = Array.ConvertAll(
type.GenericParameters.ToArray(),
delegate(GenericParameterDeclaration gpd) { return gpd.Name; });
foreach (string parameterName in parameterNames)

foreach (var parameterName in type.GenericParameters.Select(gpd => gpd.Name))
{
nameBuilder.Append("_");
nameBuilder.Append(parameterName);
Expand All @@ -479,36 +469,31 @@ internal static Local GetLocalByName(Method method, string name)

public static LexicalInfo SafeLexicalInfo(Node node)
{
if (null == node) return LexicalInfo.Empty;
LexicalInfo info = node.LexicalInfo;
if (info.IsValid) return info;
return SafeLexicalInfo(node.ParentNode);
if (node == null)
return LexicalInfo.Empty;
var info = node.LexicalInfo;
return info.IsValid ? info : SafeLexicalInfo(node.ParentNode);
}

public static string SafePositionOnlyLexicalInfo(Node node)
{
LexicalInfo info = SafeLexicalInfo(node);
return String.Format("({0},{1})", info.Line, info.Column);
var info = SafeLexicalInfo(node);
return string.Format("({0},{1})", info.Line, info.Column);
}

public static ICollection<TValue> GetValues<TNode, TValue>(NodeCollection<TNode> nodes)
where TNode : LiteralExpression
{
List<TValue> values = new List<TValue>(nodes.Count);

foreach (TNode node in nodes)
values.Add((TValue) Convert.ChangeType(node.ValueObject, typeof(TValue)));

return values;
return nodes.Select(node => (TValue) Convert.ChangeType(node.ValueObject, typeof(TValue))).ToList();
}

internal static bool AllCodePathsReturnOrRaise(Block block)
{
if (null == block || block.IsEmpty)
if (block == null || block.IsEmpty)
return false;

Node node = block.LastStatement;
NodeType last = node.NodeType;
var node = block.LastStatement;
var last = node.NodeType;
switch (last)
{
case NodeType.ReturnStatement:
Expand All @@ -519,23 +504,18 @@ internal static bool AllCodePathsReturnOrRaise(Block block)
return AllCodePathsReturnOrRaise((Block)node);

case NodeType.IfStatement:
IfStatement ifstmt = (IfStatement) node;
var ifstmt = (IfStatement) node;
return
AllCodePathsReturnOrRaise(ifstmt.TrueBlock)
&& AllCodePathsReturnOrRaise(ifstmt.FalseBlock);

case NodeType.TryStatement:
TryStatement ts = (TryStatement) node;
var ts = (TryStatement) node;
if (!AllCodePathsReturnOrRaise(ts.ProtectedBlock))
return false;
//if (null != ts.FailureBlock && !EndsWithReturnStatement(ts.FailureBlock))
// return false;
foreach (ExceptionHandler handler in ts.ExceptionHandlers)
{
if (!AllCodePathsReturnOrRaise(handler.Block))
return false;
}
return true;
return ts.ExceptionHandlers.Select(handler => handler.Block).All(AllCodePathsReturnOrRaise);
}
return false;
}
Expand Down
38 changes: 19 additions & 19 deletions src/Boo.Lang.Compiler/Steps/AbstractFastVisitorCompilerStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,31 @@ namespace Boo.Lang.Compiler.Steps
{
public class AbstractFastVisitorCompilerStep : FastDepthFirstVisitor, ICompilerStep
{
private CompilerContext _context;
public virtual void Run()
{
CompileUnit.Accept(this);
}

public virtual void Initialize(CompilerContext context)
{
_context = context;
_codeBuilder = new EnvironmentProvision<BooCodeBuilder>();
_typeSystemServices = new EnvironmentProvision<TypeSystemServices>();
_nameResolutionService = new EnvironmentProvision<NameResolutionService>();
}

public virtual void Dispose()
{
_context = null;
}

protected CompilerContext Context
{
get { return _context; }
}

private CompilerContext _context;

protected CompilerErrorCollection Errors
{
get { return _context.Errors; }
Expand Down Expand Up @@ -136,24 +154,6 @@ protected void BindExpressionType(Expression node, IType type)
node.ExpressionType = type;
}

public virtual void Initialize(CompilerContext context)
{
_context = context;
_codeBuilder = new EnvironmentProvision<BooCodeBuilder>();
_typeSystemServices = new EnvironmentProvision<TypeSystemServices>();
_nameResolutionService = new EnvironmentProvision<NameResolutionService>();
}

public virtual void Dispose()
{
_context = null;
}

public virtual void Run()
{
CompileUnit.Accept(this);
}

protected CompileUnit CompileUnit
{
get { return _context.CompileUnit; }
Expand Down
7 changes: 0 additions & 7 deletions src/Boo.Lang.Compiler/Steps/EmitAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4385,13 +4385,6 @@ CustomAttributeBuilder CreateRuntimeCompatibilityAttribute()
RuntimeCompatibilityAttribute_Property, new object[] { true });
}

CustomAttributeBuilder CreateSerializableAttribute()
{
return new CustomAttributeBuilder(
SerializableAttribute_Constructor,
new object[0]);
}

CustomAttributeBuilder CreateUnverifiableCodeAttribute()
{
return new CustomAttributeBuilder(Methods.ConstructorOf(() => new UnverifiableCodeAttribute()), new object[0]);
Expand Down
Loading