diff options
author | SimplyTheOther <simplytheother@gmail.com> | 2020-11-29 22:47:31 +0800 |
---|---|---|
committer | SimplyTheOther <simplytheother@gmail.com> | 2020-12-08 21:10:34 +0800 |
commit | db39766514144dbbad34d9db3977c3a72d1216c3 (patch) | |
tree | c7c470e4bf94ccb0105f8ad80ff85c7582ee9358 /gcc/rust/backend/rust-compile.cc | |
parent | 9b252167a77316750f34c455222e5f30724e51e4 (diff) | |
download | gcc-db39766514144dbbad34d9db3977c3a72d1216c3.zip gcc-db39766514144dbbad34d9db3977c3a72d1216c3.tar.gz gcc-db39766514144dbbad34d9db3977c3a72d1216c3.tar.bz2 |
Added new pattern stripping
Fixed get_locus_slow call in StructPatternField compile error
Added and improved cfg stripping
Fixed compilation errors
Diffstat (limited to 'gcc/rust/backend/rust-compile.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index eb01b12..d684c7d 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -100,11 +100,11 @@ Compilation::compileVarDecl (Bfunction *fndecl, AST::LetStmt *stmt, stmt->variables_pattern->accept_vis (*this); for (auto &pattern : patternBuffer) { - auto var = backend->local_variable (fndecl, pattern.variable_ident, + auto var = backend->local_variable (fndecl, pattern.get_ident (), translatedType, NULL /*decl_var*/, false /*address_taken*/, stmt->locus); vars.push_back (var); - scope.InsertVar (pattern.variable_ident, var); + scope.InsertVar (pattern.get_ident (), var); } patternBuffer.clear (); return true; @@ -219,7 +219,7 @@ Compilation::visit (AST::TypePathSegmentFunction &segment) void Compilation::visit (AST::TypePath &path) { - if (path.segments.size () > 1) + if (path.get_segments ().size () > 1) { rust_error_at (path.get_locus (), "unable to compile multi segment types yet"); return; @@ -953,7 +953,7 @@ Compilation::visit (AST::Function &function) { // translate the type translatedType = NULL; - param.type->accept_vis (*this); + param.get_type ()->accept_vis (*this); if (translatedType == NULL) { rust_error_at (param.get_locus (), "failed to generate type for parameter"); @@ -961,7 +961,7 @@ Compilation::visit (AST::Function &function) } auto before = patternBuffer.size (); - param.param_name->accept_vis (*this); + param.get_pattern ()->accept_vis (*this); if (patternBuffer.size () <= before) { rust_error_at (param.get_locus (), "failed to analyse parameter name"); @@ -974,13 +974,13 @@ Compilation::visit (AST::Function &function) auto paramName = patternBuffer.back (); patternBuffer.pop_back (); parameters.push_back ( - Backend::Btyped_identifier (paramName.variable_ident, + Backend::Btyped_identifier (paramName.get_ident (), translatedType, param.get_locus ())); } } Btype *returnType = NULL; - if (function.has_function_return_type ()) + if (function.has_return_type ()) { translatedType = NULL; function.get_return_type ()->accept_vis (*this); @@ -1051,7 +1051,7 @@ Compilation::visit (AST::Function &function) scope.PushBlock (code_block); Bvariable *retDecl = NULL; - if (function.has_function_return_type ()) + if (function.has_return_type ()) { bool address_is_taken = false; Bstatement *ret_var_stmt = NULL; @@ -1302,21 +1302,21 @@ Compilation::visit (AST::LetStmt &stmt) for (auto &pattern : patternBuffer) { Bvariable *var = NULL; - if (!scope.LookupVar (pattern.variable_ident, &var)) + if (!scope.LookupVar (pattern.get_ident (), &var)) { rust_error_at (stmt.get_locus (), "failed to find var decl for %s", - pattern.variable_ident.c_str ()); + pattern.get_ident ().c_str ()); return; } varBuffer.push_back (var); Bexpression *init = NULL; - VISIT_POP (stmt.init_expr->get_locus_slow (), stmt.init_expr, init, + VISIT_POP (stmt.get_init_expr ()->get_locus_slow (), stmt.get_init_expr (), init, exprs); if (init == NULL) { - rust_error_at (stmt.init_expr->get_locus_slow (), + rust_error_at (stmt.get_init_expr ()->get_locus_slow (), "failed to compile init statement"); return; } |