diff --git a/BeefLibs/corlib/src/Attribute.bf b/BeefLibs/corlib/src/Attribute.bf index 4bd007b0..6832ba09 100644 --- a/BeefLibs/corlib/src/Attribute.bf +++ b/BeefLibs/corlib/src/Attribute.bf @@ -334,7 +334,7 @@ namespace System } - public this(String error, bool isError) + public this(String message, bool isError) { } diff --git a/BeefLibs/corlib/src/Reflection/TypeInstance.bf b/BeefLibs/corlib/src/Reflection/TypeInstance.bf index 520e18b2..8169eb1a 100644 --- a/BeefLibs/corlib/src/Reflection/TypeInstance.bf +++ b/BeefLibs/corlib/src/Reflection/TypeInstance.bf @@ -39,7 +39,7 @@ namespace System.Reflection { extension TypeInstance { - public override FieldInfo? GetField(String fieldName) + public override Result 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) diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index 8977553c..ff103f96 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -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 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 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) diff --git a/BeefySysLib/platform/win/WinBFApp.cpp b/BeefySysLib/platform/win/WinBFApp.cpp index 801a0f3d..2f1e1945 100644 --- a/BeefySysLib/platform/win/WinBFApp.cpp +++ b/BeefySysLib/platform/win/WinBFApp.cpp @@ -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; diff --git a/IDE/mintest/minlib/src/System/Internal.bf b/IDE/mintest/minlib/src/System/Internal.bf index 16c978ad..1d1e6de2 100644 --- a/IDE/mintest/minlib/src/System/Internal.bf +++ b/IDE/mintest/minlib/src/System/Internal.bf @@ -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; + } } diff --git a/IDEHelper/COFF.cpp b/IDEHelper/COFF.cpp index 5952a7f9..654e3230 100644 --- a/IDEHelper/COFF.cpp +++ b/IDEHelper/COFF.cpp @@ -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; } } diff --git a/IDEHelper/Compiler/BfContext.cpp b/IDEHelper/Compiler/BfContext.cpp index 8b62c4c0..d85196e7 100644 --- a/IDEHelper/Compiler/BfContext.cpp +++ b/IDEHelper/Compiler/BfContext.cpp @@ -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 diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index b5e1dbec..ef6e8e15 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -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 diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 9e9e19d4..ca7368f1 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -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") @@ -11036,7 +11036,7 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM BF_ASSERT(instModule == mParentModule); } else if (instModule != this) - { + { if ((!mIsReified) && (instModule->mIsReified)) { BF_ASSERT(!mCompiler->mIsResolveOnly); @@ -11064,10 +11064,11 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM specializationRequest->mMethodDef = methodDef; specializationRequest->mMethodGenericArguments = methodGenericArguments; specializationRequest->mType = typeInst; + specializationRequest->mFlags = flags; } auto defFlags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline); - + // Not extern // Create the instance in the proper module and then create a reference in this one moduleMethodInst = instModule->GetMethodInstance(typeInst, methodDef, methodGenericArguments, defFlags, foreignType); @@ -11769,12 +11770,7 @@ void BfModule::HadSlotCountDependency() } BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance) -{ - if (fieldInstance->mResolvedType->IsVar()) - { - NOP; - } - +{ if (mIsScratchModule) { // Just fake it for the extern and unspecialized modules @@ -19490,7 +19486,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool // CheckHotMethod(methodInstance, mangledName); BfLogSysM("DoMethodDeclaration %s Module: %p Type: %p MethodInst: %p Reified: %d Unspecialized: %d IRFunction: %d MethodId:%llx\n", mangledName.c_str(), this, mCurTypeInstance, methodInstance, methodInstance->mIsReified, mCurTypeInstance->IsUnspecializedType(), methodInstance->mIRFunction.mId, methodInstance->mIdHash); - + SizedArray diParams; diParams.push_back(mBfIRBuilder->DbgGetType(resolvedReturnType)); diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index 3a02432b..dc372957 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -1867,9 +1867,14 @@ 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; } diff --git a/IDEHelper/DbgModule.cpp b/IDEHelper/DbgModule.cpp index fca0a641..e4891b82 100644 --- a/IDEHelper/DbgModule.cpp +++ b/IDEHelper/DbgModule.cpp @@ -1410,9 +1410,11 @@ DbgType* DbgType::GetPrimaryType() { if ((mCompileUnit != NULL) && ((mCompileUnit->mLanguage == DbgLanguage_Beef) || (mTypeCode == DbgType_Namespace) || (mIsDeclaration))) - { - mPrimaryType = mCompileUnit->mDbgModule->GetPrimaryType(this); + { + mPrimaryType = mCompileUnit->mDbgModule->GetPrimaryType(this); + mPrimaryType->PopulateType(); mTypeCode = mPrimaryType->mTypeCode; + mTypeParam = mPrimaryType->mTypeParam; } }