Skip to content

Commit

Permalink
resolved some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AqlaSolutions committed Mar 6, 2016
1 parent f93e8f9 commit 17fe3dc
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 108 deletions.
2 changes: 2 additions & 0 deletions RunSharp/RunSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\RunSharp.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -44,6 +45,7 @@
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>bin\Release\RunSharp.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
Expand Down
2 changes: 2 additions & 0 deletions RunSharpIKVM/RunSharp_IKVM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\RunSharp.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -44,6 +45,7 @@
<WarningLevel>4</WarningLevel>
<DebugSymbols>true</DebugSymbols>
<DocumentationFile>bin\Release\RunSharp.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
Expand Down
2 changes: 2 additions & 0 deletions RunSharpShared/Aqla/AttributeMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ public override bool TryGet(string key, bool publicOnly, out object value)
value = null;
return false;
}

private readonly Attribute _attribute;

public ReflectionAttributeMap(Attribute attribute)
{
_attribute = attribute;
Expand Down
8 changes: 4 additions & 4 deletions RunSharpShared/Aqla/CompilerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ limitations under the License.
using System.Reflection.Emit;
#endif

using System;

namespace TriAxis.RunSharp
{
/// <summary>
Expand Down Expand Up @@ -76,8 +74,6 @@ public void SetFrameworkOptions(Type from, ITypeMapper mapper)
}
}

private string _imageRuntimeVersion;
private int _metaDataVersion;
/// <summary>
/// The TargetFrameworkAttribute FrameworkName value to burn into the generated assembly
/// </summary>
Expand All @@ -96,6 +92,10 @@ public void SetFrameworkOptions(Type from, ITypeMapper mapper)
public string OutputPath { get; set; }

#if FEAT_IKVM

private string _imageRuntimeVersion;
private int _metaDataVersion;

/// <summary>
/// The name of the container that holds the key pair.
/// </summary>
Expand Down
96 changes: 37 additions & 59 deletions RunSharpShared/CodeGen.Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,36 +395,34 @@ public void ThrowAssert(Operand condition, Operand message)
#endregion

#region Event subscription
public void SubscribeEvent(Operand target, string eventName, Operand handler)
{
if ((object)target == null)
throw new ArgumentNullException(nameof(target));
if ((object)handler == null)
throw new ArgumentNullException(nameof(handler));

IMemberInfo evt = TypeMapper.TypeInfo.FindEvent(target.GetReturnType(TypeMapper), eventName, target.IsStaticTarget);
MethodInfo mi = ((EventInfo)evt.Member).GetAddMethod();
if (!target.IsStaticTarget)
target.EmitGet(this);
handler.EmitGet(this);
EmitCallHelper(mi, target);
}

public void UnsubscribeEvent(Operand target, string eventName, Operand handler)
public void SubscribeEvent(Operand target, string eventName, Operand handler)
{
SubscribeOrUnsubscribeEvent(target, eventName, handler, true);
}

public void UnsubscribeEvent(Operand target, string eventName, Operand handler)
{
if ((object)target == null)
throw new ArgumentNullException(nameof(target));
if ((object)handler == null)
throw new ArgumentNullException(nameof(handler));
SubscribeOrUnsubscribeEvent(target, eventName, handler, false);
}

IMemberInfo evt = TypeMapper.TypeInfo.FindEvent(target.GetReturnType(TypeMapper), eventName, target.IsStaticTarget);
MethodInfo mi = ((EventInfo)evt.Member).GetRemoveMethod();
if (!target.IsStaticTarget)
target.EmitGet(this);
handler.EmitGet(this);
EmitCallHelper(mi, target);
}
#endregion
void SubscribeOrUnsubscribeEvent(Operand target, string eventName, Operand handler, bool subscribe)
{
if ((object)target == null)
throw new ArgumentNullException(nameof(target));
if ((object)handler == null)
throw new ArgumentNullException(nameof(handler));

IMemberInfo evt = TypeMapper.TypeInfo.FindEvent(target.GetReturnType(TypeMapper), eventName, target.IsStaticTarget);
var eventInfo = (EventInfo)evt.Member;
MethodInfo mi = subscribe ? eventInfo.GetAddMethod() : eventInfo.GetRemoveMethod();
if (!target.IsStaticTarget)
target.EmitGet(this);
handler.EmitGet(this);
EmitCallHelper(mi, target);
}

#endregion

public void InitObj(Operand target)
{
Expand Down Expand Up @@ -458,36 +456,15 @@ interface IContinuable

public void Break()
{
BeforeStatement();

bool useLeave = false;

foreach (Block blk in _blocks)
{
ExceptionBlock xb = blk as ExceptionBlock;

if (xb != null)
{
if (xb.IsFinally)
throw new InvalidOperationException(Properties.Messages.ErrInvalidFinallyBranch);

useLeave = true;
}

IBreakable brkBlock = blk as IBreakable;

if (brkBlock != null)
{
IL.Emit(useLeave ? OpCodes.Leave : OpCodes.Br, brkBlock.GetBreakTarget());
IsReachable = false;
return;
}
}

throw new InvalidOperationException(Properties.Messages.ErrInvalidBreak);
LeaveBlock(blk => (blk as IBreakable)?.GetBreakTarget());
}

public void Continue()
public void Continue()
{
LeaveBlock(blk => (blk as IContinuable)?.GetContinueTarget());
}

void LeaveBlock(RunSharpFunc<Block, Label?> tryGetJumpLabel)
{
BeforeStatement();

Expand All @@ -505,11 +482,12 @@ public void Continue()
useLeave = true;
}

IContinuable cntBlock = blk as IContinuable;

if (cntBlock != null)
{
IL.Emit(useLeave ? OpCodes.Leave : OpCodes.Br, cntBlock.GetContinueTarget());
Label? label = tryGetJumpLabel(blk);

if (label != null)
{
IL.Emit(useLeave ? OpCodes.Leave : OpCodes.Br, label.Value);
IsReachable = false;
return;
}
Expand Down
61 changes: 21 additions & 40 deletions RunSharpShared/Conversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,27 +331,7 @@ public static Conversion FindImplicit(List<UserDefined> collection, Type @from,
}
}

if (sx == null || tx == null)
return new Ambiguous(typeMapper);

UserDefined match = null;

for (int i = 0; i < collection.Count; i++)
{
UserDefined udc = collection[i];
if (udc._fromType == sx && udc._toType == tx)
{
if (match != null)
return new Ambiguous(typeMapper); // ambiguous match
else
match = udc;
}
}

if (match == null)
return new Ambiguous(typeMapper);

return match;
return FindConversation_Match(collection, sx, tx, typeMapper);
}

public static Conversion FindExplicit(List<UserDefined> collection, Type @from, Type to, ITypeMapper typeMapper)
Expand Down Expand Up @@ -438,28 +418,29 @@ public static Conversion FindExplicit(List<UserDefined> collection, Type @from,
}
}

if (sx == null || tx == null)
return new Ambiguous(typeMapper);
return FindConversation_Match(collection, sx, tx, typeMapper);
}

UserDefined match = null;
static Conversion FindConversation_Match(List<UserDefined> collection, Type sx, Type tx, ITypeMapper typeMapper)
{
if (sx == null || tx == null)
return new Ambiguous(typeMapper);

for (int i = 0; i < collection.Count; i++)
{
UserDefined udc = collection[i];
if (udc._fromType == sx && udc._toType == tx)
{
if (match != null)
return new Ambiguous(typeMapper); // ambiguous match
else
match = udc;
}
}
Conversion match = null;

if (match == null)
return new Ambiguous(typeMapper);

return match;
}
for (int i = 0; i < collection.Count; i++)
{
UserDefined udc = collection[i];
if (udc._fromType == sx && udc._toType == tx)
{
if (match != null)
return new Ambiguous(typeMapper); // ambiguous match
match = udc;
}
}

return match ?? new Ambiguous(typeMapper);
}
}
#endregion

Expand Down
4 changes: 1 addition & 3 deletions RunSharpShared/DelegateGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ public class DelegateGen : SignatureGen<DelegateGen>
TypeGen _delegateType;
List<AttributeGen> _customAttributes;
readonly TypeGen _owner2;

public ITypeMapper TypeMapper => _owner != null ? _owner.TypeMapper : _owner2.TypeMapper;


public DelegateGen(AssemblyGen owner, string name, Type returnType, TypeAttributes attrs)
: base(returnType, owner.TypeMapper)
{
Expand Down
5 changes: 4 additions & 1 deletion RunSharpSilverlight/RunSharp_Silverlight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>Bin\Debug\RunSharp.XML</DocumentationFile>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -65,6 +66,7 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\RunSharp.XML</DocumentationFile>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
Expand Down Expand Up @@ -97,7 +99,8 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="..\RunSharpShared\RunSharpShared.projitems" Label="Shared" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<Import Project="..\RunSharpShared\RunSharpShared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
4 changes: 3 additions & 1 deletion RunSharpWP8/RunSharp_WP8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down Expand Up @@ -65,6 +65,7 @@
<ErrorReport>prompt</ErrorReport>
<DocumentationFile>bin\x86\Debug\RunSharp.XML</DocumentationFile>
<WarningLevel>4</WarningLevel>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -76,6 +77,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>Bin\x86\Release\RunSharp.XML</DocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|ARM' ">
<DebugSymbols>true</DebugSymbols>
Expand Down

0 comments on commit 17fe3dc

Please sign in to comment.