mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
match IntVal and FloatVal cases
This commit is contained in:
parent
9ebe767a6a
commit
8a1e38ab5b
2 changed files with 32 additions and 10 deletions
|
@ -304,7 +304,13 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render::render_expr2(&size, &expr2, CODE_TXT_XY.into(), &mut glyph_brush);
|
render::render_expr2(
|
||||||
|
&arena,
|
||||||
|
&size,
|
||||||
|
&expr2,
|
||||||
|
CODE_TXT_XY.into(),
|
||||||
|
&mut glyph_brush,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
match draw_all_rects(
|
match draw_all_rects(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use bumpalo::Bump;
|
||||||
use cgmath::Vector2;
|
use cgmath::Vector2;
|
||||||
use wgpu_glyph::GlyphBrush;
|
use wgpu_glyph::GlyphBrush;
|
||||||
use winit::dpi::PhysicalSize;
|
use winit::dpi::PhysicalSize;
|
||||||
|
@ -8,53 +9,68 @@ use crate::{
|
||||||
primitives::text::{queue_code_text_draw, Text},
|
primitives::text::{queue_code_text_draw, Text},
|
||||||
style::CODE_FONT_SIZE,
|
style::CODE_FONT_SIZE,
|
||||||
},
|
},
|
||||||
lang::ast::Expr2,
|
lang::ast::{Expr2, FloatVal, IntVal},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn render_expr2(
|
pub fn render_expr2<'a>(
|
||||||
|
_arena: &'a Bump,
|
||||||
size: &PhysicalSize<u32>,
|
size: &PhysicalSize<u32>,
|
||||||
expr2: &Expr2,
|
expr2: &Expr2,
|
||||||
position: Vector2<f32>,
|
position: Vector2<f32>,
|
||||||
glyph_brush: &mut GlyphBrush<()>,
|
glyph_brush: &mut GlyphBrush<()>,
|
||||||
) {
|
) {
|
||||||
use Expr2::*;
|
|
||||||
|
|
||||||
let area_bounds = (size.width as f32, size.height as f32).into();
|
let area_bounds = (size.width as f32, size.height as f32).into();
|
||||||
|
|
||||||
match expr2 {
|
match expr2 {
|
||||||
SmallInt {
|
Expr2::SmallInt {
|
||||||
number,
|
number,
|
||||||
..
|
..
|
||||||
// text,
|
// text,
|
||||||
// style, pretending always decimal for now
|
// style, pretending always decimal for now
|
||||||
// var,
|
// var,
|
||||||
} => {
|
} => {
|
||||||
|
let text = match number {
|
||||||
|
IntVal::I64(val) => format!("{}", val),
|
||||||
|
IntVal::I32(val) => format!("{}", val),
|
||||||
|
IntVal::I16(val) => format!("{}", val),
|
||||||
|
IntVal::I8(val) => format!("{}", val),
|
||||||
|
IntVal::U64(val) => format!("{}", val),
|
||||||
|
IntVal::U32(val ) => format!("{}", val),
|
||||||
|
IntVal::U16(val) => format!("{}", val),
|
||||||
|
IntVal::U8(val) => format!("{}", val),
|
||||||
|
};
|
||||||
|
|
||||||
let code_text = Text {
|
let code_text = Text {
|
||||||
position,
|
position,
|
||||||
area_bounds,
|
area_bounds,
|
||||||
color: CODE_COLOR.into(),
|
color: CODE_COLOR.into(),
|
||||||
text: format!("{:?}", number),
|
text,
|
||||||
size: CODE_FONT_SIZE,
|
size: CODE_FONT_SIZE,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
queue_code_text_draw(&code_text, glyph_brush);
|
queue_code_text_draw(&code_text, glyph_brush);
|
||||||
}
|
}
|
||||||
Float {
|
Expr2::Float {
|
||||||
number,
|
number,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
|
let text = match number {
|
||||||
|
FloatVal::F64(val) => format!("{}", val),
|
||||||
|
FloatVal::F32(val) => format!("{}", val),
|
||||||
|
};
|
||||||
|
|
||||||
let code_text = Text {
|
let code_text = Text {
|
||||||
position,
|
position,
|
||||||
area_bounds,
|
area_bounds,
|
||||||
color: CODE_COLOR.into(),
|
color: CODE_COLOR.into(),
|
||||||
text: format!("{:?}", number),
|
text,
|
||||||
size: CODE_FONT_SIZE,
|
size: CODE_FONT_SIZE,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
queue_code_text_draw(&code_text, glyph_brush);
|
queue_code_text_draw(&code_text, glyph_brush);
|
||||||
}
|
}
|
||||||
rest => panic!("implement {:?} render", rest)
|
rest => todo!("implement {:?} render", rest)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue