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
20 changes: 20 additions & 0 deletions IDE/Tests/Test1/scripts/HotSwap_StringLiterals.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ShowFile("src/HotSwap_StringLiterals.bf")

# Build with the literal, then remove its usage and rebuild without cleaning.
ToggleCommentAt("UseString")
Compile()
AssertCompileSucceeded()
ToggleCommentAt("UseString")
Compile()
AssertCompileSucceeded()

GotoText("//StringPool_Start")
ToggleBreakpoint()
RunWithCompiling()
AssertEvalEquals("GetLength()", "0")

# The hot update must emit the literal omitted from the executable being debugged.
ToggleCommentAt("UseString")
Compile()
AssertCompileSucceeded()
AssertEvalEquals("GetLength()", "15")
30 changes: 30 additions & 0 deletions IDE/Tests/Test1/src/HotSwap_StringLiterals.bf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;

#pragma warning disable 168

namespace IDETest
{
class HotSwap_StringLiterals
{
// A separate module lets the literal become unused when its call is removed.
class StringSource
{
public static String GetValue() => "hot-swap string";
}

static int GetLength()
{
int length = 0;
/*UseString
length = StringSource.GetValue().Length;
*/
return length;
}

public static void Test()
{
//StringPool_Start
int length = GetLength();
}
}
}
1 change: 1 addition & 0 deletions IDE/Tests/Test1/src/Program.bf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace IDETest
HotSwap_LiveTypes.Test();
HotSwap_LocateSym01.Test();
HotSwap_Reflection.Test();
HotSwap_StringLiterals.Test();
HotSwap_TLS.Test();
InlineTester.Test();
LambdaTester.Test();
Expand Down
2 changes: 2 additions & 0 deletions IDEHelper/Compiler/BfCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,8 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
CompileLog("VData unchanged, skipping\n");
return;
}
if (!isHotCompile)
bfModule->mDefinedStrings.Clear();

auto typeResolveModule = mContext->mUnreifiedModule;
BfTypeInstance* stringType = typeResolveModule->ResolveTypeDef(mStringTypeDef, BfPopulateType_Data)->ToTypeInstance();
Expand Down
Loading