Sync
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
@native @inline
|
||||
@expr(say (&a: String) (b: i32) times)
|
||||
fn say_something(&a: String, b: i32) -> Pack<String,i32> {
|
||||
for index in 0..b {
|
||||
a += a
|
||||
}
|
||||
return {a,b}
|
||||
}
|
||||
*/
|
||||
println("where the huzz")
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
struct Type {
|
||||
name: String,
|
||||
params: Vec<Type>,
|
||||
}
|
||||
struct Decl {
|
||||
name: String,
|
||||
typed: Option<Type>,
|
||||
default: Option<Expr>,
|
||||
}
|
||||
struct Param {
|
||||
borrow: bool,
|
||||
decl: Decl,
|
||||
}
|
||||
struct Call {
|
||||
name: String,
|
||||
params: Vec<Param>,
|
||||
}
|
||||
struct StructEntry {
|
||||
name: Option<String>,
|
||||
value: Expr
|
||||
}
|
||||
struct FuncEntry {
|
||||
name: Option<String>,
|
||||
value: Expr,
|
||||
borrow: bool,
|
||||
}
|
||||
struct Class {
|
||||
name: String,
|
||||
entries: Vec<Decl>,
|
||||
methods: Vec<Function>,
|
||||
}
|
||||
struct Block(Vec<Statement>);
|
||||
struct Function {
|
||||
annotations: Vec<Annotation>,
|
||||
name: String,
|
||||
params: Vec<FuncEntry>,
|
||||
result: Type,
|
||||
}
|
||||
enum Overloaded {
|
||||
Plus,
|
||||
Get,
|
||||
Set,
|
||||
GetIndex,
|
||||
SetIndex,
|
||||
}
|
||||
enum Annotation {
|
||||
Inline,
|
||||
Native,
|
||||
Overload(Overloaded),
|
||||
Expr(String),
|
||||
}
|
||||
enum Statement {
|
||||
DeclLet(Decl),
|
||||
DeclVar(Decl),
|
||||
Assignment {
|
||||
name: String,
|
||||
expr: Expr,
|
||||
},
|
||||
Call(Call),
|
||||
Return(Expr),
|
||||
Block(Block),
|
||||
While(Expr,Box<Statement>),
|
||||
Loop(Box<Statement>),
|
||||
Function(Function),
|
||||
Break,
|
||||
}
|
||||
enum Expr {
|
||||
Paren(Box<Expr>),
|
||||
Call(Call),
|
||||
Add {
|
||||
left: Box<Expr>,
|
||||
right: Box<Expr>,
|
||||
},
|
||||
String(String),
|
||||
Number(String),
|
||||
}
|
||||
|
||||
enum TopLevel {
|
||||
Class(Class),
|
||||
Statement(Statement)
|
||||
}
|
||||
struct Program(Vec<TopLevel>);
|
||||
struct ParseError(String);
|
||||
struct Reader(String);
|
||||
impl Reader {
|
||||
|
||||
}
|
||||
trait Parsed {
|
||||
fn enter(reader: &mut Reader) -> ;
|
||||
fn exit(reader: &mut Reader) -> Result<(), ParseError>;
|
||||
}
|
||||
impl Parsed for TopLevel {
|
||||
|
||||
}
|
||||
impl Parsed for Statement {
|
||||
|
||||
}
|
||||
impl Parsed for Expr {
|
||||
|
||||
}
|
||||
fn parse(source: String) -> Result<Program,ParseError> {
|
||||
Ok(Program(Vec::new()))
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
use game::run;
|
||||
|
||||
fn main() {
|
||||
run().unwrap();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
struct VertexOutput {
|
||||
@builtin(position) clip_position: vec4<f32>,
|
||||
};
|
||||
|
||||
@vertex
|
||||
fn vs_main(
|
||||
@builtin(vertex_index) in_vertex_index: u32,
|
||||
) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
let x = f32(1 - i32(in_vertex_index)) * 0.5;
|
||||
let y = f32(i32(in_vertex_index & 1u) * 2 - 1) * 0.5;
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.3, 0.2, 0.1, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
struct VertexOutput {
|
||||
@builtin(position) clip_position: vec4<f32>,
|
||||
@location(0) color: vec4<f32>
|
||||
};
|
||||
|
||||
@vertex
|
||||
fn vs_main(
|
||||
@builtin(vertex_index) in_vertex_index: u32,
|
||||
) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
let x = f32(1 - i32(in_vertex_index)) * 0.5;
|
||||
let y = f32(i32(in_vertex_index & 1u) * 2 - 1) * 0.5;
|
||||
out.clip_position = vec4<f32>(x, y, 0.0, 1.0);
|
||||
out.color = vec4<f32>(0.3,x,y,1.0);
|
||||
return out;
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn fs_main(@location(0) col: vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return col;
|
||||
}
|
||||
Reference in New Issue
Block a user