mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Enum fixes, small reflection fixes
This commit is contained in:
parent
973b5e73cf
commit
dffde00a6a
11 changed files with 100 additions and 35 deletions
|
@ -334,7 +334,7 @@ namespace System
|
|||
|
||||
}
|
||||
|
||||
public this(String error, bool isError)
|
||||
public this(String message, bool isError)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace System.Reflection
|
|||
{
|
||||
extension TypeInstance
|
||||
{
|
||||
public override FieldInfo? GetField(String fieldName)
|
||||
public override Result<FieldInfo> GetField(String fieldName)
|
||||
{
|
||||
for (int32 i = 0; i < mFieldDataCount; i++)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ namespace System.Reflection
|
|||
if (fieldData.mName == fieldName)
|
||||
return FieldInfo(this, fieldData);
|
||||
}
|
||||
return null;
|
||||
return .Err;
|
||||
}
|
||||
|
||||
public override FieldInfo.Enumerator GetFields(BindingFlags bindingFlags = cDefaultLookup)
|
||||
|
|
|
@ -349,6 +349,24 @@ namespace System
|
|||
}
|
||||
}
|
||||
|
||||
public virtual int32 MinValue
|
||||
{
|
||||
[Error("This property can only be accessed directly from a typeof() expression")]
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int32 MaxValue
|
||||
{
|
||||
[Error("This property can only be accessed directly from a typeof() expression")]
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int32 GetTypeId()
|
||||
{
|
||||
return (int32)mTypeId;
|
||||
|
@ -425,9 +443,9 @@ namespace System
|
|||
return type == this;
|
||||
}
|
||||
|
||||
public virtual FieldInfo? GetField(String fieldName)
|
||||
public virtual Result<FieldInfo> GetField(String fieldName)
|
||||
{
|
||||
return null;
|
||||
return .Err;
|
||||
}
|
||||
|
||||
public virtual FieldInfo.Enumerator GetFields(BindingFlags bindingFlags = cDefaultLookup)
|
||||
|
@ -665,7 +683,7 @@ namespace System.Reflection
|
|||
strBuffer.Append(mName);
|
||||
}
|
||||
|
||||
public override FieldInfo? GetField(String fieldName)
|
||||
public override Result<FieldInfo> GetField(String fieldName)
|
||||
{
|
||||
for (int32 i = 0; i < mFieldDataCount; i++)
|
||||
{
|
||||
|
@ -673,7 +691,7 @@ namespace System.Reflection
|
|||
if (fieldData.mName == fieldName)
|
||||
return FieldInfo(this, fieldData);
|
||||
}
|
||||
return null;
|
||||
return .Err;
|
||||
}
|
||||
|
||||
public override FieldInfo.Enumerator GetFields(BindingFlags bindingFlags = cDefaultLookup)
|
||||
|
|
|
@ -132,9 +132,9 @@ WinBFWindow::WinBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
|
|||
::SystemParametersInfo(SPI_GETWORKAREA, NULL, &desktopRect, NULL);
|
||||
|
||||
if (x + width >= desktopRect.right)
|
||||
x = BF_MAX((int)desktopRect.left, requestedX - width);
|
||||
x = BF_MAX((int)desktopRect.left, desktopRect.right - width);
|
||||
if (y + height >= desktopRect.bottom)
|
||||
y = BF_MAX((int)desktopRect.top, requestedY - height);
|
||||
y = BF_MAX((int)desktopRect.top, desktopRect.bottom - height);
|
||||
}
|
||||
|
||||
mFlags = windowFlags;
|
||||
|
|
|
@ -51,8 +51,10 @@ namespace System
|
|||
public static extern void ObjectDynCheck(Object obj, int32 typeId, bool allowNull);
|
||||
public static extern void ObjectDynCheckFailed(Object obj, int32 typeId);
|
||||
public static extern void Dbg_ObjectCreated(Object obj, int size, ClassVData* classVData);
|
||||
public static extern void Dbg_ObjectCreatedEx(Object obj, int size, ClassVData* classVData);
|
||||
public static extern void Dbg_ObjectAllocated(Object obj, int size, ClassVData* classVData);
|
||||
public static extern int Dbg_PrepareStackTrace(int maxDepth);
|
||||
public static extern void Dbg_ObjectAllocatedEx(Object obj, int size, ClassVData* classVData);
|
||||
public static extern int Dbg_PrepareStackTrace(int baseAllocSize, int maxStackTraceDepth);
|
||||
public static extern void Dbg_ObjectStackInit(Object object, ClassVData* classVData);
|
||||
public static extern Object Dbg_ObjectAlloc(TypeInstance typeInst, int size);
|
||||
public static extern Object Dbg_ObjectAlloc(ClassVData* classVData, int size, int align, int maxStackTraceDepth);
|
||||
|
@ -139,6 +141,8 @@ namespace System
|
|||
public static String[] CreateParamsArray()
|
||||
{
|
||||
char8* cmdLine = GetCommandLineArgs();
|
||||
//Windows.MessageBoxA(default, scope String()..AppendF("CmdLine: {0}", StringView(cmdLine)), "HI", 0);
|
||||
|
||||
String[] strVals = null;
|
||||
for (int pass = 0; pass < 2; pass++)
|
||||
{
|
||||
|
@ -151,21 +155,40 @@ namespace System
|
|||
var str = new String(len);
|
||||
char8* outStart = str.Ptr;
|
||||
char8* outPtr = outStart;
|
||||
bool inQuote = false;
|
||||
|
||||
for (int i < len)
|
||||
{
|
||||
char8 c = cmdLine[idx + i];
|
||||
if (c == '\"')
|
||||
|
||||
if (!inQuote)
|
||||
{
|
||||
if ((cmdLine[idx + i + 1] == '\"') &&
|
||||
(cmdLine[idx + i + 2] == '\"'))
|
||||
if (c == '"')
|
||||
{
|
||||
*(outPtr++) = '\"';
|
||||
i += 2;
|
||||
inQuote = true;
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c == '^')
|
||||
{
|
||||
i++;
|
||||
c = cmdLine[idx + i];
|
||||
}
|
||||
else if (c == '\"')
|
||||
{
|
||||
if (cmdLine[idx + i + 1] == '\"')
|
||||
{
|
||||
*(outPtr++) = '\"';
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
inQuote = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
*(outPtr++) = c;
|
||||
}
|
||||
str.[Friend]mLength = (.)(outPtr - outStart);
|
||||
|
@ -195,6 +218,10 @@ namespace System
|
|||
{
|
||||
if (firstCharIdx == -1)
|
||||
firstCharIdx = i;
|
||||
if (c == '^')
|
||||
{
|
||||
i++;
|
||||
}
|
||||
if (c == '"')
|
||||
inQuote = !inQuote;
|
||||
else if ((inQuote) && (c == '\\'))
|
||||
|
@ -225,4 +252,22 @@ namespace System
|
|||
extern static this();
|
||||
extern static ~this();
|
||||
}
|
||||
|
||||
struct CRTAlloc
|
||||
{
|
||||
public void* Alloc(int size, int align)
|
||||
{
|
||||
return Internal.StdMalloc(size);
|
||||
}
|
||||
|
||||
public void Free(void* ptr)
|
||||
{
|
||||
Internal.StdFree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
public static CRTAlloc gCRTAlloc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -994,6 +994,7 @@ void COFF::CvParseMembers(DbgType* parentType, int tagIdx, bool ipi)
|
|||
parentType->mTypeParam = CvGetType(fieldTypeId);
|
||||
if ((parentType->mBaseTypes.mHead != NULL) && (strcmp(parentType->mBaseTypes.mHead->mBaseType->mName, "System.Enum") == 0))
|
||||
parentType->mTypeCode = DbgType_Enum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -437,6 +437,7 @@ bool BfContext::ProcessWorkList(bool onlyReifiedTypes, bool onlyReifiedMethods)
|
|||
continue;
|
||||
|
||||
auto methodSpecializationRequest = *workItemRef;
|
||||
|
||||
auto module = workItemRef->mFromModule;
|
||||
workIdx = mMethodSpecializationWorkList.RemoveAt(workIdx);
|
||||
|
||||
|
@ -2339,11 +2340,6 @@ void BfContext::QueueMethodSpecializations(BfTypeInstance* typeInst, bool checkS
|
|||
return;
|
||||
}
|
||||
|
||||
if ((module->mModuleName == "System_Array") && (!mCompiler->mIsResolveOnly))
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
// Find any method specialization requests for types that are rebuilding, but from
|
||||
// modules that are NOT rebuilding to be sure we generate those. Failure to do this
|
||||
// will cause a link error from an old module
|
||||
|
|
|
@ -16163,6 +16163,7 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
|||
MarkResultUsed();
|
||||
|
||||
mModule->FixIntUnknown(mResult);
|
||||
mModule->PopulateType(mResult.mType);
|
||||
auto ptrType = mModule->CreatePointerType(mResult.mType);
|
||||
if ((!CheckModifyResult(mResult, unaryOpExpr, "take address of")) || (mResult.mType->IsValuelessType()))
|
||||
{
|
||||
|
@ -16194,6 +16195,7 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
|||
return;
|
||||
}
|
||||
|
||||
mModule->PopulateType(resolvedType);
|
||||
if (resolvedType->IsValuelessType())
|
||||
mResult = BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), resolvedType, true);
|
||||
else
|
||||
|
|
|
@ -1097,7 +1097,7 @@ void BfModule::EnsureIRBuilder(bool dbgVerifyCodeGen)
|
|||
// code as we walk the AST
|
||||
//mBfIRBuilder->mDbgVerifyCodeGen = true;
|
||||
if (
|
||||
(mModuleName == "IDE_ui_LaunchDialog")
|
||||
(mModuleName == "Blurg")
|
||||
//|| (mModuleName == "System_Internal")
|
||||
//|| (mModuleName == "vdata")
|
||||
//|| (mModuleName == "Hey_Dude_Bro_TestClass")
|
||||
|
@ -11064,6 +11064,7 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
|||
specializationRequest->mMethodDef = methodDef;
|
||||
specializationRequest->mMethodGenericArguments = methodGenericArguments;
|
||||
specializationRequest->mType = typeInst;
|
||||
specializationRequest->mFlags = flags;
|
||||
}
|
||||
|
||||
auto defFlags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline);
|
||||
|
@ -11770,11 +11771,6 @@ void BfModule::HadSlotCountDependency()
|
|||
|
||||
BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
|
||||
{
|
||||
if (fieldInstance->mResolvedType->IsVar())
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (mIsScratchModule)
|
||||
{
|
||||
// Just fake it for the extern and unspecialized modules
|
||||
|
|
|
@ -1869,7 +1869,12 @@ void BfTupleType::Finish()
|
|||
BfType* BfBoxedType::GetModifiedElementType()
|
||||
{
|
||||
if ((mBoxedFlags & BoxedFlags_StructPtr) != 0)
|
||||
return mModule->CreatePointerType(mElementType);
|
||||
{
|
||||
auto module = mModule;
|
||||
if (module == NULL)
|
||||
module = mContext->mUnreifiedModule;
|
||||
return module->CreatePointerType(mElementType);
|
||||
}
|
||||
return mElementType;
|
||||
}
|
||||
|
||||
|
|
|
@ -1412,7 +1412,9 @@ DbgType* DbgType::GetPrimaryType()
|
|||
((mCompileUnit->mLanguage == DbgLanguage_Beef) || (mTypeCode == DbgType_Namespace) || (mIsDeclaration)))
|
||||
{
|
||||
mPrimaryType = mCompileUnit->mDbgModule->GetPrimaryType(this);
|
||||
mPrimaryType->PopulateType();
|
||||
mTypeCode = mPrimaryType->mTypeCode;
|
||||
mTypeParam = mPrimaryType->mTypeParam;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue