Skip to content

Commit

Permalink
Use fixed width integer types in Compiler
Browse files Browse the repository at this point in the history
- Contributes to #535
- Contributes to #531
- Also address many code analysis issues from VS19 in-IDE parser
  - e.g. Use of enum class in preference to unscoped enums
- Define specific integer types (using enum class) for IPs and text positions to help identify
errors
  • Loading branch information
blairmcg committed Dec 2, 2019
1 parent f3cce4e commit 7713a8f
Show file tree
Hide file tree
Showing 24 changed files with 2,705 additions and 2,365 deletions.
5 changes: 4 additions & 1 deletion Core/DolphinVM/Compiler/Compiler.idl
Expand Up @@ -144,7 +144,10 @@ library CompilerLib
CInfoLast = CInfoHardBreakpoint
} FirstAndLastCodes;

typedef enum FLAGS {Default=0x00, SyntaxCheckOnly=0x02, NoOptimize=0x08, TextMap=0x10, TempsMap=0x20, DebugMethod=0x40, Boot=0x80, ScanOnly=0x100, Interactive=0x200, SendYourself=0x400} FLAGS;
cpp_quote("#define class_CompilerFlags class CompilerFlags")
typedef enum class_CompilerFlags
{Default=0x00, SyntaxCheckOnly=0x02, NoOptimize=0x08, TextMap=0x10, TempsMap=0x20, DebugMethod=0x40, Boot=0x80, ScanOnly=0x100, Interactive=0x200, SendYourself=0x400} FLAGS;
cpp_quote("#undef CompilerFlags")

[
object,
Expand Down
4 changes: 2 additions & 2 deletions Core/DolphinVM/Compiler/CompilerSupport.cpp
Expand Up @@ -14,15 +14,15 @@ be thrown away eventually, or perhaps compiled into a separate DLL.

#include "..\VMPointers.h"

POTE Compiler::NewCompiledMethod(POTE classPointer, unsigned numBytes, const STMethodHeader& hdr)
POTE Compiler::NewCompiledMethod(POTE classPointer, size_t numBytes, const STMethodHeader& hdr)
{
//_ASSERTE(ObjectMemory::inheritsFrom(classPointer, GetVMPointers().ClassCompiledMethod));
// Note we subtract
POTE methodPointer = m_piVM->NewObjectWithPointers(classPointer,
((sizeof(STCompiledMethod)
- sizeof(Oop) // Deduct dummy literal frame entry (arrays cannot be zero sized in IDL)
// -sizeof(ObjectHeader) // Deduct size of head which NewObjectWithPointers includes implicitly
) / sizeof(Oop)) + GetLiteralCount());
) / sizeof(Oop)) + LiteralCount);
STCompiledMethod* method = reinterpret_cast<STCompiledMethod*>(GetObj(methodPointer));
POTE bytes = m_piVM->NewByteArray(numBytes);
m_piVM->StorePointerWithValue((Oop*)&method->byteCodes, Oop(bytes));
Expand Down

0 comments on commit 7713a8f

Please sign in to comment.