diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-17 16:38:25 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-17 16:38:25 -0700 |
commit | 10b90870a6190df847a7b08d4964793e6d81c23e (patch) | |
tree | 2686c1104bb93ce5230dff5d10f53428acbf4963 | |
parent | 6b001d8667dbfa7c19ba273451e97cfb9a425128 (diff) | |
parent | ba929a4ffac09becb3ae75facd74dc4f85c2725a (diff) | |
download | system_core-10b90870a6190df847a7b08d4964793e6d81c23e.tar.gz system_core-10b90870a6190df847a7b08d4964793e6d81c23e.tar.bz2 system_core-10b90870a6190df847a7b08d4964793e6d81c23e.zip |
Merge change 7790
* changes:
Track lvalues vs. rvalues.
-rw-r--r-- | libacc/acc.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/libacc/acc.cpp b/libacc/acc.cpp index 2a7d66ec5..250f4897a 100644 --- a/libacc/acc.cpp +++ b/libacc/acc.cpp @@ -144,6 +144,20 @@ class Compiler : public ErrorSink { Type* pTail; }; + enum ExpressionType { + ET_RVALUE, + ET_LVALUE + }; + + struct ExpressionValue { + ExpressionValue() { + et = ET_RVALUE; + pType = NULL; + } + ExpressionType et; + Type* pType; + }; + class CodeBuf { char* ind; // Output code pointer char* pProgramBase; @@ -468,7 +482,7 @@ class Compiler : public ErrorSink { virtual size_t stackSizeOf(Type* pType) = 0; virtual Type* getR0Type() { - return mExpressionStack.back(); + return mExpressionStack.back().pType; } protected: @@ -510,15 +524,20 @@ class Compiler : public ErrorSink { } void setR0Type(Type* pType) { - mExpressionStack.back() = pType; + mExpressionStack.back().pType = pType; } Type* getTOSType() { - return mExpressionStack[mExpressionStack.size()-2]; + return mExpressionStack[mExpressionStack.size()-2].pType; } void pushType() { - mExpressionStack.push_back(NULL); + if (mExpressionStack.size()) { + mExpressionStack.push_back(mExpressionStack.back()); + } else { + mExpressionStack.push_back(ExpressionValue()); + } + } void popType() { @@ -551,7 +570,7 @@ class Compiler : public ErrorSink { Type* mkpInt; private: - Vector<Type*> mExpressionStack; + Vector<ExpressionValue> mExpressionStack; CodeBuf* pCodeBuf; ErrorSink* mErrorSink; }; |