Mercurial > projects > ldc
comparison gen/runtime.cpp @ 133:44a95ac7368a trunk
[svn r137] Many fixes towards tango.io.Console working, but not quite there yet...
In particular, assertions has been fixed to include file/line info, and much more!
author | lindquist |
---|---|
date | Mon, 14 Jan 2008 05:11:54 +0100 |
parents | 1700239cab2e |
children | 5c17f81fc1c1 |
comparison
equal
deleted
inserted
replaced
132:1700239cab2e | 133:44a95ac7368a |
---|---|
131 | 131 |
132 ////////////////////////////////////////////////////////////////////////////////////////////////// | 132 ////////////////////////////////////////////////////////////////////////////////////////////////// |
133 | 133 |
134 static const llvm::Type* rt_ptr(const llvm::Type* t) | 134 static const llvm::Type* rt_ptr(const llvm::Type* t) |
135 { | 135 { |
136 return llvm::PointerType::get(t); | 136 return getPtrToType(t); |
137 } | 137 } |
138 | 138 |
139 static const llvm::Type* rt_array(const llvm::Type* elemty) | 139 static const llvm::Type* rt_array(const llvm::Type* elemty) |
140 { | 140 { |
141 std::vector<const llvm::Type*> t; | 141 std::vector<const llvm::Type*> t; |
195 | 195 |
196 ///////////////////////////////////////////////////////////////////////////////////// | 196 ///////////////////////////////////////////////////////////////////////////////////// |
197 ///////////////////////////////////////////////////////////////////////////////////// | 197 ///////////////////////////////////////////////////////////////////////////////////// |
198 ///////////////////////////////////////////////////////////////////////////////////// | 198 ///////////////////////////////////////////////////////////////////////////////////// |
199 | 199 |
200 // assert | 200 // void _d_assert( char[] file, uint line ) |
201 // void _d_assert(bool cond, uint line, char[] msg) | 201 // void _d_array_bounds( char[] file, uint line ) |
202 // void _d_switch_error( char[] file, uint line ) | |
202 { | 203 { |
203 std::string fname("_d_assert"); | 204 std::string fname("_d_assert"); |
204 std::vector<const llvm::Type*> types; | 205 std::string fname2("_d_array_bounds"); |
205 types.push_back(boolTy); | 206 std::string fname3("_d_switch_error"); |
207 std::vector<const llvm::Type*> types; | |
208 types.push_back(stringTy); | |
206 types.push_back(intTy); | 209 types.push_back(intTy); |
210 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
211 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
212 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | |
213 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); | |
214 } | |
215 | |
216 // void _d_assert_msg( char[] msg, char[] file, uint line ) | |
217 { | |
218 std::string fname("_d_assert_msg"); | |
219 std::vector<const llvm::Type*> types; | |
207 types.push_back(stringTy); | 220 types.push_back(stringTy); |
208 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | 221 types.push_back(stringTy); |
222 types.push_back(intTy); | |
223 const llvm::FunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); | |
209 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 224 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
210 } | 225 } |
211 | 226 |
212 ///////////////////////////////////////////////////////////////////////////////////// | 227 ///////////////////////////////////////////////////////////////////////////////////// |
213 ///////////////////////////////////////////////////////////////////////////////////// | 228 ///////////////////////////////////////////////////////////////////////////////////// |
229 { | 244 { |
230 std::string fname("_d_free"); | 245 std::string fname("_d_free"); |
231 std::vector<const llvm::Type*> types; | 246 std::vector<const llvm::Type*> types; |
232 types.push_back(voidPtrTy); | 247 types.push_back(voidPtrTy); |
233 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | 248 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
249 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
250 } | |
251 | |
252 // Object _d_newclass(ClassInfo ci) | |
253 { | |
254 std::string fname("_d_newclass"); | |
255 std::vector<const llvm::Type*> types; | |
256 types.push_back(classInfoTy); | |
257 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
234 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 258 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
235 } | 259 } |
236 | 260 |
237 ///////////////////////////////////////////////////////////////////////////////////// | 261 ///////////////////////////////////////////////////////////////////////////////////// |
238 ///////////////////////////////////////////////////////////////////////////////////// | 262 ///////////////////////////////////////////////////////////////////////////////////// |
624 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | 648 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); |
625 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | 649 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); |
626 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); | 650 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); |
627 } | 651 } |
628 | 652 |
629 } | 653 ///////////////////////////////////////////////////////////////////////////////////// |
630 | 654 ///////////////////////////////////////////////////////////////////////////////////// |
631 | 655 ///////////////////////////////////////////////////////////////////////////////////// |
632 | 656 |
633 | 657 // Object _d_toObject(void* p) |
634 | 658 { |
635 | 659 std::string fname("_d_toObject"); |
660 std::vector<const llvm::Type*> types; | |
661 types.push_back(voidPtrTy); | |
662 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
663 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
664 } | |
665 | |
666 // Object _d_dynamic_cast(Object o, ClassInfo c) | |
667 { | |
668 std::string fname("_d_dynamic_cast"); | |
669 std::vector<const llvm::Type*> types; | |
670 types.push_back(objectTy); | |
671 types.push_back(classInfoTy); | |
672 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
673 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
674 } | |
675 | |
676 // Object _d_interface_cast(void* p, ClassInfo c) | |
677 { | |
678 std::string fname("_d_interface_cast"); | |
679 std::vector<const llvm::Type*> types; | |
680 types.push_back(voidPtrTy); | |
681 types.push_back(classInfoTy); | |
682 const llvm::FunctionType* fty = llvm::FunctionType::get(objectTy, types, false); | |
683 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
684 } | |
685 | |
686 ///////////////////////////////////////////////////////////////////////////////////// | |
687 ///////////////////////////////////////////////////////////////////////////////////// | |
688 ///////////////////////////////////////////////////////////////////////////////////// | |
689 | |
690 // void _d_throw_exception(Object e) | |
691 { | |
692 std::string fname("_d_throw_exception"); | |
693 std::vector<const llvm::Type*> types; | |
694 types.push_back(objectTy); | |
695 const llvm::FunctionType* fty = llvm::FunctionType::get(voidTy, types, false); | |
696 new llvm::Function(fty, llvm::GlobalValue::ExternalLinkage, fname, M); | |
697 } | |
698 } | |
699 | |
700 | |
701 | |
702 | |
703 | |
704 |