Skip to content

Commit 694173b

Browse files
committed
Add basic float builtin type for sus-float
1 parent 77b1f16 commit 694173b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/compiler_top.rs

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ impl Linker {
5353
// Critically, std/core.sus MUST be the first file to be loaded into the linker. Otherwise the IDs don't point to the correct objects
5454
assert_eq!(self.types[get_builtin_type!("int")].link_info.name, "int");
5555
assert_eq!(self.types[get_builtin_type!("bool")].link_info.name, "bool");
56+
assert_eq!(
57+
self.types[get_builtin_type!("float")].link_info.name,
58+
"float"
59+
);
5660

5761
assert_eq!(
5862
self.constants[get_builtin_const!("true")].link_info.name,

src/typing/concrete_type.rs

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ impl ConcreteType {
9898
32 // TODO concrete int sizes
9999
} else if type_ref.id == get_builtin_type!("bool") {
100100
1
101+
} else if type_ref.id == get_builtin_type!("float") {
102+
32
101103
} else {
102104
println!("TODO Named Structs Size");
103105
1 // todo!() // Named structs are not implemented yet

std/core.sus

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ __builtin__ struct bool {}
2828
// An integer of variable size. Right now it's not implemented yet, so this is just a 32-bit int.
2929
__builtin__ struct int {}
3030

31+
// Single precision IEEE 32-bit float. Operators are definted externally, but it's defined here for convenience.
32+
__builtin__ struct float {}
33+
3134
// For intentionally triggering an ICE for debugging. It is a constant that crashes the compiler when it is evaluated
3235
__builtin__ const bool __crash_compiler {}
3336

0 commit comments

Comments
 (0)