Update String to be *str
This commit is contained in:
		
							parent
							
								
									eb99a4c74e
								
							
						
					
					
						commit
						069c277516
					
				| @ -1,5 +1,5 @@ | ||||
| 
 | ||||
| extern fn puts(message: string) -> i32; | ||||
| extern fn puts(message: *str) -> i32; | ||||
| 
 | ||||
| struct DivT { | ||||
|     quotient: i32, | ||||
| @ -8,7 +8,7 @@ struct DivT { | ||||
| 
 | ||||
| extern fn div(numerator: i32, denominator: i32) -> DivT; | ||||
| 
 | ||||
| pub fn print(message: string) { | ||||
| pub fn print(message: *str) { | ||||
|     puts(message); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -31,7 +31,7 @@ pub enum TypeKind { | ||||
|     F128, | ||||
|     F80, | ||||
|     F128PPC, | ||||
|     String, | ||||
|     Str, | ||||
|     Array(Box<TypeKind>, u64), | ||||
|     Custom(String), | ||||
|     Borrow(Box<TypeKind>, bool), | ||||
|  | ||||
| @ -60,7 +60,7 @@ impl Parse for Type { | ||||
|                     "f80" => TypeKind::F80, | ||||
|                     "f128" => TypeKind::F128, | ||||
|                     "f128ppc" => TypeKind::F128PPC, | ||||
|                     "string" => TypeKind::String, | ||||
|                     "str" => TypeKind::Str, | ||||
|                     _ => TypeKind::Custom(ident), | ||||
|                 } | ||||
|             } else { | ||||
|  | ||||
| @ -307,7 +307,7 @@ impl From<ast::TypeKind> for mir::TypeKind { | ||||
|             ast::TypeKind::Array(type_kind, length) => { | ||||
|                 mir::TypeKind::Array(Box::new(mir::TypeKind::from(*type_kind.clone())), *length) | ||||
|             } | ||||
|             ast::TypeKind::String => mir::TypeKind::StringPtr, | ||||
|             ast::TypeKind::Str => mir::TypeKind::Str, | ||||
|             ast::TypeKind::Custom(name) => mir::TypeKind::CustomType(name.clone()), | ||||
|             ast::TypeKind::Borrow(type_kind, mutable) => { | ||||
|                 mir::TypeKind::Borrow(Box::new(mir::TypeKind::from(*type_kind.clone())), *mutable) | ||||
|  | ||||
| @ -247,7 +247,7 @@ impl mir::Module { | ||||
|         insert_debug!(&TypeKind::I64); | ||||
|         insert_debug!(&TypeKind::I128); | ||||
|         insert_debug!(&TypeKind::Void); | ||||
|         insert_debug!(&TypeKind::StringPtr); | ||||
|         insert_debug!(&TypeKind::Str); | ||||
| 
 | ||||
|         for typedef in &self.typedefs { | ||||
|             let type_value = match &typedef.kind { | ||||
| @ -1206,7 +1206,7 @@ impl TypeKind { | ||||
|             TypeKind::F128 => Type::F128, | ||||
|             TypeKind::F80 => Type::F80, | ||||
|             TypeKind::F128PPC => Type::F128PPC, | ||||
|             TypeKind::StringPtr => Type::Ptr(Box::new(Type::I8)), | ||||
|             TypeKind::Str => Type::I8, | ||||
|             TypeKind::Array(elem_t, len) => { | ||||
|                 Type::Array(Box::new(elem_t.get_type(type_vals, typedefs)), *len) | ||||
|             } | ||||
| @ -1257,18 +1257,6 @@ impl TypeKind { | ||||
|         let name = format!("{}", self); | ||||
| 
 | ||||
|         let data = match self { | ||||
|             TypeKind::StringPtr => DebugTypeData::Pointer(DebugPointerType { | ||||
|                 name, | ||||
|                 pointee: TypeKind::I8.get_debug_type_hard( | ||||
|                     scope, | ||||
|                     debug_info, | ||||
|                     debug_types, | ||||
|                     type_values, | ||||
|                     types, | ||||
|                     tokens, | ||||
|                 ), | ||||
|                 size_bits: self.size_of(), | ||||
|             }), | ||||
|             TypeKind::CodegenPtr(inner) | TypeKind::UserPtr(inner) | TypeKind::Borrow(inner, _) => { | ||||
|                 DebugTypeData::Pointer(DebugPointerType { | ||||
|                     name, | ||||
| @ -1358,7 +1346,7 @@ impl TypeKind { | ||||
|                     | TypeKind::F128 | ||||
|                     | TypeKind::F128PPC => DwarfEncoding::Float, | ||||
|                     TypeKind::Void => DwarfEncoding::Address, | ||||
|                     TypeKind::StringPtr => DwarfEncoding::Address, | ||||
|                     TypeKind::Str => DwarfEncoding::UnsignedChar, | ||||
|                     TypeKind::Array(_, _) => DwarfEncoding::Address, | ||||
|                     TypeKind::CustomType(_) => DwarfEncoding::Address, | ||||
|                     _ => panic!("tried fetching debug-type for non-supported type!"), | ||||
|  | ||||
| @ -335,7 +335,7 @@ impl Display for TypeKind { | ||||
|             TypeKind::U64 => write!(f, "u64"), | ||||
|             TypeKind::U128 => write!(f, "u128"), | ||||
|             TypeKind::Void => write!(f, "void"), | ||||
|             TypeKind::StringPtr => write!(f, "string"), | ||||
|             TypeKind::Str => write!(f, "str"), | ||||
|             TypeKind::Array(type_kind, len) => { | ||||
|                 f.write_char('[')?; | ||||
|                 Display::fmt(type_kind, f)?; | ||||
|  | ||||
| @ -43,7 +43,7 @@ impl TypeKind { | ||||
|             TypeKind::U64 => false, | ||||
|             TypeKind::U128 => false, | ||||
|             TypeKind::Void => false, | ||||
|             TypeKind::StringPtr => false, | ||||
|             TypeKind::Str => false, | ||||
|             TypeKind::Array(_, _) => false, | ||||
|             TypeKind::CustomType(_) => false, | ||||
|             TypeKind::CodegenPtr(_) => false, | ||||
| @ -74,7 +74,7 @@ impl TypeKind { | ||||
|             TypeKind::U64 => false, | ||||
|             TypeKind::U128 => false, | ||||
|             TypeKind::Void => false, | ||||
|             TypeKind::StringPtr => false, | ||||
|             TypeKind::Str => false, | ||||
|             TypeKind::Array(_, _) => false, | ||||
|             TypeKind::CustomType(_) => false, | ||||
|             TypeKind::CodegenPtr(_) => false, | ||||
| @ -105,7 +105,7 @@ impl TypeKind { | ||||
|             TypeKind::I128 => 128, | ||||
|             TypeKind::U128 => 128, | ||||
|             TypeKind::Void => 0, | ||||
|             TypeKind::StringPtr => 32, | ||||
|             TypeKind::Str => 8, | ||||
|             TypeKind::Array(type_kind, len) => type_kind.size_of() * len, | ||||
|             TypeKind::CustomType(_) => 32, | ||||
|             TypeKind::CodegenPtr(_) => 64, | ||||
| @ -136,7 +136,7 @@ impl TypeKind { | ||||
|             TypeKind::I128 => 128, | ||||
|             TypeKind::U128 => 128, | ||||
|             TypeKind::Void => 0, | ||||
|             TypeKind::StringPtr => 32, | ||||
|             TypeKind::Str => 8, | ||||
|             TypeKind::Array(type_kind, _) => type_kind.alignment(), | ||||
|             TypeKind::CustomType(_) => 32, | ||||
|             TypeKind::CodegenPtr(_) => 64, | ||||
|  | ||||
| @ -98,7 +98,7 @@ pub enum TypeKind { | ||||
|     F128, | ||||
|     F80, | ||||
|     F128PPC, | ||||
|     StringPtr, | ||||
|     Str, | ||||
|     Array(Box<TypeKind>, u64), | ||||
|     CustomType(String), | ||||
|     Borrow(Box<TypeKind>, bool), | ||||
| @ -185,7 +185,7 @@ impl Literal { | ||||
|             Literal::U64(_) => TypeKind::U64, | ||||
|             Literal::U128(_) => TypeKind::U128, | ||||
|             Literal::Bool(_) => TypeKind::Bool, | ||||
|             Literal::String(_) => TypeKind::StringPtr, | ||||
|             Literal::String(_) => TypeKind::UserPtr(Box::new(TypeKind::Str)), | ||||
|             Literal::Vague(VagueLiteral::Number(_)) => TypeKind::Vague(VagueType::Integer), | ||||
|             Literal::Vague(VagueLiteral::Decimal(_)) => TypeKind::Vague(VagueType::Decimal), | ||||
|             Literal::F16(_) => TypeKind::F16, | ||||
|  | ||||
| @ -742,7 +742,10 @@ impl Literal { | ||||
|                 (L::F128(_), TypeKind::F128) => self, | ||||
|                 (L::F128PPC(_), TypeKind::F128PPC) => self, | ||||
|                 (L::Bool(_), TypeKind::Bool) => self, | ||||
|                 (L::String(_), TypeKind::StringPtr) => self, | ||||
|                 (L::String(_), TypeKind::UserPtr(ptr)) => match *ptr.clone() { | ||||
|                     TypeKind::Str => self, | ||||
|                     _ => Err(ErrorKind::LiteralIncompatible(self, hint.clone()))?, | ||||
|                 }, | ||||
|                 // TODO make sure that v is actually able to fit in the
 | ||||
|                 // requested type
 | ||||
|                 (L::Vague(VagueL::Number(v)), TypeKind::I8) => L::I8(v as i8), | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user