adding comments
This commit is contained in:
parent
876690319f
commit
93deeee6b9
|
@ -1964,6 +1964,7 @@ impl Codegen {
|
||||||
|
|
||||||
unimplemented!("{:#?}", op)
|
unimplemented!("{:#?}", op)
|
||||||
}
|
}
|
||||||
|
E::Comment { .. } => Some(Value::void()),
|
||||||
ast => unimplemented!("{:#?}", ast),
|
ast => unimplemented!("{:#?}", ast),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
|
@ -2253,6 +2254,9 @@ impl Codegen {
|
||||||
|
|
||||||
fn load_arg(&mut self, flags: parser::IdentFlags, ty: ty::Id, parama: &mut ParamAlloc) -> Loc {
|
fn load_arg(&mut self, flags: parser::IdentFlags, ty: ty::Id, parama: &mut ParamAlloc) -> Loc {
|
||||||
let size = self.tys.size_of(ty) as Size;
|
let size = self.tys.size_of(ty) as Size;
|
||||||
|
if size == 0 {
|
||||||
|
return Loc::default();
|
||||||
|
}
|
||||||
let (src, dst) = match size {
|
let (src, dst) = match size {
|
||||||
0 => (Loc::default(), Loc::default()),
|
0 => (Loc::default(), Loc::default()),
|
||||||
..=8 if flags & idfl::REFERENCED == 0 => {
|
..=8 if flags & idfl::REFERENCED == 0 => {
|
||||||
|
@ -2395,6 +2399,10 @@ impl Codegen {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if size == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
src.as_ref().assert_valid();
|
src.as_ref().assert_valid();
|
||||||
dst.as_ref().assert_valid();
|
dst.as_ref().assert_valid();
|
||||||
|
|
||||||
|
@ -2884,6 +2892,7 @@ mod tests {
|
||||||
arithmetic => README;
|
arithmetic => README;
|
||||||
variables => README;
|
variables => README;
|
||||||
functions => README;
|
functions => README;
|
||||||
|
comments => README;
|
||||||
if_statements => README;
|
if_statements => README;
|
||||||
loops => README;
|
loops => README;
|
||||||
fb_driver => README;
|
fb_driver => README;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{convert::identity, simd::cmp::SimdPartialEq};
|
use std::simd::cmp::SimdPartialEq;
|
||||||
|
|
||||||
const fn ascii_mask(chars: &[u8]) -> u128 {
|
const fn ascii_mask(chars: &[u8]) -> u128 {
|
||||||
let mut eq = 0;
|
let mut eq = 0;
|
||||||
|
|
|
@ -367,6 +367,10 @@ impl<'a, 'b> Parser<'a, 'b> {
|
||||||
self.expect_advance(T::RParen);
|
self.expect_advance(T::RParen);
|
||||||
expr
|
expr
|
||||||
}
|
}
|
||||||
|
T::Comment => Expr::Comment {
|
||||||
|
pos: token.start,
|
||||||
|
literal: self.move_str(token),
|
||||||
|
},
|
||||||
tok => self.report(format_args!("unexpected token: {tok:?}")),
|
tok => self.report(format_args!("unexpected token: {tok:?}")),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -577,6 +581,10 @@ macro_rules! generate_expr {
|
||||||
generate_expr! {
|
generate_expr! {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Expr<'a> {
|
pub enum Expr<'a> {
|
||||||
|
Comment {
|
||||||
|
pos: Pos,
|
||||||
|
literal: &'a str,
|
||||||
|
},
|
||||||
Break {
|
Break {
|
||||||
pos: Pos,
|
pos: Pos,
|
||||||
},
|
},
|
||||||
|
@ -725,6 +733,7 @@ impl<'a> std::fmt::Display for Expr<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
|
Self::Comment { literal, .. } => write!(f, "{literal}"),
|
||||||
Self::Mod { path, .. } => write!(f, "@mod(\"{path}\")"),
|
Self::Mod { path, .. } => write!(f, "@mod(\"{path}\")"),
|
||||||
Self::Field { target, field } => write!(f, "{}.{field}", Postfix(target)),
|
Self::Field { target, field } => write!(f, "{}.{field}", Postfix(target)),
|
||||||
Self::Directive { name, args, .. } => {
|
Self::Directive { name, args, .. } => {
|
||||||
|
|
3
hblang/tests/codegen_tests_comments.txt
Normal file
3
hblang/tests/codegen_tests_comments.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
code size: 153
|
||||||
|
ret: 0
|
||||||
|
status: Ok(())
|
Loading…
Reference in a new issue