char Tokenizer::GetNextChar() { UnwindStack(); //std::string tmp; if (include_stack.empty()) return 0; char c = (*include_stack.back().stream).get(); if ((!skip_eol) && (c == 10 || c == 13)) { // end of line include_stack.back().line += 1; include_stack.back().column = 1; // if next is different we'll skip it. //std::istream &stream=(*include_stack.back().stream); char nc = (*include_stack.back().stream).peek(); if ((nc == 10 || nc == 13) && (nc != c)) skip_eol = true; } else { if (!skip_eol) include_stack.back().column += 1; skip_eol = false; } return c; }
char Tokenizer::PeekNextChar() { UnwindStack(); //std::string tmp; char tmp = 0; if (!include_stack.empty()) tmp = (*include_stack.back().stream).peek(); return tmp; }
Function::Function(Module& pModule, llvm::Function& function, const ArgInfo& argInfo, TemplateBuilder* pTemplateBuilder) : module_(pModule), function_(function), entryBuilder_(pModule.getLLVMContext()), builder_(pModule.getLLVMContext()), createdEntryBlock_(false), useEntryBuilder_(false), argInfo_(argInfo), templateBuilder_(pTemplateBuilder), #if LOCIC_LLVM_VERSION < 307 debugInfo_(nullptr), #endif exceptionInfo_(nullptr), returnValuePtr_(nullptr), templateArgs_(nullptr), unwindState_(nullptr) { assert(function.isDeclaration()); assert(argInfo_.numArguments() == function_.getFunctionType()->getNumParams()); // Add a bottom level unwind stack. unwindStackStack_.push(UnwindStack()); // Add bottom level action for this function. unwindStack().push_back(UnwindAction::FunctionMarker()); const auto startBB = createBasicBlock(""); builder_.SetInsertPoint(startBB); argValues_.reserve(function_.arg_size()); for (auto arg = function_.arg_begin(); arg != function_.arg_end(); ++arg) { argValues_.push_back(arg); } std::vector<llvm_abi::Type*> argABITypes; argABITypes.reserve(argInfo.argumentTypes().size()); std::vector<llvm::Type*> argLLVMTypes; argLLVMTypes.reserve(argInfo.argumentTypes().size()); for (const auto& typePair : argInfo.argumentTypes()) { argABITypes.push_back(typePair.first); argLLVMTypes.push_back(typePair.second); } SetUseEntryBuilder useEntryBuilder(*this); // Decode arguments according to ABI. decodeABIValues(argValues_, argABITypes, argLLVMTypes); }
void Function::pushUnwindStack(size_t position) { // Position needs to include top level function action. assert(position >= 1); unwindStackStack_.push(UnwindStack(unwindStack().begin(), unwindStack().begin() + position)); }
bool Tokenizer::Good() { UnwindStack(); return (errors == 0) && !include_stack.empty(); }