Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b533bea authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 3499

* changes:
  Make a host version of acc for testing.
parents 268eec1e 36d9414f
Loading
Loading
Loading
Loading
+22 −4
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

#
# Shared library
#
# Shared library for target
# ========================================================

LOCAL_MODULE:= libacc
LOCAL_SRC_FILES := acc.cpp
@@ -16,4 +15,23 @@ LOCAL_SHARED_LIBRARIES := libdl libcutils

include $(BUILD_SHARED_LIBRARY)

# Shared library for host
# ========================================================

include $(CLEAR_VARS)
LOCAL_MODULE:= libacc
LOCAL_SRC_FILES := acc.cpp

ifeq ($(TARGET_ARCH),arm)
LOCAL_SRC_FILES += disassem.cpp
endif

LOCAL_STATIC_LIBRARIES := libcutils
LOCAL_LDLIBS := -ldl

include $(BUILD_HOST_SHARED_LIBRARY)

# Build children
# ========================================================

include $(call all-makefiles-under,$(LOCAL_PATH))
+29 −20
Original line number Diff line number Diff line
@@ -1087,26 +1087,6 @@ class Compiler : public ErrorSink {
        size_t mPosition;
    };

    int ch; // Current input character, or EOF
    intptr_t tok;     // token
    intptr_t tokc;    // token extra info
    int tokl;         // token operator level
    intptr_t rsym; // return symbol
    intptr_t loc; // local variable index
    char* glo;  // global variable index
    char* sym_stk;
    char* dstk; // Define stack
    char* dptr; // Macro state: Points to macro text during macro playback.
    int dch;    // Macro state: Saves old value of ch during a macro playback.
    char* last_id;
    char* pGlobalBase;
    char* pVarsBase; // Value of variables

    InputStream* file;

    CodeBuf codeBuf;
    CodeGenerator* pGen;

    class String {
    public:
        String() {
@@ -1306,6 +1286,8 @@ class Compiler : public ErrorSink {
        void pop() {
            if (mUsed > 0) {
                mUsed -= 1;
            } else {
                error("internal error: Popped empty stack.");
            }
        }

@@ -1338,7 +1320,34 @@ class Compiler : public ErrorSink {
        size_t mSize;
    };

    struct InputState {
        InputStream* pStream;
        int oldCh;
    };


    int ch; // Current input character, or EOF
    intptr_t tok;     // token
    intptr_t tokc;    // token extra info
    int tokl;         // token operator level
    intptr_t rsym; // return symbol
    intptr_t loc; // local variable index
    char* glo;  // global variable index
    char* sym_stk;
    char* dstk; // Define stack
    char* dptr; // Macro state: Points to macro text during macro playback.
    int dch;    // Macro state: Saves old value of ch during a macro playback.
    char* last_id;
    char* pGlobalBase;
    char* pVarsBase; // Value of variables

    InputStream* file;

    CodeBuf codeBuf;
    CodeGenerator* pGen;

    MacroTable mMacros;
    Array<InputState> mInputStateStack;

    String mErrorBuf;

+19 −2
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)

# Executable for host
# ========================================================
include $(CLEAR_VARS)
LOCAL_MODULE:= acc

LOCAL_SRC_FILES:= \
	main.cpp
@@ -7,9 +11,22 @@ LOCAL_SRC_FILES:= \
LOCAL_SHARED_LIBRARIES := \
    libacc

LOCAL_MODULE_TAGS := tests

include $(BUILD_HOST_EXECUTABLE)

# Executable for target
# ========================================================
include $(CLEAR_VARS)
LOCAL_MODULE:= acc

LOCAL_SRC_FILES:= \
	main.cpp

LOCAL_SHARED_LIBRARIES := \
    libacc


LOCAL_MODULE_TAGS := tests

include $(BUILD_EXECUTABLE)
 No newline at end of file
+4 −1
Original line number Diff line number Diff line
#define VALUE (2*FOO)
#define FOO 12

int main(int argc, char** argv) {
  return f();
}

int f() {
    return 10;
    return VALUE;
}
+5 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ int run(MainPtr mainFunc, int argc, char** argv) {
int main(int argc, char** argv) {
    const char* inFile = NULL;
    bool printListing;
    bool runResults = false;
    FILE* in = stdin;
    int i;
    for (i = 1; i < argc; i++) {
@@ -41,6 +42,9 @@ int main(int argc, char** argv) {
                case 'S':
                    printListing = true;
                    break;
                case 'R':
                    runResults = true;
                    break;
            default:
                fprintf(stderr, "Unrecognized flag %s\n", arg);
                return 3;
@@ -108,7 +112,7 @@ int main(int argc, char** argv) {
    accGetScriptLabel(script, "main", (ACCvoid**) & mainPointer);

    result = accGetError(script);
    if (result == ACC_NO_ERROR) {
    if (result == ACC_NO_ERROR && runResults) {
        fprintf(stderr, "Executing compiled code:\n");
        int codeArgc = argc - i + 1;
        char** codeArgv = argv + i - 1;
Loading