More branch merging
git-svn-id: svn://10.0.0.236/trunk@100431 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
426
mozilla/js2/src/winbuild/dikdik.dsp
Normal file
426
mozilla/js2/src/winbuild/dikdik.dsp
Normal file
@@ -0,0 +1,426 @@
|
||||
# Microsoft Developer Studio Project File - Name="DikDik" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||
|
||||
CFG=DikDik - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DikDik.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DikDik.mak" CFG="DikDik - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DikDik - Win32 Release" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE "DikDik - Win32 Debug" (based on "Win32 (x86) Static Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
|
||||
# ADD CPP /nologo /GX /O2 /Ob2 /D "_LIB" /D "NDEBUG" /D "WIN32" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "DikDik___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "DikDik___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "DikDik___Win32_Debug"
|
||||
# PROP Intermediate_Dir "DikDik___Win32_Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "../../../js/src/fdlibm" /D "_LIB" /D "DEBUG" /D "_DEBUG" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LIB32=link.exe -lib
|
||||
# ADD BASE LIB32 /nologo
|
||||
# ADD LIB32 /nologo
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "DikDik - Win32 Release"
|
||||
# Name "DikDik - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\bytecodegen.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\exception.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\fdlibm_ns.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\formatter.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\hash.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\js2execution.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\js2runtime.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\jsarray.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\jsmath.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\jsstring.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\lexer.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\mem.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\numerics.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\parser.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\reader.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\strings.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\token.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\tracer.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\utilities.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\world.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik - Win32 Release"
|
||||
|
||||
# ADD CPP /W4 /GR
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\algo.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\bytecodegen.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\ds.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\exception.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\fdlibm_ns.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\formatter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\hash.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\js2runtime.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\jsarray.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\jsmath.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\jsstring.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\lexer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\mem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\numerics.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\parser.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\property.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\reader.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\stlcfg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\strings.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\systemtypes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\token.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\utilities.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\world.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
59
mozilla/js2/src/winbuild/dikdik.dsw
Normal file
59
mozilla/js2/src/winbuild/dikdik.dsw
Normal file
@@ -0,0 +1,59 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "DikDik"=.\DikDik.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name fdlibm
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "DikDik_shell"=..\..\tests\cpp\winbuild\DikDik_shell.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name DikDik
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "fdlibm"=.\fdlibm\fdlibm.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
277
mozilla/js2/tests/cpp/DikDik_Shell.cpp
Normal file
277
mozilla/js2/tests/cpp/DikDik_Shell.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
//
|
||||
// The contents of this file are subject to the Netscape Public
|
||||
// License Version 1.1 (the "License"); you may not use this file
|
||||
// except in compliance with the License. You may obtain a copy of
|
||||
// the License at http://www.mozilla.org/NPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS
|
||||
// IS" basis, WITHOUT WARRANTY OF ANY KIND, either express oqr
|
||||
// implied. See the License for the specific language governing
|
||||
// rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the JavaScript 2 Prototype.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Netscape
|
||||
// Communications Corporation. Portions created by Netscape are
|
||||
// Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
// Rights Reserved.
|
||||
|
||||
|
||||
//
|
||||
// JS2 shell.
|
||||
//
|
||||
|
||||
#ifdef _WIN32
|
||||
// Turn off warnings about identifiers too long in browser information
|
||||
#pragma warning(disable: 4786)
|
||||
#endif
|
||||
|
||||
#define EXITCODE_RUNTIME_ERROR 3
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
#include "world.h"
|
||||
#include "reader.h"
|
||||
#include "parser.h"
|
||||
#include "js2runtime.h"
|
||||
#include "bytecodegen.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "tracer.h"
|
||||
#endif
|
||||
|
||||
#if defined(XP_MAC) && !defined(XP_MAC_MPW)
|
||||
#include <SIOUX.h>
|
||||
#include <MacTypes.h>
|
||||
|
||||
static char *mac_argv[] = {"js2", 0};
|
||||
|
||||
static void initConsole(StringPtr consoleName,
|
||||
const char* startupMessage,
|
||||
int &argc, char **&argv)
|
||||
{
|
||||
SIOUXSettings.autocloseonquit = false;
|
||||
SIOUXSettings.asktosaveonclose = false;
|
||||
SIOUXSetTitle(consoleName);
|
||||
|
||||
// Set up a buffer for stderr (otherwise it's a pig).
|
||||
static char buffer[BUFSIZ];
|
||||
setvbuf(stderr, buffer, _IOLBF, BUFSIZ);
|
||||
|
||||
JavaScript::stdOut << startupMessage;
|
||||
|
||||
argc = 1;
|
||||
argv = mac_argv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
using namespace JavaScript::JS2Runtime;
|
||||
|
||||
|
||||
JavaScript::World world;
|
||||
JavaScript::Arena a;
|
||||
|
||||
bool gTraceFlag = false;
|
||||
|
||||
namespace JavaScript {
|
||||
namespace Shell {
|
||||
|
||||
// Interactively read a line from the input stream in and put it into
|
||||
// s. Return false if reached the end of input before reading anything.
|
||||
static bool promptLine(LineReader &inReader, string &s, const char *prompt)
|
||||
{
|
||||
if (prompt) {
|
||||
stdOut << prompt;
|
||||
#ifdef XP_MAC_MPW
|
||||
// Print a CR after the prompt because MPW grabs the entire
|
||||
// line when entering an interactive command.
|
||||
stdOut << '\n';
|
||||
#endif
|
||||
}
|
||||
return inReader.readLine(s) != 0;
|
||||
}
|
||||
|
||||
|
||||
/* "filename" of the console */
|
||||
const String ConsoleName = widenCString("<console>");
|
||||
const bool showTokens = false;
|
||||
|
||||
#define INTERPRET_INPUT 1
|
||||
//#define SHOW_ICODE 1
|
||||
|
||||
|
||||
static JSValue load(Context *cx, const JSValue& /*thisValue*/, JSValue *argv, uint32 argc)
|
||||
{
|
||||
if ((argc >= 1) && (argv[0].isString())) {
|
||||
const String& fileName = *argv[0].string;
|
||||
cx->readEvalFile(fileName);
|
||||
}
|
||||
return kUndefinedValue;
|
||||
}
|
||||
|
||||
static JSValue print(Context *, const JSValue& /*thisValue*/, JSValue *argv, uint32 argc)
|
||||
{
|
||||
for (uint32 i = 0; i < argc; i++) {
|
||||
stdOut << argv[i] << "\n";
|
||||
}
|
||||
return kUndefinedValue;
|
||||
}
|
||||
|
||||
static JSValue debug(Context *cx, const JSValue& /*thisValue*/, JSValue * /*argv*/, uint32 /*argc*/)
|
||||
{
|
||||
cx->mDebugFlag = !cx->mDebugFlag;
|
||||
return kUndefinedValue;
|
||||
}
|
||||
|
||||
static JSValue trace(Context * /*cx*/, const JSValue& /*thisValue*/, JSValue * /*argv*/, uint32 /*argc*/)
|
||||
{
|
||||
gTraceFlag = true;
|
||||
stdOut << "Will report allocation stats\n";
|
||||
return kUndefinedValue;
|
||||
}
|
||||
|
||||
static JSValue dikdik(Context * /*cx*/, const JSValue& /*thisValue*/, JSValue * /*argv*/, uint32 /*argc*/)
|
||||
{
|
||||
extern void do_dikdik(Formatter &f);
|
||||
do_dikdik(stdOut);
|
||||
return kUndefinedValue;
|
||||
}
|
||||
|
||||
static int readEvalPrint(Context *cx, FILE *in)
|
||||
{
|
||||
int result = 0;
|
||||
String buffer;
|
||||
string line;
|
||||
LineReader inReader(in);
|
||||
while (promptLine(inReader, line, buffer.empty() ? "dd> " : "> ")) {
|
||||
appendChars(buffer, line.data(), line.size());
|
||||
try {
|
||||
Parser p(world, a, cx->mFlags, buffer, ConsoleName);
|
||||
cx->setReader(&p.lexer.reader);
|
||||
if (showTokens) {
|
||||
Lexer &l = p.lexer;
|
||||
while (true) {
|
||||
const Token &t = l.get(true);
|
||||
if (t.hasKind(Token::end))
|
||||
break;
|
||||
stdOut << ' ';
|
||||
t.print(stdOut, true);
|
||||
}
|
||||
stdOut << '\n';
|
||||
} else {
|
||||
StmtNode *parsedStatements = p.parseProgram();
|
||||
ASSERT(p.lexer.peek(true).hasKind(Token::end));
|
||||
if (cx->mDebugFlag)
|
||||
{
|
||||
PrettyPrinter f(stdOut, 30);
|
||||
{
|
||||
PrettyPrinter::Block b(f, 2);
|
||||
f << "Program =";
|
||||
f.linearBreak(1);
|
||||
StmtNode::printStatements(f, parsedStatements);
|
||||
}
|
||||
f.end();
|
||||
stdOut << '\n';
|
||||
}
|
||||
#ifdef INTERPRET_INPUT
|
||||
// Generate code for parsedStatements, which is a linked
|
||||
// list of zero or more statements
|
||||
cx->buildRuntime(parsedStatements);
|
||||
JS2Runtime::ByteCodeModule* bcm = cx->genCode(parsedStatements, ConsoleName);
|
||||
if (bcm) {
|
||||
#ifdef SHOW_ICODE
|
||||
stdOut << *bcm;
|
||||
#endif
|
||||
bcm->setSource(buffer, ConsoleName);
|
||||
cx->setReader(NULL);
|
||||
JSValue result = cx->interpret(bcm, 0, NULL, JSValue(cx->getGlobalObject()), NULL, 0);
|
||||
if (!result.isUndefined())
|
||||
stdOut << result.toString(cx) << "\n";
|
||||
delete bcm;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
clear(buffer);
|
||||
} catch (Exception &e) {
|
||||
// If we got a syntax error on the end of input, then wait for a continuation
|
||||
// of input rather than printing the error message.
|
||||
if (!(e.hasKind(Exception::syntaxError) && e.lineNum && e.pos == buffer.size() &&
|
||||
e.sourceFile == ConsoleName)) {
|
||||
stdOut << '\n' << e.fullMessage();
|
||||
clear(buffer);
|
||||
result = EXITCODE_RUNTIME_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
stdOut << '\n';
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool processArgs(Context *cx, int argc, char **argv, int *result)
|
||||
{
|
||||
bool doInteractive = true;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i][1]) {
|
||||
case 'f':
|
||||
{
|
||||
try {
|
||||
cx->readEvalFile(JavaScript::widenCString(argv[++i]));
|
||||
} catch (Exception &e) {
|
||||
stdOut << '\n' << e.fullMessage();
|
||||
*result = EXITCODE_RUNTIME_ERROR;
|
||||
}
|
||||
doInteractive = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return doInteractive;
|
||||
}
|
||||
|
||||
} /* namespace Shell */
|
||||
} /* namespace JavaScript */
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#if defined(XP_MAC) && !defined(XP_MAC_MPW)
|
||||
initConsole("\pJavaScript Shell", "Welcome to the js2 shell.\n", argc, argv);
|
||||
#endif
|
||||
|
||||
using namespace JavaScript;
|
||||
using namespace Shell;
|
||||
|
||||
try {
|
||||
JSObject *globalObject;
|
||||
Context cx(&globalObject, world, a, Pragma::js2);
|
||||
|
||||
globalObject->defineVariable(&cx, widenCString("load"), (NamespaceList *)(NULL), NULL, JSValue(new JSFunction(load, NULL)));
|
||||
globalObject->defineVariable(&cx, widenCString("print"), (NamespaceList *)(NULL), NULL, JSValue(new JSFunction(print, NULL)));
|
||||
globalObject->defineVariable(&cx, widenCString("debug"), (NamespaceList *)(NULL), NULL, JSValue(new JSFunction(debug, NULL)));
|
||||
globalObject->defineVariable(&cx, widenCString("trace"), (NamespaceList *)(NULL), NULL, JSValue(new JSFunction(trace, NULL)));
|
||||
globalObject->defineVariable(&cx, widenCString("dikdik"), (NamespaceList *)(NULL), NULL, JSValue(new JSFunction(dikdik, NULL)));
|
||||
|
||||
bool doInteractive = true;
|
||||
int result = 0;
|
||||
if (argc > 1) {
|
||||
doInteractive = processArgs(&cx, argc - 1, argv + 1, &result);
|
||||
}
|
||||
if (doInteractive)
|
||||
result = readEvalPrint(&cx, stdin);
|
||||
|
||||
if (gTraceFlag)
|
||||
trace_dump(JavaScript::stdOut);
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception &e) {
|
||||
stdOut << '\n' << e.fullMessage();
|
||||
return EXITCODE_RUNTIME_ERROR;
|
||||
}
|
||||
}
|
||||
118
mozilla/js2/tests/cpp/winbuild/DikDik_shell.dsp
Normal file
118
mozilla/js2/tests/cpp/winbuild/DikDik_shell.dsp
Normal file
@@ -0,0 +1,118 @@
|
||||
# Microsoft Developer Studio Project File - Name="DikDik_shell" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=DikDik_shell - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DikDik_shell.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "DikDik_shell.mak" CFG="DikDik_shell - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DikDik_shell - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "DikDik_shell - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "DikDik_shell - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "../../src" /D "_CONSOLE" /D "NDEBUG" /D "WIN32" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik_shell - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "DikDik_shell___Win32_Debug"
|
||||
# PROP BASE Intermediate_Dir "DikDik_shell___Win32_Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "DikDik_shell___Win32_Debug"
|
||||
# PROP Intermediate_Dir "DikDik_shell___Win32_Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "../../src" /D "_CONSOLE" /D "DEBUG" /D "_DEBUG" /D "WIN32" /D "_MBCS" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "DikDik_shell - Win32 Release"
|
||||
# Name "DikDik_shell - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\DikDik_Shell.cpp
|
||||
|
||||
!IF "$(CFG)" == "DikDik_shell - Win32 Release"
|
||||
|
||||
# ADD CPP /GR /I "../../../src"
|
||||
# SUBTRACT CPP /I "../../src"
|
||||
|
||||
!ELSEIF "$(CFG)" == "DikDik_shell - Win32 Debug"
|
||||
|
||||
# ADD CPP /I "../../../src"
|
||||
# SUBTRACT CPP /I "../../src"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\winbuild\DikDik___Win32_Debug\DikDik.lib
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
Reference in New Issue
Block a user