From 8ff6c69157b2109e7b7568f48aa61f8561432696 Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Tue, 19 May 2009 17:24:35 +0100 Subject: [PATCH] [ozulis] using auto --- src/ozulis/visitors/llvm-asm-generator.cc | 77 +++++++++++++++---------------- src/ozulis/visitors/simplify.cc | 47 +++++++++---------- src/ozulis/visitors/type-checker.cc | 55 +++++++++++----------- 3 files changed, 87 insertions(+), 92 deletions(-) diff --git a/src/ozulis/visitors/llvm-asm-generator.cc b/src/ozulis/visitors/llvm-asm-generator.cc index 900daa8..bf7d306 100644 --- a/src/ozulis/visitors/llvm-asm-generator.cc +++ b/src/ozulis/visitors/llvm-asm-generator.cc @@ -30,7 +30,7 @@ namespace ozulis static void visitFile(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::File & node = reinterpret_cast (node_); + const auto & node = reinterpret_cast (node_); BOOST_FOREACH(ast::VarDecl * var, *node.varDecls) { @@ -70,15 +70,14 @@ namespace ozulis static void visitFunctionDecl(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::FunctionDecl & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "declare "; ctx.writeFunctionHeader(node); } static void visitFunction(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::Function & node = - reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "define "; ctx.writeFunctionHeader(node); ctx.out << "{" << std::endl; @@ -95,7 +94,7 @@ namespace ozulis static void visitAlloca(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::Alloca & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << " "; LLVMAsmGenerator::visit(*node.symbol->address, ctx); @@ -106,7 +105,7 @@ namespace ozulis static void visitLoadVar(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::LoadVar & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); assert(node.from->type); ctx.out << " " << node.to << " = load "; @@ -118,7 +117,7 @@ namespace ozulis static void visitStoreVar(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::StoreVar & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); assert(node.value); assert(node.value->type); @@ -132,7 +131,7 @@ namespace ozulis static void visitAssignExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::AssignExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << " "; LLVMAsmGenerator::visit(*node.dest, ctx); ctx.out << " = "; @@ -146,7 +145,7 @@ namespace ozulis static void visitPointerArithExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::PointerArithExp & node = + auto & node = reinterpret_cast (node_); ctx.out << "getelementptr "; @@ -160,7 +159,7 @@ namespace ozulis #define GEN_BINARY_EXP_EXT(Name, Type, Instr) \ static void Name(const ast::Node & node_, LLVMAsmGenerator & ctx) \ { \ - const ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ ctx.out << Instr" "; \ LLVMAsmGenerator::visit(*unreferencedType(node.type), ctx); \ LLVMAsmGenerator::visit(*node.left, ctx); \ @@ -233,7 +232,7 @@ namespace ozulis #define GEN_BINARY_BOOL_EXP(Type, Op) \ static void visit##Type(const ast::Node & node_, LLVMAsmGenerator & ctx) \ { \ - const ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ ctx.out << Op " i1 "; \ LLVMAsmGenerator::visit(*node.left, ctx); \ ctx.out << ", "; \ @@ -269,7 +268,7 @@ namespace ozulis static void visitNegExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::NegExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "sub "; LLVMAsmGenerator::visit(*node.type, ctx); if (AST_IS_FLOATING_POINT_TYPE(node.type)) @@ -281,14 +280,14 @@ namespace ozulis static void visitBangExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::BangExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "xor i1 1, "; LLVMAsmGenerator::visit(*node.exp, ctx); } static void visitNotExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::NotExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "xor "; LLVMAsmGenerator::visit(*node.type, ctx); ctx.out << " -1, "; @@ -306,14 +305,14 @@ namespace ozulis static void visitSymbolExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::SymbolExp & node = + auto & node = reinterpret_cast (node_); LLVMAsmGenerator::visit(*node.symbol->address, ctx); } static void visitMemoryAddress(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::MemoryAddress & node = + auto & node = reinterpret_cast (node_); assert_msg(!node.address.empty(), _("address should never be empty")); ctx.out << node.address; @@ -321,7 +320,7 @@ namespace ozulis static void visitRegisterAddress(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::RegisterAddress & node = + auto & node = reinterpret_cast (node_); assert_msg(!node.address.empty(), _("address should never be empty")); ctx.out << node.address; @@ -329,13 +328,13 @@ namespace ozulis static void visitAtExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::AtExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); LLVMAsmGenerator::visit(*node.exp, ctx); } static void visitCallExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::CallExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << " call "; LLVMAsmGenerator::visit(*node.type, ctx); LLVMAsmGenerator::visit(*node.function, ctx); @@ -357,7 +356,7 @@ namespace ozulis static void visitNumberExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::NumberExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); if (node.type->nodeType == ast::FloatType::nodeTypeId()) /// @todo find the right way to print floating point numbers ctx.out << std::setprecision(1000) << (float)node.number; @@ -367,26 +366,26 @@ namespace ozulis static void visitStringExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::StringExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "c\"" << node.string << "\\00\""; } static void visitLabel(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::Label & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << " br label %" << node.name << " ; dummy branch to start a block" << std::endl << node.name << ":" << std::endl; } static void visitGoto(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::Goto & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << " br label %" << node.label << std::endl; } static void visitReturn(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::Return & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); assert(node.exp); ctx.out << " ret "; @@ -397,7 +396,7 @@ namespace ozulis static void visitConditionalBranch(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::ConditionalBranch & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << " br i1 "; LLVMAsmGenerator::visit(*node.cond, ctx); ctx.out << ", label %" << node.trueLabel->name << ", label %" @@ -416,44 +415,44 @@ namespace ozulis static void visitBoolType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::BoolType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "i1 "; } static void visitVoidType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::VoidType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "void "; } static void visitIntegerType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::IntegerType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "i" << node.size << " "; } static void visitFloatType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::FloatType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "float "; } static void visitDoubleType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::DoubleType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "double "; } static void visitPointerType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::PointerType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); LLVMAsmGenerator::visit(*node.type, ctx); ctx.out << "*"; } static void visitArrayType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::ArrayType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << " [" << node.size << " x "; LLVMAsmGenerator::visit(*node.type, ctx); ctx.out << "] "; @@ -461,7 +460,7 @@ namespace ozulis static void visitReferenceType(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::ReferenceType & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); LLVMAsmGenerator::visit(*node.type, ctx); ctx.out << "*"; } @@ -499,7 +498,7 @@ namespace ozulis static void visitCastArrayToPointerExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::CastExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "getelementptr "; LLVMAsmGenerator::visit(*node.exp->type, ctx); ctx.out << "*"; @@ -514,7 +513,7 @@ namespace ozulis static void visitCastBoolToIntegerExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::CastExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); const ast::IntegerType * to = reinterpret_cast(node.type.ptr()); @@ -535,7 +534,7 @@ namespace ozulis static void visitCastIntegerToIntegerExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::CastExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); const ast::IntegerType * from = ast::ast_cast(node.exp->type); const ast::IntegerType * to = ast::ast_cast(node.type); @@ -562,7 +561,7 @@ namespace ozulis visitCastIntegerTo##Float##Exp(const ast::Node & node_, \ LLVMAsmGenerator & ctx) \ { \ - const ast::CastExp & node = \ + auto & node = \ reinterpret_cast (node_); \ const ast::IntegerType * from = \ ast::ast_cast(node.exp->type); \ @@ -581,7 +580,7 @@ namespace ozulis visitCast##Float##ToIntegerExp(const ast::Node & node_, \ LLVMAsmGenerator & ctx) \ { \ - const ast::CastExp & node = \ + auto & node = \ reinterpret_cast (node_); \ const ast::IntegerType * to = \ ast::ast_cast(node.type); \ @@ -598,7 +597,7 @@ namespace ozulis static void visitCastIntegerToBoolExp(const ast::Node & node_, LLVMAsmGenerator & ctx) { - const ast::CastExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.out << "icmp ne "; LLVMAsmGenerator::visit(*node.exp->type, ctx); ctx.out << "0, "; diff --git a/src/ozulis/visitors/simplify.cc b/src/ozulis/visitors/simplify.cc index 20a5b65..a95e592 100644 --- a/src/ozulis/visitors/simplify.cc +++ b/src/ozulis/visitors/simplify.cc @@ -90,7 +90,7 @@ namespace ozulis if (node.nodeType == ast::SymbolExp::nodeTypeId()) { - ast::SymbolExp & se = reinterpret_cast (node); + auto & se = reinterpret_cast (node); if (se.symbol->address->nodeType == ast::RegisterAddress::nodeTypeId()) { replacement = &node; @@ -118,7 +118,7 @@ namespace ozulis static void visitBlock(ast::Node & node_, Simplify & ctx) { - ast::Block & block = reinterpret_cast (node_); + auto & block = reinterpret_cast (node_); ctx.scope = block.scope; std::vector backup = ctx.simplifications; @@ -141,7 +141,7 @@ namespace ozulis static void visitVoidExp(ast::Node & node_, Simplify & ctx) { - ast::VoidExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.replacement = &node; } @@ -155,7 +155,7 @@ namespace ozulis */ \ static void visit##Type(ast::Node & node_, Simplify & ctx) \ { \ - ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ assert(node.exp); \ SIMPLIFY(node.exp); \ \ @@ -176,7 +176,7 @@ namespace ozulis */ \ static void visit##Type(ast::Node & node_, Simplify & ctx) \ { \ - ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ SIMPLIFY(node.left); \ SIMPLIFY(node.right); \ \ @@ -210,7 +210,7 @@ namespace ozulis /// @todo redo it :) static void visitAssignExp(ast::Node & node_, Simplify & ctx) { - ast::AssignExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); assert(node.value); assert(node.type); assert(node.dest); @@ -228,7 +228,7 @@ namespace ozulis static void visitNumberExp(ast::Node & node_, Simplify & ctx) { - ast::NumberExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.replacement = &node; } @@ -246,7 +246,7 @@ namespace ozulis /** @internal load a symbol if it's in memory */ static void visitSymbolExp(ast::Node & node_, Simplify & ctx) { - ast::SymbolExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); if (node.symbol->address->nodeType == ast::MemoryAddress::nodeTypeId()) { ast::SymbolExpPtr sexp = new ast::SymbolExp; @@ -270,7 +270,7 @@ namespace ozulis static void visitVarDecl(ast::Node & node_, Simplify & ctx) { - ast::VarDecl & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ast::SymbolPtr symbol = ctx.scope->findSymbol(node.name); ast::AllocaPtr alloc = new ast::Alloca; alloc->symbol = symbol; @@ -279,8 +279,7 @@ namespace ozulis static void visitValuedVarDecl(ast::Node & node_, Simplify & ctx) { - ast::ValuedVarDecl & node = - reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); visitVarDecl(node, ctx); SIMPLIFY(node.value); ast::StoreVarPtr sv = new ast::StoreVar; @@ -294,7 +293,7 @@ namespace ozulis * of a reference. So in fact there is nothing to do ;-) */ static void visitAtExp(ast::Node & node_, Simplify & ctx) { - ast::AtExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); assert(node.exp->type->nodeType == ast::ReferenceType::nodeTypeId()); ctx.replacement = node.exp; ctx.simplifyLValue(ctx.replacement); @@ -302,7 +301,7 @@ namespace ozulis static void visitDereferenceExp(ast::Node & node_, Simplify & ctx) { - ast::DereferenceExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); SIMPLIFY(node.exp); ast::LoadVarPtr lv = new ast::LoadVar; @@ -324,8 +323,7 @@ namespace ozulis /** @internal just do (node.exp + node.index)* */ static void visitDereferenceByIndexExp(ast::Node & node_, Simplify & ctx) { - ast::DereferenceByIndexExp & node = - reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ast::PointerArithExpPtr add = new ast::PointerArithExp; add->pointer = node.exp; add->offset = node.index; @@ -343,8 +341,7 @@ namespace ozulis static void visitPointerArithExp(ast::Node & node_, Simplify & ctx) { - ast::PointerArithExp & node = - reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); SIMPLIFY(node.pointer); SIMPLIFY(node.offset); @@ -353,7 +350,7 @@ namespace ozulis static void visitCallExp(ast::Node & node_, Simplify & ctx) { - ast::CallExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); BOOST_FOREACH (ast::ExpPtr & exp, (*node.args)) SIMPLIFY(exp); @@ -363,7 +360,7 @@ namespace ozulis /** @internal develop the cast, and simplify it */ static void visitCastExp(ast::Node & node_, Simplify & ctx) { - ast::CastExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); SIMPLIFY(node.exp); ast::ExpPtr exp = CastSimplifier::simplify(node); if (exp->nodeType == ast::NumberExp::nodeTypeId()) @@ -374,19 +371,19 @@ namespace ozulis static void visitLabel(ast::Node & node_, Simplify & ctx) { - ast::Label & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.simplifications.push_back(&node); } static void visitGoto(ast::Node & node_, Simplify & ctx) { - ast::Goto & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); ctx.simplifications.push_back(&node); } static void visitReturn(ast::Node & node_, Simplify & ctx) { - ast::Return & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); SIMPLIFY(node.exp); ctx.simplifications.push_back(&node); } @@ -404,7 +401,7 @@ namespace ozulis */ static void visitIf(ast::Node & node_, Simplify & ctx) { - ast::If & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); SIMPLIFY(node.branch->cond); ctx.simplifications.push_back(node.branch); @@ -437,7 +434,7 @@ namespace ozulis */ static void visitWhile(ast::Node & node_, Simplify & ctx) { - ast::While & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); assert(node.block); assert(node.branch->cond); @@ -471,7 +468,7 @@ namespace ozulis */ static void visitDoWhile(ast::Node & node_, Simplify & ctx) { - ast::DoWhile & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); assert(node.block); assert(node.branch->cond); diff --git a/src/ozulis/visitors/type-checker.cc b/src/ozulis/visitors/type-checker.cc index c917e89..2254f26 100644 --- a/src/ozulis/visitors/type-checker.cc +++ b/src/ozulis/visitors/type-checker.cc @@ -49,14 +49,14 @@ namespace ozulis /** @internal keep the file's scope and visit the file */ static void visitFile(ast::Node & node_, TypeChecker & ctx) { - ast::File & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); ctx.scope = node.scope; Browser::visit(node, ctx); } static void visitFunction(ast::Node & node_, TypeChecker & ctx) { - ast::Function & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); ctx.scope = node.scope; ctx.currentFunction = &node; Browser::visit(node, ctx); @@ -67,7 +67,7 @@ namespace ozulis /** @internal get the scope, visit declarations, visit statements */ static void visitBlock(ast::Node & node_, TypeChecker & ctx) { - ast::Block & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); ctx.scope = node.scope; // We must respect this order BOOST_FOREACH (ast::VarDeclPtr & varDecl, (*node.varDecls)) @@ -80,7 +80,7 @@ namespace ozulis * is not possible */ static void visitReturn(ast::Node & node_, TypeChecker & ctx) { - ast::Return & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.exp); node.exp = castToType(ctx.currentFunction->returnType, node.exp); } @@ -89,11 +89,11 @@ namespace ozulis * the type of the destination. If not put a cast. */ static void visitAssignExp(ast::Node & node_, TypeChecker & ctx) { - ast::AssignExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.dest); CHECK(node.value); - ast::CastExp * castExp = new ast::CastExp(); + auto castExp = new ast::CastExp(); castExp->type = unreferencedType(node.dest->type); castExp->exp = node.value; node.value = castExp; @@ -104,7 +104,7 @@ namespace ozulis * type of the symbol to the node. */ static void visitSymbolExp(ast::Node & node_, TypeChecker & ctx) { - ast::SymbolExp & node = reinterpret_cast (node_); + auto & node = reinterpret_cast (node_); if (!node.type) { TypeChecker::visit(*node.symbol, ctx); @@ -116,13 +116,13 @@ namespace ozulis * create a SymbolExp, and replace IdExp by the SymbolExp */ static void visitIdExp(ast::Node & node_, TypeChecker & ctx) { - ast::IdExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); assert(ctx.scope); ast::Symbol * s = ctx.scope->findSymbol(node.id); assert(s); assert(s->type); assert(s->address); - ast::SymbolExp * exp = new ast::SymbolExp; + auto exp = new ast::SymbolExp; exp->symbol = s; exp->type = s->type; ctx.replacement = exp; @@ -142,9 +142,9 @@ namespace ozulis * address of the child exp. The simplifier will do this job. */ static void visitAtExp(ast::Node & node_, TypeChecker & ctx) { - ast::AtExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.exp); - ast::PointerType * type = new ast::PointerType; + auto type = new ast::PointerType; type->type = unreferencedType(node.exp->type); node.type = type; } @@ -152,20 +152,19 @@ namespace ozulis /** @internal obvious, will comment it later */ static void visitDereferenceExp(ast::Node & node_, TypeChecker & ctx) { - ast::DereferenceExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.exp); ast::Type * unrefType = unreferencedType(node.exp->type); if (unrefType->nodeType != ast::PointerType::nodeTypeId()) Compiler::instance().error(_("you can't dereference a non pointer type")); - ast::PointerType * type = ast::ast_cast (unrefType); + auto type = ast::ast_cast (unrefType); node.type = type->type; } /** @internal obvious, will comment it later */ static void visitDereferenceByIndexExp(ast::Node & node_, TypeChecker & ctx) { - ast::DereferenceByIndexExp & node = - reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.exp); CHECK(node.index); ast::Type * unrefType = unreferencedType(node.exp->type); @@ -173,7 +172,7 @@ namespace ozulis unrefType->nodeType != ast::ArrayType::nodeTypeId()) Compiler::instance().error(_("Error: you can't dereference a non " "pointer or array type")); - ast::UnaryType * type = reinterpret_cast (unrefType); + auto type = reinterpret_cast (unrefType); node.type = type->type; ast::IntegerType * itype = ast::NodeFactory::createUIntForPtr(); @@ -182,7 +181,7 @@ namespace ozulis static void visitPointerArithExp(ast::Node & node_, TypeChecker & ctx) { - ast::PointerArithExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.pointer); CHECK(node.offset); node.type = unreferencedType(node.pointer->type); @@ -200,7 +199,7 @@ namespace ozulis /** @internal just check the child exp */ static void visitCastExp(ast::Node & node_, TypeChecker & ctx) { - ast::CastExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); assert(node.exp); CHECK(node.exp); } @@ -209,7 +208,7 @@ namespace ozulis * to resolve the symbol. Then put casts force the right type. */ static void visitCallExp(ast::Node & node_, TypeChecker & ctx) { - ast::CallExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.function); ast::SymbolExp * sexp = ast::ast_cast(node.function); @@ -298,7 +297,7 @@ namespace ozulis #define VISIT_ADD_EXP(Type) \ static void visit##Type(ast::Node & node_, TypeChecker & ctx) \ { \ - ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ CHECK(node.left); \ CHECK(node.right); \ if (unreferencedType(node.left->type)->nodeType == \ @@ -314,7 +313,7 @@ namespace ozulis #define VISIT_BINARY_ARITH(Type) \ static void visit##Type(ast::Node & node_, TypeChecker & ctx) \ { \ - ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ CHECK(node.left); \ CHECK(node.right); \ TypeChecker::homogenizeTypes(node); \ @@ -329,7 +328,7 @@ namespace ozulis #define VISIT_BITWISE_EXP(Type) \ static void visit##Type(ast::Node & node_, TypeChecker & ctx) \ { \ - ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ CHECK(node.left); \ CHECK(node.right); \ \ @@ -353,7 +352,7 @@ namespace ozulis #define VISIT_BINARY_CMP_EXP(Type) \ static void visit##Type(ast::Node & node_, TypeChecker & ctx) \ { \ - ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ CHECK(node.left); \ CHECK(node.right); \ /** \ @@ -375,7 +374,7 @@ namespace ozulis #define VISIT_BINARY_BOOL_EXP(Type) \ static void visit##Type(ast::Node & node_, TypeChecker & ctx) \ { \ - ast::Type & node = reinterpret_cast (node_); \ + auto & node = reinterpret_cast (node_); \ node.type = ast::NodeFactory::createBoolType(); \ \ CHECK(node.left); \ @@ -396,14 +395,14 @@ namespace ozulis static void visitNegExp(ast::Node & node_, TypeChecker & ctx) { - ast::NegExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.exp); node.type = node.exp->type; } static void visitNotExp(ast::Node & node_, TypeChecker & ctx) { - ast::NotExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.exp); if (AST_IS_FLOATING_POINT_TYPE(node.exp->type)) Compiler::instance().error(_("you can't do bitwise operation with " @@ -413,7 +412,7 @@ namespace ozulis static void visitBangExp(ast::Node & node_, TypeChecker & ctx) { - ast::BangExp & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.exp); if (AST_IS_FLOATING_POINT_TYPE(node.exp->type)) Compiler::instance().error(_("you can't do bitwise operation with " @@ -424,7 +423,7 @@ namespace ozulis static void visitConditionalBranch(ast::Node & node_, TypeChecker & ctx) { - ast::ConditionalBranch & node = reinterpret_cast(node_); + auto & node = reinterpret_cast(node_); CHECK(node.cond); node.cond = castToType(ast::NodeFactory::createBoolType(), node.cond); } -- 2.11.4.GIT