Skip to content

Commit c932cc5

Browse files
committed
Some minor C# expreesion changes.
1 parent 954c363 commit c932cc5

File tree

2 files changed

+21
-46
lines changed

2 files changed

+21
-46
lines changed

Clojure/Clojure/CljCompiler/Ast/InstanceOfExpr.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,26 @@
88
* You must not remove this notice, or any other, from this software.
99
**/
1010

11-
/**
12-
* Author: David Miller
13-
**/
14-
1511
using System;
1612
using System.Reflection.Emit;
1713

18-
1914
namespace clojure.lang.CljCompiler.Ast
2015
{
2116
public sealed class InstanceOfExpr : Expr, MaybePrimitiveExpr
2217
{
2318
#region Data
2419

2520
readonly Expr _expr;
26-
public Expr Expr { get { return _expr; } }
21+
public Expr Expr => _expr;
2722

2823
readonly Type _t;
29-
public Type Type { get { return _t; } }
24+
public Type Type => _t;
3025

3126
readonly string _source;
32-
public string Source { get { return _source; } }
27+
public string Source => _source;
3328

3429
readonly IPersistentMap _spanMap;
35-
public IPersistentMap SpanMap { get { return _spanMap; } }
30+
public IPersistentMap SpanMap => _spanMap;
3631

3732
#endregion
3833

@@ -50,15 +45,9 @@ public InstanceOfExpr(string source, IPersistentMap spanMap, Type t, Expr expr)
5045

5146
#region Type mangling
5247

53-
public bool HasClrType
54-
{
55-
get { return true; }
56-
}
48+
public bool HasClrType => true;
5749

58-
public Type ClrType
59-
{
60-
get { return typeof(bool); }
61-
}
50+
public Type ClrType => typeof(bool);
6251

6352
#endregion
6453

@@ -81,12 +70,9 @@ public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
8170
ilg.Emit(OpCodes.Pop);
8271
}
8372

84-
public bool HasNormalExit() { return true; }
73+
public bool HasNormalExit() => true;
8574

86-
public bool CanEmitPrimitive
87-
{
88-
get { return true; }
89-
}
75+
public bool CanEmitPrimitive => true;
9076

9177
public void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg)
9278
{

Clojure/Clojure/CljCompiler/Ast/StaticInvokeExpr.cs

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class StaticInvokeExpr : Expr, MaybePrimitiveExpr
2828
readonly bool _variadic;
2929
readonly object _tag;
3030

31-
public MethodInfo Method { get { return _method; } }
31+
public MethodInfo Method => _method;
3232

3333
Type _cachedType;
3434

@@ -51,10 +51,7 @@ public StaticInvokeExpr(Type target, MethodInfo method, bool variadic, IPersiste
5151

5252
#region Type mangling
5353

54-
public bool HasClrType
55-
{
56-
get { return true; }
57-
}
54+
public bool HasClrType => true;
5855

5956
public Type ClrType
6057
{
@@ -72,7 +69,7 @@ public Type ClrType
7269

7370
public static Expr Parse(Var v, ISeq args, object tag)
7471
{
75-
if (!v.isBound || v.get() == null)
72+
if (!v.isBound || v.get() is null)
7673
{
7774
//Console.WriteLine("Not bound: {0}", v);
7875
return null;
@@ -86,12 +83,12 @@ public static Expr Parse(Var v, ISeq args, object tag)
8683
// We do not want to direct link to if we going into a non-PersistedAssemblyBuilder assembly --
8784
// this throws an exception when generating the method call IL in the StaticInvokeExpr.Emit
8885

89-
if ( Compiler.IsCompiling &&
86+
if (Compiler.IsCompiling &&
9087
Compiler.CompilerContextVar.deref() is GenContext context &&
91-
! GenContext.IsInternalAssembly(context.AssemblyBuilder) &&
88+
!GenContext.IsInternalAssembly(context.AssemblyBuilder) &&
9289
Compiler.TryGetDirectLink(v, out Type t))
9390
{
94-
if (t != null)
91+
if (t is not null)
9592
target = t;
9693
}
9794
}
@@ -123,7 +120,7 @@ public static Expr Parse(Var v, ISeq args, object tag)
123120
}
124121
}
125122

126-
if (method == null)
123+
if (method is null)
127124
return null;
128125

129126
IPersistentVector argv = PersistentVector.EMPTY;
@@ -152,23 +149,18 @@ public void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
152149
EmitUnboxed(rhc, objx, ilg);
153150
if (rhc != RHC.Statement)
154151
HostExpr.EmitBoxReturn(objx, ilg, _retType);
155-
if (rhc == RHC.Statement )
152+
if (rhc == RHC.Statement)
156153
ilg.Emit(OpCodes.Pop);
157154
}
158155

159-
public bool HasNormalExit()
160-
{
161-
return true;
162-
}
163-
156+
public bool HasNormalExit() => true;
164157

165158
public void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg)
166159
{
167160
if (_variadic)
168161
{
169-
170162
ParameterInfo[] pinfos = _method.GetParameters();
171-
for (int i =0; i< pinfos.Length-1; i++ )
163+
for (int i = 0; i < pinfos.Length - 1; i++)
172164
{
173165
Expr e = (Expr)_args.nth(i);
174166
if (Compiler.MaybePrimitiveType(e) == pinfos[i].ParameterType)
@@ -181,7 +173,7 @@ public void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg)
181173
}
182174
IPersistentVector restArgs = RT.subvec(_args, pinfos.Length - 1, _args.count());
183175
MethodExpr.EmitArgsAsArray(restArgs, objx, ilg);
184-
ilg.EmitCall(Compiler.Method_ArraySeq_create);
176+
ilg.EmitCall(Compiler.Method_ArraySeq_create);
185177
}
186178
else
187179
MethodExpr.EmitTypedArgs(objx, ilg, _method.GetParameters(), _args);
@@ -198,14 +190,11 @@ public void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg)
198190
}
199191
}
200192

201-
#endregion
193+
#endregion
202194

203195
#region MaybePrimitiveExpr Members
204196

205-
public bool CanEmitPrimitive
206-
{
207-
get { return _retType.IsPrimitive; }
208-
}
197+
public bool CanEmitPrimitive => _retType.IsPrimitive;
209198

210199
#endregion
211200
}

0 commit comments

Comments
 (0)