Mercurial > hg > CbC > CbC_llvm
changeset 59:322ba4588e4f
remove assignment flags
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 02 Feb 2014 17:39:42 +0900 |
parents | 01c954c1b51b |
children | d4de94500cd9 |
files | tools/clang/include/clang/Parse/Parser.h tools/clang/lib/Parse/ParseCbC.cpp |
diffstat | 2 files changed, 18 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/clang/include/clang/Parse/Parser.h Sun Feb 02 17:07:04 2014 +0900 +++ b/tools/clang/include/clang/Parse/Parser.h Sun Feb 02 17:39:42 2014 +0900 @@ -1710,8 +1710,8 @@ ExprResult LookupAndDeclareName(IdentifierInfo *II = 0, bool IsAddressOfOperand = false); ExprResult LookupMemberAndBuildExpr(IdentifierInfo *II, Expr* Base, bool IsArrow); StmtResult CreateSjForContinuationWithEnv(); - StmtResult CreateAssignmentStmt(IdentifierInfo* LHSII = 0, IdentifierInfo* RHSII = 0, unsigned LHSFlags = 0, - unsigned RHSFlags = 0, IdentifierInfo* extraLHSII = 0, IdentifierInfo* extraRHSII = 0); + StmtResult CreateAssignmentStmt(IdentifierInfo* LHSII = 0, IdentifierInfo* RHSII = 0, bool LHSisMemberAccess = false, + bool RHShasAmp = false, IdentifierInfo* extraLHSII = 0, IdentifierInfo* extraRHSII = 0); void CreateArrayDecl(ParsingDeclarator &D, SourceLocation Loc, const char* size); StmtResult CreateDeclStmt(IdentifierInfo *II = 0, unsigned DeclFlags = 0, DeclSpec::TST valueType = DeclSpec::TST_int, IdentifierInfo* Name = 0, const char* size = 0); IdentifierInfo* CreateUniqueIdentifierInfo(const char* Name, SourceLocation Loc);
--- a/tools/clang/lib/Parse/ParseCbC.cpp Sun Feb 02 17:07:04 2014 +0900 +++ b/tools/clang/lib/Parse/ParseCbC.cpp Sun Feb 02 17:39:42 2014 +0900 @@ -73,27 +73,11 @@ } namespace CbCSpace{ - enum AssignmentFlags { - HasStar = 0x01, - HasAmp = 0x02, - HasPeriod = 0x04, - HasArrow = 0x08 - }; - - bool hasStar(unsigned F) { return F & HasStar; } - bool hasAmp(unsigned F) { return F & HasAmp; } - bool hasPeriod(unsigned F) { return F & HasPeriod; } - bool hasArrow(unsigned F) { return F & HasArrow; } - enum DeclarationFlags { - ArrayType = 0x01, - PointerType = 0x02, CbCReturnFunc = 0x04, CopyParentType = 0x08 }; - bool isArray(unsigned F) { return F & ArrayType; } - bool isPointer(unsigned F) { return F & PointerType; } bool isCbCRetFunc(unsigned F) { return F & CbCReturnFunc; } bool shouldCopyParentsType(unsigned F) { return F & CopyParentType; } } @@ -161,11 +145,11 @@ if (innerRes.isUsable()) CompoundStmts.push_back(innerRes.release()); - innerRes = CreateAssignmentStmt(__CbC_envII, retvalII, CbCSpace::HasPeriod, CbCSpace::HasAmp, ret_pII); + innerRes = CreateAssignmentStmt(__CbC_envII, retvalII, true, true, ret_pII); if (innerRes.isUsable()) CompoundStmts.push_back(innerRes.release()); - innerRes = CreateAssignmentStmt(__CbC_envII, bufII, CbCSpace::HasPeriod, 0, envII); + innerRes = CreateAssignmentStmt(__CbC_envII, bufII, true, false, envII); if (innerRes.isUsable()) CompoundStmts.push_back(innerRes.release()); @@ -182,8 +166,18 @@ return Actions.ActOnStmtExpr(Loc, CompoundStmtRes.take(), Loc); } -StmtResult Parser::CreateAssignmentStmt(IdentifierInfo* LHSII,IdentifierInfo* RHSII,unsigned LHSFlags,unsigned RHSFlags, - IdentifierInfo* extraLHSII,IdentifierInfo* extraRHSII){ +/// CreateAssignmentStmt - Create assignment statement such as "aaa = bbb;", "auaua = llll;", etc. +/// It can create kinds of statement. +/// 1. common assignment statement: +/// variable '=' variable ';' +/// 2. LHS variable is member of struct: +/// structVar '.' member '=' variable ';' +/// 3. RHS variable is address of operand: +/// variable '=' '&' variable ';' +/// 4. 2+3: +/// structVar '.' member '=' '&' variable ';' +StmtResult Parser::CreateAssignmentStmt(IdentifierInfo* LHSII, IdentifierInfo* RHSII, bool LHSisMemberAccess, bool RHShasAmp, + IdentifierInfo* extraLHSII, IdentifierInfo* extraRHSII){ ExprResult Expr,LHS,RHS; Token Next,LHSToken; @@ -203,18 +197,13 @@ LHS = getExprAnnotation(LHSToken); - if ( CbCSpace::hasPeriod(LHSFlags) ) + if (LHSisMemberAccess) LHS = LookupMemberAndBuildExpr(extraLHSII, LHS.take(), false); - else if ( CbCSpace::hasArrow(LHSFlags) ) - LHS = LookupMemberAndBuildExpr(extraLHSII, LHS.take(), true); // It is not sure. RHS = LookupAndDeclareName(RHSII); - if ( CbCSpace::hasAmp(RHSFlags) ) + if (RHShasAmp) RHS = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::amp, RHS.get()); - else if ( CbCSpace::hasStar(RHSFlags) ) - RHS = Actions.ActOnUnaryOp(getCurScope(), Loc, tok::star, RHS.get()); // It is not sure. - Expr = Actions.ActOnBinOp(getCurScope(), Loc,tok::equal,LHS.take(),RHS.take()); return Actions.ActOnExprStmt(Expr); @@ -283,8 +272,6 @@ PrototypeScope.Exit(); DSp = &FDS; } - if (CbCSpace::isArray(DeclFlags)) - CreateArrayDecl(D, Loc, size); SmallVector<Decl *, 8> DeclsInGroup; Decl *FirstDecl;