summaryrefslogtreecommitdiff
path: root/indra/lscript/lscript_compile
diff options
context:
space:
mode:
authorBryan O'Sullivan <bos@lindenlab.com>2008-06-02 21:14:31 +0000
committerBryan O'Sullivan <bos@lindenlab.com>2008-06-02 21:14:31 +0000
commit9db949eec327df4173fde3de934a87bedb0db13c (patch)
treeaeffa0f0e68b1d2ceb74d460cbbd22652c9cd159 /indra/lscript/lscript_compile
parent419e13d0acaabf5e1e02e9b64a07648bce822b2f (diff)
svn merge -r88066:88786 svn+ssh://svn.lindenlab.com/svn/linden/branches/cmake-9-merge
dataserver-is-deprecated for-fucks-sake-whats-with-these-commit-markers
Diffstat (limited to 'indra/lscript/lscript_compile')
-rw-r--r--indra/lscript/lscript_compile/CMakeLists.txt142
-rw-r--r--indra/lscript/lscript_compile/bison.bat11
-rw-r--r--indra/lscript/lscript_compile/indra.l6
-rw-r--r--indra/lscript/lscript_compile/lscript_bytecode.cpp4
-rw-r--r--indra/lscript/lscript_compile/lscript_bytecode.h4
-rw-r--r--indra/lscript/lscript_compile/lscript_error.cpp4
-rw-r--r--indra/lscript/lscript_compile/lscript_scope.h22
-rw-r--r--indra/lscript/lscript_compile/lscript_tree.cpp2
-rw-r--r--indra/lscript/lscript_compile/windows/unistd.h29
9 files changed, 201 insertions, 23 deletions
diff --git a/indra/lscript/lscript_compile/CMakeLists.txt b/indra/lscript/lscript_compile/CMakeLists.txt
new file mode 100644
index 0000000000..3b144c5338
--- /dev/null
+++ b/indra/lscript/lscript_compile/CMakeLists.txt
@@ -0,0 +1,142 @@
+# -*- cmake -*-
+
+include(00-Common)
+include(LLCommon)
+include(LLMath)
+include(LLMessage)
+include(LLInventory)
+include(LScript)
+
+include(FindCygwin)
+
+find_program(FLEX flex
+ "C:/Program Files/GnuWin32/bin"
+ ${CYGWIN_INSTALL_PATH}/bin
+ /bin
+ /usr/bin
+ /usr/local/bin
+ )
+mark_as_advanced(FLEX)
+
+find_program(BISON bison
+ "C:/Program Files/GnuWin32/bin"
+ ${CYGWIN_INSTALL_PATH}/bin
+ /bin
+ /usr/bin
+ /usr/local/bin
+ )
+mark_as_advanced(BISON)
+
+find_program(M4 m4
+ "C:/Program Files/GnuWin32/bin"
+ ${CYGWIN_INSTALL_PATH}/bin
+ /bin
+ /usr/bin
+ /usr/local/bin
+ )
+mark_as_advanced(M4)
+
+include_directories(
+ ${LLCOMMON_INCLUDE_DIRS}
+ ${LLMATH_INCLUDE_DIRS}
+ ${LLMESSAGE_INCLUDE_DIRS}
+ ${LLINVENTORY_INCLUDE_DIRS}
+ ${LSCRIPT_INCLUDE_DIRS}
+ )
+
+set(lscript_compile_SOURCE_FILES
+ indra.l.cpp
+ indra.y.cpp
+ lscript_alloc.cpp
+ lscript_bytecode.cpp
+ lscript_error.cpp
+ lscript_heap.cpp
+ lscript_resource.cpp
+ lscript_scope.cpp
+ lscript_tree.cpp
+ lscript_typecheck.cpp
+ )
+
+set(lscript_compile_HEADER_FILES
+ CMakeLists.txt
+
+ indra.l
+ indra.y
+
+ ../lscript_alloc.h
+ ../lscript_byteformat.h
+ ../lscript_byteconvert.h
+ ../lscript_http.h
+
+ lscript_error.h
+ lscript_bytecode.h
+ lscript_heap.h
+ lscript_resource.h
+ lscript_scope.h
+ lscript_tree.h
+ lscript_typecheck.h
+ )
+
+set_source_files_properties(${lscript_compile_HEADER_FILES}
+ PROPERTIES HEADER_FILE_ONLY TRUE)
+
+list(APPEND lscript_compile_SOURCE_FILES ${lscript_compile_HEADER_FILES})
+
+add_custom_command(
+ OUTPUT
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.l.cpp
+ COMMAND ${FLEX}
+ ARGS
+ -o${CMAKE_CURRENT_BINARY_DIR}/indra.l.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/indra.l
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/indra.l
+ )
+
+if (WINDOWS)
+ set_source_files_properties(indra.l.cpp
+ PROPERTIES COMPILE_FLAGS /DYY_NO_UNISTD_H)
+endif (WINDOWS)
+
+if (WINDOWS)
+ get_filename_component(M4_PATH ${M4} PATH)
+ add_custom_command(
+ OUTPUT
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bison.bat
+ ${BISON} ${M4_PATH}
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
+ DEPENDS
+ ${CMAKE_CURRENT_SOURCE_DIR}/bison.bat
+ ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
+ )
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/windows)
+else (WINDOWS)
+ add_custom_command(
+ OUTPUT
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
+ COMMAND
+ ${BISON}
+ ARGS
+ -d -o ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
+ DEPENDS
+ ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
+ )
+endif (WINDOWS)
+
+if (DARWIN)
+ # Mac OS X 10.4 compatibility
+ add_custom_command(
+ OUTPUT
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
+ COMMAND
+ mv
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp.h
+ ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
+ )
+endif (DARWIN)
+
+add_library (lscript_compile ${lscript_compile_SOURCE_FILES})
diff --git a/indra/lscript/lscript_compile/bison.bat b/indra/lscript/lscript_compile/bison.bat
new file mode 100644
index 0000000000..54cf0231d9
--- /dev/null
+++ b/indra/lscript/lscript_compile/bison.bat
@@ -0,0 +1,11 @@
+@REM Run bison under Windows. This script is needed so that bison can
+@REM find m4, even if neither program is present in PATH.
+
+@set bison=%1
+set M4PATH=%2
+set M4=
+@set output=%3
+@set input=%4
+
+set PATH=%M4PATH%;%PATH%
+%bison% -d -o %output% %input%
diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l
index ba10ef6fcc..eec3cb7bbf 100644
--- a/indra/lscript/lscript_compile/indra.l
+++ b/indra/lscript/lscript_compile/indra.l
@@ -19,11 +19,7 @@ FS (f|F)
#include "lscript_tree.h"
#include "lscript_typecheck.h"
#include "lscript_resource.h"
-#if LL_WINDOWS
-#include "ytab.h"
-#else
-#include "indra.y.h"
-#endif
+#include "indra.y.hpp"
#include "lltimer.h"
#include "indra_constants.h"
#include "llagentconstants.h"
diff --git a/indra/lscript/lscript_compile/lscript_bytecode.cpp b/indra/lscript/lscript_compile/lscript_bytecode.cpp
index 5fe42fd9a8..4ff9849193 100644
--- a/indra/lscript/lscript_compile/lscript_bytecode.cpp
+++ b/indra/lscript/lscript_compile/lscript_bytecode.cpp
@@ -101,7 +101,7 @@ void LLScriptByteCodeChunk::addU16(U16 data)
addBytes(temp, 2);
}
-void LLScriptByteCodeChunk::addBytes(U8 *bytes, S32 size)
+void LLScriptByteCodeChunk::addBytes(const U8 *bytes, S32 size)
{
if (mCodeChunk)
{
@@ -118,7 +118,7 @@ void LLScriptByteCodeChunk::addBytes(U8 *bytes, S32 size)
mCurrentOffset += size;
}
-void LLScriptByteCodeChunk::addBytes(char *bytes, S32 size)
+void LLScriptByteCodeChunk::addBytes(const char *bytes, S32 size)
{
if (mCodeChunk)
{
diff --git a/indra/lscript/lscript_compile/lscript_bytecode.h b/indra/lscript/lscript_compile/lscript_bytecode.h
index fcc5a23403..28505a12a9 100644
--- a/indra/lscript/lscript_compile/lscript_bytecode.h
+++ b/indra/lscript/lscript_compile/lscript_bytecode.h
@@ -56,8 +56,8 @@ public:
void addByte(U8 byte);
void addU16(U16 data);
- void addBytes(U8 *bytes, S32 size);
- void addBytes(char *bytes, S32 size);
+ void addBytes(const U8 *bytes, S32 size);
+ void addBytes(const char *bytes, S32 size);
void addBytes(S32 size);
void addBytesDontInc(S32 size);
void addInteger(S32 value);
diff --git a/indra/lscript/lscript_compile/lscript_error.cpp b/indra/lscript/lscript_compile/lscript_error.cpp
index 62d36f74d7..309eb07dc2 100644
--- a/indra/lscript/lscript_compile/lscript_error.cpp
+++ b/indra/lscript/lscript_compile/lscript_error.cpp
@@ -49,13 +49,13 @@ void LLScriptFilePosition::fdotabs(LLFILE *fp, S32 tabs, S32 tabsize)
}
}
-char* gWarningText[LSWARN_EOF] = /*Flawfinder: ignore*/
+const char* gWarningText[LSWARN_EOF] = /*Flawfinder: ignore*/
{
"INVALID",
"Dead code found beyond return statement"
};
-char* gErrorText[LSERROR_EOF] = /*Flawfinder: ignore*/
+const char* gErrorText[LSERROR_EOF] = /*Flawfinder: ignore*/
{
"INVALID",
"Syntax error",
diff --git a/indra/lscript/lscript_compile/lscript_scope.h b/indra/lscript/lscript_compile/lscript_scope.h
index c55d99577a..5a629df021 100644
--- a/indra/lscript/lscript_compile/lscript_scope.h
+++ b/indra/lscript/lscript_compile/lscript_scope.h
@@ -277,14 +277,14 @@ public:
class LLScriptScopeEntry
{
public:
- LLScriptScopeEntry(char *identifier, LSCRIPTIdentifierType idtype, LSCRIPTType type, S32 count = 0)
+ LLScriptScopeEntry(const char *identifier, LSCRIPTIdentifierType idtype, LSCRIPTType type, S32 count = 0)
: mIdentifier(identifier), mIDType(idtype), mType(type), mOffset(0), mSize(0), mAssignable(NULL), mCount(count), mLibraryNumber(0)
{
}
~LLScriptScopeEntry() {}
- char *mIdentifier;
+ const char *mIdentifier;
LSCRIPTIdentifierType mIDType;
LSCRIPTType mType;
S32 mOffset;
@@ -309,9 +309,9 @@ public:
mEntryMap.deleteAllData();
}
- LLScriptScopeEntry *addEntry(char *identifier, LSCRIPTIdentifierType idtype, LSCRIPTType type)
+ LLScriptScopeEntry *addEntry(const char *identifier, LSCRIPTIdentifierType idtype, LSCRIPTType type)
{
- char *name = mSTable->addString(identifier);
+ const char *name = mSTable->addString(identifier);
if (!mEntryMap.checkData(name))
{
if (idtype == LIT_FUNCTION)
@@ -329,9 +329,9 @@ public:
}
}
- BOOL checkEntry(char *identifier)
+ BOOL checkEntry(const char *identifier)
{
- char *name = mSTable->addString(identifier);
+ const char *name = mSTable->addString(identifier);
if (mEntryMap.checkData(name))
{
return TRUE;
@@ -343,9 +343,9 @@ public:
}
}
- LLScriptScopeEntry *findEntry(char *identifier)
+ LLScriptScopeEntry *findEntry(const char *identifier)
{
- char *name = mSTable->addString(identifier);
+ const char *name = mSTable->addString(identifier);
LLScriptScope *scope = this;
while (scope)
@@ -360,9 +360,9 @@ public:
return NULL;
}
- LLScriptScopeEntry *findEntryTyped(char *identifier, LSCRIPTIdentifierType idtype)
+ LLScriptScopeEntry *findEntryTyped(const char *identifier, LSCRIPTIdentifierType idtype)
{
- char *name = mSTable->addString(identifier);
+ const char *name = mSTable->addString(identifier);
LLScriptScope *scope = this;
while (scope)
@@ -397,7 +397,7 @@ public:
mParentScope = scope;
}
- LLMap<char *, LLScriptScopeEntry *> mEntryMap;
+ LLMap<const char *, LLScriptScopeEntry *> mEntryMap;
LLScriptScope *mParentScope;
LLStringTable *mSTable;
S32 mFunctionCount;
diff --git a/indra/lscript/lscript_compile/lscript_tree.cpp b/indra/lscript/lscript_compile/lscript_tree.cpp
index f00a2e51e7..efbbe374ed 100644
--- a/indra/lscript/lscript_compile/lscript_tree.cpp
+++ b/indra/lscript/lscript_compile/lscript_tree.cpp
@@ -9804,7 +9804,7 @@ void LLScriptScript::recurse(LLFILE *fp, S32 tabs, S32 tabsize, LSCRIPTCompilePa
mGlobalScope = new LLScriptScope(gScopeStringTable);
// zeroth, add library functions to global scope
S32 i;
- char *arg;
+ const char *arg;
LLScriptScopeEntry *sentry;
for (i = 0; i < gScriptLibrary.mNextNumber; i++)
{
diff --git a/indra/lscript/lscript_compile/windows/unistd.h b/indra/lscript/lscript_compile/windows/unistd.h
new file mode 100644
index 0000000000..b8034039e6
--- /dev/null
+++ b/indra/lscript/lscript_compile/windows/unistd.h
@@ -0,0 +1,29 @@
+/**
+ * $LicenseInfo:firstyear=2002&license=viewergpl$
+ *
+ * Copyright (c) 2002-2007, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlife.com/developers/opensource/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at http://secondlife.com/developers/opensource/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+/* After all that, this file is empty. */