Skip to content
Open
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
30 changes: 30 additions & 0 deletions src/ScriptEngine/Compiler/CodeGeneratorPrivateTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,35 @@ public static NestedLoopInfo New()
public List<int> breakStatements;
public int tryNesting;
}

private enum BlockType
{
While,
ForEach,
For,
If,
ElseIf,
Else,
Try,
Except
}

private class LabelInfo
{
public int codeIndex = DUMMY_ADDRESS;
public List<(BlockType type, int id)> blockStack;
public int tryNesting;
}

private struct PendingGoto
{
public int commandIndex;
public int exitTryIndex;
public string labelName;
public List<(BlockType type, int id)> blockStack;
public List<(int commandIndex, BlockType loopType, int blockId)> loopCleanupSlots;
public CodeRange location;
public int tryNesting;
}
}
}
12 changes: 12 additions & 0 deletions src/ScriptEngine/Compiler/CompilerErrors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ public static CodeError MissedImport(string symbol, string libName) =>
Create($"Свойство {symbol} принадлежит пакету {libName}, который не импортирован в данном модуле",
$"Property {symbol} belongs to package {libName} which is not imported in this module");

public static CodeError DuplicateLabelDefinition(string name) =>
Create($"Дублирование определения метки ~{name}",
$"Duplicate label definition ~{name}");

public static CodeError UndefinedLabel(string name) =>
Create($"Метка не определена ~{name}",
$"Undefined label ~{name}");

public static CodeError InvalidGotoTarget(string name) =>
Create($"На метку с указанным именем имеется недопустимый переход (~{name})",
$"Invalid goto target (~{name})");

private static CodeError Create(string ru, string en, [CallerMemberName] string errorId = default)
{
return new CodeError
Expand Down
Loading