untracked files and changes
This commit is contained in:
parent
cbbbb7989a
commit
006e982cde
13
src/ast.rs
13
src/ast.rs
|
@ -197,6 +197,19 @@ pub enum Tag {
|
|||
body: Node,
|
||||
else_expr: Node,
|
||||
},
|
||||
// TODO: implement this:
|
||||
// /// if expression whose body consists of a single expression
|
||||
// SimpleIfExpr {
|
||||
// condition: Node,
|
||||
// body: Node,
|
||||
// },
|
||||
// /// if expression whose body consists of a single expression,
|
||||
// /// and whose else-expr is one of: SimpleIfExpr, SimpleIfElseExpr, Expr
|
||||
// SimpleIfElseExpr {
|
||||
// condition: Node,
|
||||
// body: Node,
|
||||
// else_expr: Node,
|
||||
// },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
78
src/intern_pool.rs
Normal file
78
src/intern_pool.rs
Normal file
|
@ -0,0 +1,78 @@
|
|||
struct Symbol {
|
||||
name: Index,
|
||||
}
|
||||
|
||||
struct Pools {
|
||||
bytes: Vec<u8>,
|
||||
symbols: Vec<Symbol>,
|
||||
}
|
||||
|
||||
type Data = u32;
|
||||
|
||||
struct InternPool {
|
||||
tags: Vec<Tag>,
|
||||
data: Vec<Data>,
|
||||
}
|
||||
|
||||
enum Tag {
|
||||
TypeSInt,
|
||||
TypeUInt,
|
||||
}
|
||||
|
||||
// #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
// #[allow(non_camel_case_types)]
|
||||
// #[repr(u32)]
|
||||
// #[non_exhaustive]
|
||||
// enum Index {
|
||||
// u0_type,
|
||||
// i0_type,
|
||||
// u1_type,
|
||||
// i1_type,
|
||||
// u8_type,
|
||||
// i8_type,
|
||||
// u16_type,
|
||||
// i16_type,
|
||||
// u32_type,
|
||||
// i32_type,
|
||||
// u64_type,
|
||||
// i64_type,
|
||||
// usize_type,
|
||||
// isize_type,
|
||||
// bool_type,
|
||||
// void_type,
|
||||
// f32_type,
|
||||
// f64_type,
|
||||
|
||||
// zero_u8,
|
||||
// zero_u32,
|
||||
// zero_usize,
|
||||
// one_u8,
|
||||
// one_u32,
|
||||
// one_usize,
|
||||
// false_value,
|
||||
// true_value,
|
||||
|
||||
// None = u32::MAX,
|
||||
// }
|
||||
|
||||
// const static_keys: [Key; 14] = [
|
||||
// Key::UInt { bits: 0 },
|
||||
// Key::SInt { bits: 0 },
|
||||
// Key::UInt { bits: 1 },
|
||||
// Key::SInt { bits: 1 },
|
||||
// Key::UInt { bits: 8 },
|
||||
// Key::SInt { bits: 8 },
|
||||
// Key::UInt { bits: 16 },
|
||||
// Key::SInt { bits: 16 },
|
||||
// Key::UInt { bits: 32 },
|
||||
// Key::SInt { bits: 32 },
|
||||
// Key::UInt { bits: 64 },
|
||||
// Key::SInt { bits: 64 },
|
||||
// Key::UInt { bits: 64 },
|
||||
// Key::SInt { bits: 64 },
|
||||
// ];
|
||||
|
||||
// enum Key {
|
||||
// SInt { bits: u16 },
|
||||
// UInt { bits: u16 },
|
||||
// }
|
0
src/mangle.rs
Normal file
0
src/mangle.rs
Normal file
33
test.c
Normal file
33
test.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern float inverse_sqrt(float);
|
||||
extern float inverse_sqrt(float);
|
||||
extern int square_of_greater(int, int);
|
||||
|
||||
float Q_rsqrt(float number)
|
||||
{
|
||||
long i;
|
||||
float x2, y;
|
||||
const float threehalfs = 1.5F;
|
||||
|
||||
x2 = number * 0.5F;
|
||||
y = number;
|
||||
i = * ( long * ) &y; // evil floating point bit level hacking
|
||||
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
|
||||
y = * ( float * ) &i;
|
||||
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
|
||||
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("hello, world!\n");
|
||||
float n = 4.0;
|
||||
float i = inverse_sqrt(n);
|
||||
printf("%f = inverse_sqrt(%f)\n", i, n);
|
||||
printf("%f = Q_rsqrt(%f)\n", Q_rsqrt(4.0), 4.0);
|
||||
printf("%d = square_of_greater(4,5)\n", square_of_greater(4, 5));
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue