Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiled locks #1561

Merged
merged 1 commit into from
Mar 30, 2016
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
5 changes: 5 additions & 0 deletions src/kOS.Safe/Compilation/KS/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,11 @@ private void PreProcessUserFunctionStatement(ParseNode node)

if (userFuncObject.IsSystemLock())
{
AddOpcode(new OpcodePush(userFuncObject.ScopelessPointerIdentifier));
AddOpcode(new OpcodeExists());
var branch = new OpcodeBranchIfTrue();
branch.Distance = 4;
AddOpcode(branch);
AddOpcode(new OpcodePush(userFuncObject.ScopelessPointerIdentifier));
AddOpcode(new OpcodePushRelocateLater(null), userFuncObject.DefaultLabel);
AddOpcode(new OpcodeStore());
Expand Down
2 changes: 2 additions & 0 deletions src/kOS.Safe/Compilation/ProgramBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ private void ReplaceLabels(List<Opcode> program)
{
if (labels.ContainsKey(program[index].Label))
{
if (program[index].Label.EndsWith("-default"))
continue;
// This is one of those "should never happen" errors that if it happens
// it means kOS devs screwed up - so dump the partially relabeled program
// to the log just to help in diagnosing the bug report that may happen:
Expand Down