@@ -525,13 +525,13 @@ std::string codegen::Context::get_mangled_function_name(std::filesystem::path mo
525525
526526// Types
527527llvm::Type* codegen::Context::as_llvm_type (ast::Type type) {
528- if (type == ast::Type (" float64 " )) return llvm::Type::getDoubleTy (*(this ->context ));
529- else if (type == ast::Type (" int64 " )) return llvm::Type::getInt64Ty (*(this ->context ));
530- else if (type == ast::Type (" int32 " )) return llvm::Type::getInt32Ty (*(this ->context ));
531- else if (type == ast::Type (" int8 " )) return llvm::Type::getInt8Ty (*(this ->context ));
532- else if (type == ast::Type (" bool " )) return llvm::Type::getInt1Ty (*(this ->context ));
533- else if (type == ast::Type (" string " )) return llvm::Type::getInt8PtrTy (*(this ->context ));
534- else if (type == ast::Type (" void " )) return llvm::Type::getVoidTy (*(this ->context ));
528+ if (type == ast::Type (" Float64 " )) return llvm::Type::getDoubleTy (*(this ->context ));
529+ else if (type == ast::Type (" Int64 " )) return llvm::Type::getInt64Ty (*(this ->context ));
530+ else if (type == ast::Type (" Int32 " )) return llvm::Type::getInt32Ty (*(this ->context ));
531+ else if (type == ast::Type (" Int8 " )) return llvm::Type::getInt8Ty (*(this ->context ));
532+ else if (type == ast::Type (" Bool " )) return llvm::Type::getInt1Ty (*(this ->context ));
533+ else if (type == ast::Type (" String " )) return llvm::Type::getInt8PtrTy (*(this ->context ));
534+ else if (type == ast::Type (" None " )) return llvm::Type::getVoidTy (*(this ->context ));
535535 else if (type.is_pointer ()) return this ->as_llvm_type (ast::get_concrete_type (type.as_nominal_type ().parameters [0 ], this ->type_bindings ))->getPointerTo ();
536536 else if (type.is_boxed ()) return this ->as_llvm_type (ast::get_concrete_type (type.as_nominal_type ().parameters [0 ], this ->type_bindings ))->getPointerTo ();
537537 else if (type.is_array ()) {
@@ -598,27 +598,27 @@ codegen::CollectionAsArguments codegen::Context::get_struct_type_as_argument(llv
598598 size_t bytes = 0 ;
599599 while (bytes < 8 ) {
600600 if (fields[i]->isDoubleTy ()) {
601- type = ast::Type (" float64 " );
601+ type = ast::Type (" Float64 " );
602602 bytes += 8 ;
603603 }
604604 else if (fields[i]->isIntegerTy (64 )) {
605- type = ast::Type (" int64 " );
605+ type = ast::Type (" Int64 " );
606606 bytes += 8 ;
607607 }
608608 else if (fields[i]->isIntegerTy (32 )) {
609- type = ast::Type (" int64 " );
609+ type = ast::Type (" Int64 " );
610610 bytes += 4 ;
611611 }
612612 else if (fields[i]->isIntegerTy (8 )) {
613- type = ast::Type (" int64 " );
613+ type = ast::Type (" Int64 " );
614614 bytes += 4 ;
615615 }
616616 else if (fields[i]->isIntegerTy (1 )) {
617- type = ast::Type (" int64 " );
617+ type = ast::Type (" Int64 " );
618618 bytes += 1 ;
619619 }
620620 else if (fields[i]->isPointerTy ()) {
621- type = ast::Type (" int64 " );
621+ type = ast::Type (" Int64 " );
622622 bytes += 8 ;
623623 }
624624 else {
@@ -1011,7 +1011,7 @@ void codegen::Context::codegen(ast::Ast& ast) {
10111011 // Codegen array wrapper type
10121012 llvm::StructType* array_type = llvm::StructType::create (*this ->context , " arrayWrapper" );
10131013 std::vector<llvm::Type*> fields;
1014- fields.push_back (this ->as_llvm_type (ast::Type (" int64 " )));
1014+ fields.push_back (this ->as_llvm_type (ast::Type (" Int64 " )));
10151015 fields.push_back (llvm::Type::getVoidTy (*(this ->context ))->getPointerTo ());
10161016 array_type->setBody (fields);
10171017
@@ -1275,15 +1275,15 @@ void codegen::Context::codegen_function_bodies(std::filesystem::path module_path
12751275 }
12761276
12771277 // Codegen body
1278- if (ast::is_expression (function_body) && return_type != ast::Type (" void " )) {
1278+ if (ast::is_expression (function_body) && return_type != ast::Type (" None " )) {
12791279 llvm::Value* result = this ->codegen (function_body);
12801280 if (result) {
12811281 this ->builder ->CreateRet (result);
12821282 }
12831283 }
12841284 else {
12851285 this ->codegen (function_body);
1286- if (return_type == ast::Type (" void " )) {
1286+ if (return_type == ast::Type (" None " )) {
12871287 this ->builder ->CreateRetVoid ();
12881288 }
12891289 }
@@ -1440,7 +1440,7 @@ llvm::Value* codegen::Context::codegen(ast::ContinueNode& node) {
14401440}
14411441
14421442llvm::Value* codegen::Context::codegen (ast::IfElseNode& node) {
1443- if (ast::is_expression ((ast::Node*) &node) && ast::get_type ((ast::Node*) &node) == ast::Type (" void " )) {
1443+ if (ast::is_expression ((ast::Node*) &node) && ast::get_type ((ast::Node*) &node) == ast::Type (" None " )) {
14441444 llvm::Function *current_function = this ->builder ->GetInsertBlock ()->getParent ();
14451445 llvm::BasicBlock *block = llvm::BasicBlock::Create (*(this ->context ), " then" , current_function);
14461446 llvm::BasicBlock *else_block = llvm::BasicBlock::Create (*(this ->context ), " else" );
@@ -1710,7 +1710,7 @@ llvm::Value* codegen::Context::codegen_size_function(std::variant<llvm::Value*,
17101710
17111711 // Load size
17121712 return this ->builder ->CreateLoad (
1713- this ->as_llvm_type (ast::Type (" int64 " )),
1713+ this ->as_llvm_type (ast::Type (" Int64 " )),
17141714 size_ptr
17151715 );
17161716 }
@@ -1747,7 +1747,7 @@ llvm::Value* codegen::Context::codegen_print_struct_function(ast::Type arg_type,
17471747 );
17481748 }
17491749 else {
1750- std::string print_function_name = this ->get_mangled_function_name (utilities::get_folder_of_executable () + " /std/std" + " .dmd" , " printWithoutLineEnding" , {struct_type.as_nominal_type ().type_definition ->fields [i]->type }, ast::Type (" void " ), false );
1750+ std::string print_function_name = this ->get_mangled_function_name (utilities::get_folder_of_executable () + " /std/std" + " .dmd" , " printWithoutLineEnding" , {struct_type.as_nominal_type ().type_definition ->fields [i]->type }, ast::Type (" None " ), false );
17511751 llvm::Function* llvm_function = this ->module ->getFunction (print_function_name);
17521752 assert (llvm_function);
17531753
@@ -1964,15 +1964,15 @@ llvm::Value* codegen::Context::codegen(ast::FloatNode& node) {
19641964}
19651965
19661966llvm::Value* codegen::Context::codegen (ast::IntegerNode& node) {
1967- if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" float64 " ))
1967+ if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" Float64 " ))
19681968 return llvm::ConstantFP::get (*(this ->context ), llvm::APFloat ((double )node.value ));
1969- else if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" int64 " )) {
1969+ else if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" Int64 " )) {
19701970 return llvm::ConstantInt::get (*(this ->context ), llvm::APInt (64 , node.value , true ));
19711971 }
1972- else if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" int32 " )) {
1972+ else if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" Int32 " )) {
19731973 return llvm::ConstantInt::get (*(this ->context ), llvm::APInt (32 , node.value , true ));
19741974 }
1975- else if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" int8 " )) {
1975+ else if (ast::get_concrete_type ((ast::Node*) &node, this ->type_bindings ) == ast::Type (" Int8 " )) {
19761976 return llvm::ConstantInt::get (*(this ->context ), llvm::APInt (8 , node.value , true ));
19771977 }
19781978
0 commit comments