2019-09-21 10:49:35 -07:00
|
|
|
//GORB
|
|
|
|
#pragma warning disable 168
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
//#define A
|
|
|
|
//#define B
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct StructA
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
public int mA;
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static StructA operator+(StructA lhs, float rhs)
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
StructA newVal = .();
|
|
|
|
newVal.mA = lhs.mA + (int)rhs;
|
|
|
|
return newVal;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct StructB
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
public int mA;
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static bool operator==(StructA lhs, StructB rhs)
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
return lhs.mA == rhs.mA;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct StructC
|
|
|
|
{
|
|
|
|
public int mA;
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static operator StructD(StructC val)
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
StructD conv;
|
|
|
|
conv.mA = val.mA;
|
|
|
|
return conv;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct StructD
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
public int mA;
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static operator StructD(StructC val)
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
StructC conv;
|
|
|
|
conv.mA = val.mA;
|
|
|
|
return conv;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct StructE
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
|
|
|
public int mA;
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static operator StructD(StructE val)
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
StructC conv;
|
|
|
|
conv.mA = val.mA;
|
|
|
|
return conv;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
class ClassA
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
public int mA;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct StructK
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct StructL : StructK
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
public int mA;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
struct Checker
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
public static int CheckIt(int* iPtr, int len)
|
2019-09-29 07:44:39 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
int acc = 0;
|
|
|
|
for (int i < len)
|
|
|
|
{
|
|
|
|
acc += iPtr[i];
|
|
|
|
}
|
|
|
|
return acc;
|
2019-09-29 07:44:39 -07:00
|
|
|
}
|
2019-09-29 09:21:51 -07:00
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static int CheckItSpan(int* iPtr, int len)
|
2019-09-29 09:21:51 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
Span<int> span = .(iPtr, len);
|
2019-09-29 09:21:51 -07:00
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
int acc = 0;
|
|
|
|
for (int i < len)
|
2019-10-09 16:20:09 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
acc += span[i];
|
2019-10-09 16:20:09 -07:00
|
|
|
}
|
2019-11-25 06:48:19 -08:00
|
|
|
return acc;
|
2019-09-29 09:21:51 -07:00
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static int CheckItSpanOpt(int* iPtr, int len)
|
2019-09-29 09:21:51 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
OptSpan<int> span = .(iPtr, len);
|
2019-09-29 09:21:51 -07:00
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
int acc = 0;
|
|
|
|
for (int i < len)
|
2019-09-29 09:21:51 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
acc += span[i];
|
2019-09-29 09:21:51 -07:00
|
|
|
}
|
2019-11-25 06:48:19 -08:00
|
|
|
return acc;
|
2019-10-09 16:20:09 -07:00
|
|
|
}
|
2019-09-29 07:44:39 -07:00
|
|
|
}
|
|
|
|
|
2019-10-09 16:20:09 -07:00
|
|
|
struct Blurg
|
2019-09-29 07:44:39 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
static int GetHash<T>(T val) where T : IHashable
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
return val.GetHashCode();
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
|
2019-11-25 06:48:19 -08:00
|
|
|
public static int32 LongCall(
|
|
|
|
int abcdefghijklmnopqrstuvwxyz0,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz1,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz2,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz3,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz4,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz5,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz6,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz7,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz8,
|
|
|
|
int abcdefghijklmnopqrstuvwxyz9
|
|
|
|
)
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-25 06:48:19 -08:00
|
|
|
return 0;
|
2019-09-21 10:49:35 -07:00
|
|
|
}
|
|
|
|
|
2019-11-27 08:02:15 -08:00
|
|
|
static mixin ScopedAlloc(int size, int align)
|
|
|
|
{
|
|
|
|
//(void*)scope:mixin [Align(align)] uint8[size]* { ? }
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void TestAlloc()
|
|
|
|
{
|
|
|
|
int i = 1;
|
|
|
|
if (i == 1)
|
|
|
|
{
|
|
|
|
int size = 128;
|
|
|
|
scope:: int[size]*;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct StructA
|
|
|
|
{
|
|
|
|
public int[10] mA;
|
2019-11-29 09:24:13 -08:00
|
|
|
|
|
|
|
public this()
|
|
|
|
{
|
|
|
|
mA = default;
|
|
|
|
void* v = &this;
|
|
|
|
}
|
2019-11-27 08:02:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
enum EnumA
|
|
|
|
{
|
|
|
|
case None;
|
|
|
|
case A(StructA sa);
|
|
|
|
}
|
|
|
|
|
|
|
|
enum EnumB
|
|
|
|
{
|
|
|
|
case A;
|
|
|
|
case B(int a, int b);
|
|
|
|
}
|
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
/*[DisableChecks]
|
|
|
|
public static float GetSum<TCount>(float[TCount] vals) where TCount : const int
|
2019-09-21 10:49:35 -07:00
|
|
|
{
|
2019-11-29 09:24:13 -08:00
|
|
|
float total = 0;
|
|
|
|
for (int i < vals.Count)
|
|
|
|
total += vals[i];
|
|
|
|
return total;
|
|
|
|
}
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
public static void Max<T, TFunc>(T lhs, T rhs, TFunc func) where TFunc : delegate int(T lhs, T rhs)
|
|
|
|
{
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
}*/
|
2019-10-09 16:20:09 -07:00
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
struct Base
|
|
|
|
{
|
|
|
|
int32 mA;
|
|
|
|
int64 mB;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Derived : Base
|
|
|
|
{
|
|
|
|
int8 mC;
|
|
|
|
}
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
static int[] gArr = new .(1, 2, 3, 4, 5, );
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
[Checked]
|
|
|
|
public static int32 GetVal()
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
[Unchecked]
|
|
|
|
public static int32 GetVal()
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
public static int32 GetVal2()
|
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
2019-09-21 10:49:35 -07:00
|
|
|
|
2019-11-29 09:24:13 -08:00
|
|
|
public static int32 Hey()
|
|
|
|
{
|
|
|
|
/*Self.[Checked]GetVal();
|
|
|
|
Self.[Unchecked]GetVal();
|
|
|
|
GetVal2();*/
|
|
|
|
|
|
|
|
int a = gArr[1];
|
|
|
|
a = gArr[[Unchecked]2];
|
|
|
|
|
|
|
|
return (int32)123;
|
2019-09-29 07:44:39 -07:00
|
|
|
}
|
2019-09-21 10:49:35 -07:00
|
|
|
|
|
|
|
}
|
2019-11-29 09:24:13 -08:00
|
|
|
|