Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/Flame.Clr/Analysis/ClrMethodBodyAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ private void AnalyzeExceptionHandler(
/// Analyzes a 'catch' exception handler's implementation.
/// </summary>
/// <param name="handler">The exception handler to analyze.</param>
/// <param name="landingPadTag">
/// The basic block tag of the landing pad to populate for the handler.
/// <param name="analyzedHandler">
/// The analyzed catch handler to populate.
/// </param>
/// <param name="cilMethodBody">A CIL method body.</param>
private void AnalyzeCatchHandler(
Expand Down Expand Up @@ -344,8 +344,8 @@ private void AnalyzeCatchHandler(
/// Analyzes a 'filter' exception handler's implementation.
/// </summary>
/// <param name="handler">The exception handler to analyze.</param>
/// <param name="landingPadTag">
/// The basic block tag of the landing pad to populate for the handler.
/// <param name="analyzedHandler">
/// The analyzed filter handler to populate.
/// </param>
/// <param name="cilMethodBody">A CIL method body.</param>
private void AnalyzeFilterHandler(
Expand Down
2 changes: 1 addition & 1 deletion src/Flame.Compiler/Flow/ReturnFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override BlockFlow WithInstructions(IReadOnlyList<Instruction> instructio
{
ContractHelpers.Assert(instructions.Count == 1, "Return flow takes exactly one instruction.");
var newReturnValue = instructions[0];
if (object.ReferenceEquals(newReturnValue, ReturnValue))
if (newReturnValue.Equals(ReturnValue))
{
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Flame.Compiler/Flow/SwitchFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public override BlockFlow WithInstructions(IReadOnlyList<Instruction> instructio
{
ContractHelpers.Assert(instructions.Count == 1, "Switch flow takes exactly one instruction.");
var newSwitchValue = instructions[0];
if (object.ReferenceEquals(newSwitchValue, SwitchValue))
if (newSwitchValue.Equals(SwitchValue))
{
return this;
}
Expand Down
13 changes: 10 additions & 3 deletions src/Flame.Ir/ConstantCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ public override LNode Encode(Constant value, EncoderState state)
{
// Encode other integer constants as custom literals.
return state.Factory.Literal(
new CustomLiteral(
integerConst.Value.ToString(),
GSymbol.Get(integerConst.Spec.ToString())));
integerConst.Value.ToString(),
GSymbol.Get(integerConst.Spec.ToString()));
}
}
else if (value is Float32Constant)
Expand Down Expand Up @@ -253,13 +252,21 @@ private static bool TryDecomposeCustomLiteral(
out Symbol typeMarker)
{
var val = node.Value;
#pragma warning disable CS0618 // Keep CustomLiteral support for backward compatibility with older encoded IR
if (val is CustomLiteral)
{
var literal = (CustomLiteral)val;
value = literal.Value;
typeMarker = literal.TypeMarker;
return true;
}
#pragma warning restore CS0618
else if (node.TypeMarker != null && node.TypeMarker.Name != "_")
{
value = val;
typeMarker = node.TypeMarker;
return true;
}
else
{
value = null;
Expand Down
4 changes: 2 additions & 2 deletions src/Flame.Ir/DecoderState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ private BlockFlow DecodeBlockFlow(
return UnreachableFlow.Instance;
}
}
else if (node.Calls(CodeSymbols.Switch))
else if (node.Calls(CodeSymbols.SwitchStmt))
{
// Decode the value being switched on as well as the default branch.
Instruction switchVal;
Expand Down Expand Up @@ -907,7 +907,7 @@ private BlockFlow DecodeBlockFlow(
Quotation.QuoteEvenInBold(
"unknown type of flow; expected one of ",
CodeSymbols.Goto.Name, ", ",
CodeSymbols.Switch.Name, ", ",
CodeSymbols.SwitchStmt.Name, ", ",
CodeSymbols.Try.Name, ", ",
CodeSymbols.Return.Name, " or ",
EncoderState.unreachableFlowSymbol.Name, "."));
Expand Down
4 changes: 2 additions & 2 deletions src/Flame.Ir/EncoderState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public EncoderState(IrCodec codec, LNodeFactory factory)
public EncoderState(IrCodec codec)
: this(
codec,
new LNodeFactory(EmptySourceFile.Default))
new LNodeFactory(EmptySourceFile.Synthetic))
{ }

/// <summary>
Expand Down Expand Up @@ -457,7 +457,7 @@ private LNode Encode(
}

return Factory.Call(
CodeSymbols.Switch,
CodeSymbols.SwitchStmt,
Encode(switchFlow.SwitchValue, valueNameMap),
Encode(switchFlow.DefaultBranch, blockNameMap, valueNameMap),
Factory.Call(CodeSymbols.Braces, caseNodes));
Expand Down
4 changes: 2 additions & 2 deletions src/Flame.Ir/InstructionCodecElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private static IReadOnlyList<LNode> EncodeIndirectCall(IndirectCallPrototype val
return new LNode[]
{
state.Encode(value.ResultType),
state.Factory.List(paramTypeNodes)
state.Factory.AltList(paramTypeNodes)
};
}

Expand Down Expand Up @@ -279,7 +279,7 @@ private static IReadOnlyList<LNode> EncodeIntrinsic(IntrinsicPrototype value, En
{
state.Factory.Id(value.Name),
state.Encode(value.ResultType),
state.Factory.List(paramTypeNodes)
state.Factory.AltList(paramTypeNodes)
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/Flame.Ir/TypeCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private TypeCodec()
public static readonly TypeCodec Instance = new TypeCodec();

private static readonly Symbol pointerSymbol = GSymbol.Get("#pointer");
private static readonly Symbol genericParameterSymbol = CodeSymbols.PtrArrow;
private static readonly Symbol genericParameterSymbol = CodeSymbols.RightArrow;

private Dictionary<PointerKind, Symbol> pointerKindEncoding;
private Dictionary<Symbol, PointerKind> pointerKindDecoding;
Expand Down
5 changes: 0 additions & 5 deletions src/Flame/ContractHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.Serialization;

namespace Flame
{
Expand All @@ -8,15 +7,11 @@ namespace Flame
/// </summary>
public static class ContractHelpers
{
[Serializable]
private class AssertionException : Exception
{
public AssertionException() { }
public AssertionException(string message) : base(message) { }
public AssertionException(string message, Exception inner) : base(message, inner) { }
protected AssertionException(
SerializationInfo info,
StreamingContext context) : base(info, context) { }
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/UnitTests/Flame/DeferredInitializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void TestMultithreadedInit()
public void RecursiveInit()
{
var integer = new Box<int>(0);
DeferredInitializer init;
DeferredInitializer init = default;
// This test makes sure that Initialize() does not recurse:
// calling Initialize() from Initialize() does nothing at all.
// This is by design, because it allows initialization to touch
Expand Down
Loading