Static path codegen
This commit is contained in:
+9
-10
@@ -1,6 +1,6 @@
|
|||||||
use parser::ast::{
|
use parser::ast::{
|
||||||
BinaryOp, Block, Expression, IfStmt, Postfix, Statement, TopLevel, TypeExpr, VarAssignStmt,
|
BinaryOp, Block, Expression, IfStmt, Postfix, Statement, StaticPath, TopLevel, TypeExpr,
|
||||||
VarDecl, VarDeclStmt, WhileStmt,
|
VarAssignStmt, VarDecl, VarDeclStmt, WhileStmt,
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -75,14 +75,7 @@ impl Default for RustCodegen {
|
|||||||
impl GetRust for TypeExpr {
|
impl GetRust for TypeExpr {
|
||||||
fn get_rust(&self) -> String {
|
fn get_rust(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
TypeExpr::Identifier(name) => match name.as_str() {
|
TypeExpr::Path(path) => path.get_rust(),
|
||||||
"int" => "i32".into(),
|
|
||||||
"float" | "float64" => "f64".into(),
|
|
||||||
"float32" => "f32".into(),
|
|
||||||
"bool" => "bool".into(),
|
|
||||||
"string" => "String".into(),
|
|
||||||
_ => name.clone(),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,3 +308,9 @@ impl GetRust for VarDecl {
|
|||||||
format!("{}{}{}", mutability, self.name, ty)
|
format!("{}{}{}", mutability, self.name, ty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetRust for StaticPath {
|
||||||
|
fn get_rust(&self) -> String {
|
||||||
|
self.0.join("::")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+3
-1
@@ -1 +1,3 @@
|
|||||||
int test() {}
|
i32 test() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user