Browse Source

Define constants and return codes

cl-refactor
Paweł Bylica 10 years ago
parent
commit
8fb6de09e4
  1. 7
      evmcc/Type.cpp
  2. 18
      evmcc/Type.h

7
evmcc/Type.cpp

@ -12,6 +12,7 @@ llvm::IntegerType* Type::lowPrecision;
llvm::IntegerType* Type::Byte;
llvm::PointerType* Type::BytePtr;
llvm::Type* Type::Void;
llvm::Type* Type::MainReturn;
void Type::init(llvm::LLVMContext& _context)
{
@ -21,6 +22,12 @@ void Type::init(llvm::LLVMContext& _context)
Byte = llvm::Type::getInt8Ty(_context);
BytePtr = Byte->getPointerTo();
Void = llvm::Type::getVoidTy(_context);
MainReturn = llvm::Type::getInt32Ty(_context);
}
llvm::Constant* Constant::get(ReturnCode _returnCode)
{
return llvm::ConstantInt::get(Type::MainReturn, static_cast<uint64_t>(_returnCode));
}
}

18
evmcc/Type.h

@ -2,6 +2,7 @@
#pragma once
#include <llvm/IR/Type.h>
#include <llvm/IR/Constants.h>
namespace evmcc
{
@ -20,7 +21,24 @@ struct Type
static llvm::Type* Void;
/// Main function return type
static llvm::Type* MainReturn;
static void init(llvm::LLVMContext& _context);
};
enum class ReturnCode
{
Stop = 0,
Return = 1,
Suicide = 2,
BadJumpDestination = 101,
};
struct Constant
{
static llvm::Constant* get(ReturnCode _returnCode);
};
}

Loading…
Cancel
Save