dslinux/user/pixil/packages/viewml/viewml/jscript Makefile Makefile.am Makefile.in Makefile.new README bison2cpp.h builtin.cpp builtin.h cpp2bison.cpp jserror.h jsexec.cpp jsexec.h jstree.cpp jstree.h t1.c t1.h t1.y t2.c t2.l
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:26:27 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/packages/viewml/viewml/jscript
In directory antilope:/tmp/cvs-serv11916/packages/viewml/viewml/jscript
Added Files:
Makefile Makefile.am Makefile.in Makefile.new README
bison2cpp.h builtin.cpp builtin.h cpp2bison.cpp jserror.h
jsexec.cpp jsexec.h jstree.cpp jstree.h t1.c t1.h t1.y t2.c
t2.l
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: cpp2bison.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#define ____CPP____
#include "bison2cpp.h"
#include "jstree.h"
#include "jsexec.h"
#include <qlist.h>
JSCode *code;
extern "C" void* newJSInteger( int _value )
{
return (void*) new JSInteger( _value );
}
extern "C" void* newJSBinaryOperator( int _op, void* _left, void *_right )
{
return (void*) new JSBinaryOperator( _op, (JSNode*)_left, (JSNode*)_right );
}
extern "C" void* newJSAssignment( int _op, void* _left, void *_right )
{
return (void*) new JSAssignment( _op, (JSNode*)_left, (JSNode*)_right );
}
extern "C" void* newJSIdentifier( char *_name )
{
return (void*) new JSIdentifier( (const char *)_name );
}
extern "C" void* newJSStatement( void *_code, void *_next_code )
{
return (void*) new JSStatement( (JSNode*)_code, (JSNode*)_next_code );
}
extern "C" void jsAppendCode( void *_code )
{
code->append( (JSNode*)_code );
}
extern "C" void* newJSFunction( const char *_name, void *_param, void *_code )
{
return (void*) new JSFunction( _name, (JSParameter*)_param, (JSNode*)_code );
}
extern "C" void* newJSParameter( const char *_name, void *_next )
{
return (void*) new JSParameter( _name, (JSParameter*)_next );
}
extern "C" void* newJSArgument( void *_code, void *_next )
{
return (void*) new JSArgument( (JSNode*)_code, (JSArgument*)_next );
}
extern "C" void* newJSFunctionCall( void *_function, void *_arguments )
{
return (void*) new JSFunctionCall( (JSNode*)_function, (JSArgument*)_arguments );
}
extern "C" void* newJSConstructorCall( void *_function, void *_arguments )
{
return (void*) new JSConstructorCall( (JSNode*)_function, (JSArgument*)_arguments );
}
extern "C" void* newJSThis()
{
return (void*) new JSThis();
}
extern "C" void* newJSNull()
{
return (void*) new JSNull();
}
extern "C" void* newJSMember( void *_obj, char* _member )
{
return (void*) new JSMember( (JSNode*)_obj, (const char*)_member );
}
extern "C" void* newJSArrayAccess( void *_array, void *_index )
{
return (void*) new JSArrayAccess( (JSNode*)_array, (JSNode*)_index );
}
extern "C" void* newJSString( char *_string )
{
return (void*) new JSString( (const char*)_string );
}
extern "C" void* newJSBool( char _bool )
{
return (void*) new JSBool( (bool)_bool );
}
extern "C" void* newJSFloat( double _f )
{
return (void*) new JSFloat( _f );
}
int parseJavaScript( const char *_script, JSCode* _code, JSScope* _global )
{
code = _code;
mainParse( _script );
JSNode *c;
for ( c = _code->first(); c != 0L; c = _code->next() )
{
if ( c->isA() == ID_JSFunction )
{
JSFunction *func = (JSFunction*)c;
_global->insertObject( new JSFunctionObject( func ) );
}
}
return 0L;
}
--- NEW FILE: bison2cpp.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef bison2cpp_h
#define bison2cpp_h
#define OP_ASSIGN 1
#define OP_MUL 20
#define OP_ADD 21
#define OP_DIV 22
#define OP_SUB 23
#define OP_SL 24
#define OP_SR 25
#define OP_BAND 26
#define OP_BOR 27
#define OP_BXOR 28
#define OP_AND 30
#define OP_OR 31
#define OP_EQ 40
#define OP_NEQ 41
#define OP_LT 42
#define OP_GT 43
#define OP_LEQ 44
#define OP_GEQ 45
#ifndef ____CPP____
void* newJSInteger( int _value );
void* newJSBinaryOperator( int _op, void* _left, void *_right );
void* newJSAssignment( int _op, void* _left, void *_right );
void* newJSIdentifier( char* _name );
void* newJSStatement( void *_code, void *_next_code );
void* newJSFunction( const char *_name, void *_param, void *_code );
void* newJSParameter( const char *_name, void *_next );
void* newJSArgument( void *_code, void *_next );
void* newJSFunctionCall( void *_function, void *_arguments );
void* newJSConstructorCall( void *_function, void *_arguments );
void* newJSMember( void *_obj, char* _member );
void* newJSArrayAccess( void *_array, void *_index );
void* newJSString( char *_string );
void* newJSBool( char );
void* newJSFloat( double );
void* newJSThis();
void* newJSNull();
void jsAppendCode( void *_code );
void mainParse( const char *_code );
#else
extern "C" void mainParse( const char *_code );
#endif
#endif
--- NEW FILE: t2.l ---
%{
#include "t1.h"
#include <string.h>
#include <stdlib.h>
char* putSymbol( char *_name );
char* putString( char *_name );
int yywrap();
void initFlex( const char *_code );
%}
DIGIT [0-9]
ID [a-z][a-z0-9]*
%%
"function" { return FUNCTION; }
"if" { return IF; }
"else" { return ELSE; }
"in" { return IN; }
"with" { return WITH; }
"while" { return WHILE; }
"for" { return FOR; }
"<<" { return SHIFT_LEFT; }
">>" { return SHIFT_RIGHT; }
"==" { return EQ; }
"!=" { return NEQ; }
"||" { return OR; }
"&&" { return AND; }
"this" { return THIS; }
"null" { return B_NULL; }
"true" { return B_TRUE; }
"false" { return B_FALSE; }
"new" { return NEW; }
"delete" { return DELETE; }
"break" { return BREAK; }
"continue" { return CONTINUE; }
"return" { return RETURN; }
"var" { return VAR; }
"++" { return PP; }
"--" { return MM; }
"<=" { return LEQ; }
">=" { return GEQ; }
"*=" { return MAS; }
"/=" { return DAS; }
"+=" { return AAS; }
"-=" { return SAS; }
"^=" { return PAS; }
"%=" { return RAS; }
"&=" { return BAAS; }
"|=" { return BOAS; }
"\""[^\"]*"\"" { yyjscriptlval.name = putString( yytext ); return STRING; }
"'"[^']*"'" { yyjscriptlval.name = putString( yytext ); return STRING; }
{DIGIT}+ { yyjscriptlval.vali = atoi( yytext ); return NUM; }
{DIGIT}*"\."{DIGIT}+ { yyjscriptlval.vald = atof( yytext ); return FLOAT; }
{ID} { yyjscriptlval.name = putSymbol( yytext ); return IDENTIFIER; }
">"|"<"|"^"|"&"|"\|"|"="|";"|"\."|"+"|"-"|"*"|"/"|"("|")"|"{"|"}"|"["|"]"|"," { yyjscriptlval.name = 0L; return (int)(*yytext); }
[ \t\n]+ /* eat up whitespace */
. { printf( "Unrecognized character: %s\n", yytext ); }
%%
char* putSymbol( char *_name )
{
char *p = (char*)malloc( strlen( _name ) + 1 );
strcpy( p, _name );
return p;
}
char* putString( char *_str )
{
int l = strlen( _str );
char *p = (char*)malloc( l );
char *s = _str + 1;
char *d = p;
while ( s < _str + l - 1 )
{
if ( *s != '\\' )
*d++ = *s++;
else
{
s++;
if ( *s == '\\' )
*d++ = '\\';
else if ( *s == 'n' )
*d++ = '\n';
else if ( *s == 'r' )
*d++ = '\r';
else if ( *s == 't' )
*d++ = '\t';
s++;
}
}
*d = 0;
return p;
}
int yywrap()
{
yy_delete_buffer( YY_CURRENT_BUFFER );
return 1;
}
void initFlex( const char *_code )
{
yy_switch_to_buffer( yy_scan_string( _code ) );
}
--- NEW FILE: t1.y ---
%{
#include "bison2cpp.h"
void yyerror(char *s);
int yylex();
void initFlex( const char *_code );
%}
%union
{
int vali;
double vald;
char *name;
void *ptr;
}
%token FUNCTION
%token IF
%token ELSE
%token IN
%token WITH
%token WHILE
%token FOR
%token SHIFT_LEFT
%token SHIFT_RIGHT
%token EQ
%token NEQ
%token OR
%token AND
%token THIS
%token B_NULL
%token FLOAT
%token B_TRUE
%token B_FALSE
%token NEW
%token DELETE
%token BREAK
%token CONTINUE
%token RETURN
%token VAR
%token PP
%token MM
%token <name> STRING
%token LEQ
%token GEQ
%token MAS
%token DAS
%token AAS
%token SAS
%token PAS
%token RAS
%token BAAS
%token BOAS
%token <vali> NUM /* number */
%token <vald> FLOAT
%token <name> IDENTIFIER /* Variable and Function */
%type <ptr> primaryExpression
%type <ptr> expression
%type <ptr> assignmentExpression
%type <ptr> orExpression
%type <ptr> andExpression
%type <ptr> bitwiseOrExpression
%type <ptr> bitwiseAndExpression
%type <ptr> bitwiseXorExpression
%type <ptr> unaryExpression
%type <ptr> additiveExpression
%type <ptr> multiplicativeExpression
%type <ptr> shiftExpression
%type <ptr> relationalExpression
%type <ptr> equalityExpression
%type <ptr> conditionalExpression
%type <ptr> expressionOpt
%type <ptr> memberExpression
%type <ptr> simpleExpression
%type <ptr> statement
%type <ptr> statements
%type <ptr> compoundStatement
%type <ptr> variablesOrExpression
%type <ptr> element
%type <ptr> parameterListOpt
%type <ptr> parameterList
%type <ptr> argumentList
%type <ptr> argumentListOpt
%type <ptr> constructor
%type <ptr> constructorCall
/* Grammar follows */
%%
input: /* empty */
| input element { printf("!!!!! Adding code !!!!!\n"); jsAppendCode( $<ptr>2 ); }
;
element: FUNCTION IDENTIFIER '(' parameterListOpt ')' compoundStatement { printf("Function: '%s'\n",$<name>2 ); $$ = newJSFunction( $<name>2, $<ptr>4, $<ptr>6 ); }
| statements { printf("Statement\n"); $$ = $<ptr>1; }
| error '\n' { yyerrok; $$ = 0L; }
;
parameterListOpt: /* empty */ { $$ = 0L; }
| parameterList { $$ = $<ptr>1; }
;
parameterList: IDENTIFIER { printf("param '%s'\n", $<name>1); $$ = newJSParameter( $<name>1, 0L ); }
| IDENTIFIER ',' parameterList { printf("param '%s\n", $<name>1); $$ = newJSParameter( $<name>1, $<ptr>3 ); }
;
compoundStatement: '{' statements '}' { $$ = $<ptr>2; }
;
statements: /* empty */ { $$ = 0L; }
| statement statements { printf(" "); $$ = newJSStatement( $<ptr>1, $<ptr>2 ); }
| compoundStatement { printf(" "); $$ = $<ptr>1; }
;
statement: ';' { printf(" "); $$ = 0L; }
| IF condition statement { printf("Simple IF\n"); $$ = 0L; }
| IF condition statement ELSE statement { printf("Complex IF\n"); $$ = 0L; }
| WHILE condition statement { printf(" "); $$ = 0L; }
| forParen ';' expressionOpt ';' expressionOpt ')' statement { printf(" "); $$ = 0L; }
| forBegin ';' expressionOpt ';' expressionOpt ')' statement { printf(" "); $$ = 0L; }
| forBegin IN expression ')' statement { printf(" "); $$ = 0L; }
| BREAK semiOpt { printf(" "); $$ = 0L; }
| CONTINUE semiOpt { printf(" "); $$ = 0L; }
| WITH '(' expression ')' statement { printf(" "); $$ = 0L; }
| RETURN expressionOpt semiOpt { printf(" "); $$ = 0L; }
| compoundStatement { printf(" "); $$ = $<ptr>1; }
| variablesOrExpression semiOpt { printf(" "); $$ = $<ptr>1; }
;
semiOpt:
| ';' { printf(" "); }
;
condition: '(' expression ')' { printf("Condition\n"); }
;
forParen: FOR '(' { printf(" "); }
;
forBegin: forParen variablesOrExpression { printf(" "); }
;
variablesOrExpression: VAR variables { printf(" "); $$ = 0L; }
| assignmentExpression { printf(" "); $$ = $<ptr>1; }
;
variables: variable { printf(" "); }
| variable ',' variables { printf(" "); }
;
variable: IDENTIFIER { printf("Var: '%s'\n", $<name>1); }
| IDENTIFIER '=' assignmentExpression { printf("Var with Assignment: '%s'\n", $<name>1); }
;
expressionOpt: /* empty */ { $$ = 0L; }
| expression { printf(" "); $$ = $<ptr>1; }
;
expression: assignmentExpression { printf(" "); $$ = $<ptr>1; }
| assignmentExpression expression { printf(" "); }
;
assignmentExpression: conditionalExpression { printf(" "); $$ = $<ptr>1; }
| conditionalExpression '=' assignmentExpression { printf("Assignment ( = )\n"); $$ = newJSAssignment( OP_ASSIGN, $<ptr>1, $<ptr>3 ); }
| conditionalExpression MAS assignmentExpression { printf("Assignment ( *= )\n"); }
| conditionalExpression DAS assignmentExpression { printf("Assignment ( /= )\n"); }
| conditionalExpression AAS assignmentExpression { printf("Assignment ( += )\n"); }
| conditionalExpression SAS assignmentExpression { printf("Assignment ( -= )\n"); }
| conditionalExpression PAS assignmentExpression { printf("Assignment ( ^= )\n"); }
| conditionalExpression RAS assignmentExpression { printf("Assignment ( %%= )\n"); }
| conditionalExpression BAAS assignmentExpression { printf("Assignment ( &= )\n"); }
| conditionalExpression BOAS assignmentExpression { printf("Assignment ( |= )\n"); }
;
conditionalExpression: orExpression { printf(" "); $$ = $<ptr>1; }
| orExpression '?' assignmentExpression ':' assignmentExpression { printf(" "); }
;
orExpression: andExpression { printf(" "); $$ = $<ptr>1; }
| andExpression OR orExpression { printf(" "); $$ = newJSBinaryOperator( OP_OR, $<ptr>1, $<ptr>3 ); }
;
andExpression: bitwiseOrExpression { printf(" "); $$ = $<ptr>1; }
| bitwiseOrExpression AND andExpression { printf(" "); $$ = newJSBinaryOperator( OP_AND, $<ptr>1, $<ptr>3 ); }
;
bitwiseOrExpression: bitwiseXorExpression { printf(" "); $$ = $<ptr>1; }
| bitwiseXorExpression '|' bitwiseOrExpression { printf(" "); $$ = newJSBinaryOperator( OP_BOR, $<ptr>1, $<ptr>3 ); }
;
bitwiseXorExpression: bitwiseAndExpression { printf(" "); $$ = $<ptr>1; }
| bitwiseAndExpression '^' bitwiseXorExpression { printf(" "); $$ = newJSBinaryOperator( OP_BXOR, $<ptr>1, $<ptr>3 ); }
;
bitwiseAndExpression: equalityExpression { printf(" "); $$ = $<ptr>1; }
| equalityExpression '&' bitwiseAndExpression { printf(" "); $$ = newJSBinaryOperator( OP_BAND, $<ptr>1, $<ptr>3 ); }
;
equalityExpression: relationalExpression { printf(" "); $$ = $<ptr>1; }
| relationalExpression EQ equalityExpression { printf(" "); $$ = newJSBinaryOperator( OP_EQ, $<ptr>1, $<ptr>3 ); }
| relationalExpression NEQ equalityExpression { printf(" "); $$ = newJSBinaryOperator( OP_NEQ, $<ptr>1, $<ptr>3 ); }
;
relationalExpression: shiftExpression { printf(" "); $$ = $<ptr>1; }
| relationalExpression '<' shiftExpression { printf(" "); $$ = newJSBinaryOperator( OP_LT, $<ptr>1, $<ptr>3 ); }
| relationalExpression '>' shiftExpression { printf(" "); $$ = newJSBinaryOperator( OP_GT, $<ptr>1, $<ptr>3 ); }
| relationalExpression LEQ shiftExpression { printf(" "); $$ = newJSBinaryOperator( OP_LEQ, $<ptr>1, $<ptr>3 ); }
| relationalExpression GEQ shiftExpression { printf(" "); $$ = newJSBinaryOperator( OP_GEQ, $<ptr>1, $<ptr>3 ); }
;
shiftExpression: additiveExpression { printf(" "); $$ = $<ptr>1; }
| additiveExpression SHIFT_LEFT shiftExpression { printf(" "); $$ = newJSBinaryOperator( OP_SL, $<ptr>1, $<ptr>3 ); }
| additiveExpression SHIFT_RIGHT shiftExpression { printf(" "); $$ = newJSBinaryOperator( OP_SR, $<ptr>1, $<ptr>3 );}
;
additiveExpression: multiplicativeExpression { printf(" "); $$ = $<ptr>1; }
| multiplicativeExpression '+' additiveExpression { printf("Add ( + )\n"); $$ = newJSBinaryOperator( OP_ADD, $<ptr>1, $<ptr>3 ); }
| multiplicativeExpression '-' additiveExpression { printf("Sub ( - )\n"); $$ = newJSBinaryOperator( OP_SUB, $<ptr>1, $<ptr>3 ); }
;
multiplicativeExpression: unaryExpression { printf(" "); $$ = $<ptr>1; }
| unaryExpression '*' multiplicativeExpression { printf("Mul ( * )\n"); $$ = newJSBinaryOperator( OP_MUL, $<ptr>1, $<ptr>3 ); }
| unaryExpression '/' multiplicativeExpression { printf("Div ( / )\n"); $$ = newJSBinaryOperator( OP_DIV, $<ptr>1, $<ptr>3 ); }
;
unaryExpression: simpleExpression { printf(" "); $$ = $<ptr>1; }
| '-' unaryExpression { printf("Unary Minus\n"); }
| PP simpleExpression { printf("++ Prefix\n"); }
| MM simpleExpression { printf("-- Prefix\n"); }
| simpleExpression PP { printf("Postfix ++\n"); }
| simpleExpression MM { printf("Postfix --\n"); }
| NEW constructor { printf("new\n"); $$ = $<ptr>2; }
| DELETE simpleExpression { printf("delete\n"); }
;
constructor: THIS '.' constructorCall { printf(" "); $$ = 0L; }
| constructorCall { printf(" "); $$ = $<ptr>1; }
;
constructorCall: IDENTIFIER { printf(" "); $$ = newJSConstructorCall( newJSIdentifier( $<name>1 ) , 0L ); }
| IDENTIFIER '(' argumentListOpt ')' { printf(" "); $$ = newJSConstructorCall( newJSIdentifier( $<name>1 ), $<ptr>3 ); }
| IDENTIFIER '.' constructorCall { printf(" "); $$ = 0L; }
;
simpleExpression: memberExpression { printf(" "); $$ = $<ptr>1; }
| memberExpression '[' expression ']' { printf("[ ]\n"); $$ = newJSArrayAccess( $<ptr>1, $<ptr>3 ); }
| memberExpression '(' argumentListOpt ')' { printf("Function Call\n"); $$ = newJSFunctionCall( $<ptr>1, $<ptr>3 ); }
;
memberExpression: primaryExpression { printf(" "); $$ = $<ptr>1; }
| simpleExpression '.' IDENTIFIER { printf("Member ( '%s' )\n", $<name>3 ); $$ = newJSMember( $<ptr>1, $<name>3 ); }
;
argumentListOpt: /* empty */ { $$ = 0L; }
| argumentList { printf("ArgumentList\n"); $$ = $<ptr>1; }
;
argumentList: assignmentExpression { printf("Argument\n"); $$ = newJSArgument( $<ptr>1, 0L ); }
| assignmentExpression ',' argumentList { printf("Argument (cont)\n"); $$ = newJSArgument( $<ptr>1, $<ptr>3 ); }
;
primaryExpression: '(' expression ')' { printf("Paranthesis\n"); $$ = $<ptr>2; }
| IDENTIFIER { printf("ID '%s'\n",$<name>1); $$ = newJSIdentifier( $<name>1 ); }
| NUM { printf("NUM\n"); $$ = newJSInteger( $<vali>1 ); }
| FLOAT { printf(" "); $$ = newJSFloat( $<vald>1 ); }
| STRING { printf(" "); $$ = newJSString( $<name>1 ); }
| B_FALSE { printf(" "); $$ = newJSBool( 0 ); }
| B_TRUE { printf(" "); $$ = newJSBool( 1 ); }
| B_NULL { printf(" "); $$ = newJSNull(); }
| THIS { printf(" "); $$ = newJSThis(); }
;
/* End of grammar */
%%
void yyerror ( char *s ) /* Called by yyparse on error */
{
printf ("ERROR: %s\n", s);
}
void mainParse( const char *_code )
{
initFlex( _code );
yyparse();
}
--- NEW FILE: Makefile ---
YACC = bison -y
YFLAGS = -d -p yyjscript
LEX = flex
SOURCES = t1.c t2.c cpp2bison.cpp jstree.cpp jsexec.cpp builtin.cpp
OBJS = t1.o t2.o cpp2bison.o jstree.o jsexec.o builtin.o
INCLUDES=-I../src/fltk
OBJECTS = $(CPPFILES:.cxx=.o) $(CFILES:.c=.o)
all: grammarfiles $(OBJS)
grammarfiles: t1.y t2.l
$(YACC) $(YFLAGS) t1.y $< && mv y.tab.c t1.c
if test -f y.tab.h; then \
if cmp -s y.tab.h t1.h; then rm -f y.tab.h; \
else mv y.tab.h t1.h; fi \
else :; fi
$(LEX) -Pyyjscript t2.l && mv lex.yyjscript.c t2.c
.SUFFIXES: .cpp .h .o
.cpp.o :
$(CXX) $(INCLUDES) -I.. $(CXXFLAGS) -c -o $@ $<
.c.o :
$(CC) -I.. $(INCLUDES) $(CFLAGS) -c -o $@ $<
clean :
-@ rm -f *.o *.do $(DSONAME) $(LIBRARY) $(CLEAN) core *~ ../include/*~ makedepend cmap
--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# This file is part of the KDE libraries
# Copyright (C) 1997 Torben Weis (weis at kde.org)
# (C) 1997 Stephan Kulow (coolo at kde.org)
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
####### General stuff
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DLLTOOL = @DLLTOOL@
GLINC = @GLINC@
GLLIB = @GLLIB@
GMSGFMT = @GMSGFMT@
IDL = @IDL@
KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@
KDE_INCLUDES = @KDE_INCLUDES@
KDE_LDFLAGS = @KDE_LDFLAGS@
KDE_RPATH = @KDE_RPATH@
LD = @LD@
LIBCOMPAT = @LIBCOMPAT@
LIBCRYPT = @LIBCRYPT@
LIBDL = @LIBDL@
LIBJPEG = @LIBJPEG@
LIBMICO = @LIBMICO@
LIBOBJS = @LIBOBJS@
LIBPNG = @LIBPNG@
LIBPTHREAD = @LIBPTHREAD@
LIBPYTHON = @LIBPYTHON@
LIBQIMGIO = @LIBQIMGIO@
LIBSOCKET = @LIBSOCKET@
LIBTIFF = @LIBTIFF@
LIBTOOL = @LIBTOOL@
LIBUCB = @LIBUCB@
LIBZ = @LIBZ@
LIB_KAB = @LIB_KAB@
LIB_KDECORE = @LIB_KDECORE@
LIB_KDEUI = @LIB_KDEUI@
LIB_KDEUTIL = @LIB_KDEUTIL@
LIB_KFILE = @LIB_KFILE@
LIB_KFM = @LIB_KFM@
LIB_KHTML = @LIB_KHTML@
LIB_KHTMLW = @LIB_KHTMLW@
LIB_KIMGIO = @LIB_KIMGIO@
LIB_KIO = @LIB_KIO@
LIB_MEDIATOOL = @LIB_MEDIATOOL@
LIB_QT = @LIB_QT@
LIB_X11 = @LIB_X11@
LN_S = @LN_S@
MAKEINFO = @MAKEINFO@
MICO_INCLUDES = @MICO_INCLUDES@
MICO_LDFLAGS = @MICO_LDFLAGS@
MOC = @MOC@
MSGFMT = @MSGFMT@
NM = @NM@
PACKAGE = @PACKAGE@
PAMINC = @PAMINC@
PAMLIBPATHS = @PAMLIBPATHS@
PAMLIBS = @PAMLIBS@
PYTHONINC = @PYTHONINC@
PYTHONLIB = @PYTHONLIB@
QKEYCODE_H = @QKEYCODE_H@
QT_INCLUDES = @QT_INCLUDES@
QT_LDFLAGS = @QT_LDFLAGS@
RANLIB = @RANLIB@
TOPSUBDIRS = @TOPSUBDIRS@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XPMINC = @XPMINC@
XPMLIB = @XPMLIB@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_INCLUDES = @X_INCLUDES@
X_LDFLAGS = @X_LDFLAGS@
all_includes = @all_includes@
all_libraries = @all_libraries@
install_root = @install_root@
kde_appsdir = @kde_appsdir@
kde_bindir = @kde_bindir@
kde_cgidir = @kde_cgidir@
kde_confdir = @kde_confdir@
kde_datadir = @kde_datadir@
kde_htmldir = @kde_htmldir@
kde_icondir = @kde_icondir@
kde_includes = @kde_includes@
kde_libraries = @kde_libraries@
kde_locale = @kde_locale@
kde_mimedir = @kde_mimedir@
kde_minidir = @kde_minidir@
kde_partsdir = @kde_partsdir@
kde_sounddir = @kde_sounddir@
kde_toolbardir = @kde_toolbardir@
kde_wallpaperdir = @kde_wallpaperdir@
qt_includes = @qt_includes@
qt_libraries = @qt_libraries@
topdir = @topdir@
x_includes = @x_includes@
x_libraries = @x_libraries@
INCLUDES = $(QT_INCLUDES) $(X_INCLUDES)
lib_LTLIBRARIES = libjscript.la
YACC = bison -y
LEX = flex
YFLAGS = -d -p yyjscript
SOMAJOR = 2
SOMINOR = 0
####### Files
libjscript_la_SOURCES = t1.c t2.c cpp2bison.cpp jstree.cpp jsexec.cpp builtin.cpp
libjscript_la_LDFLAGS = -version-info $(SOMAJOR):$(SOMINOR)
libjscript_la_LIBADD =
include_HEADERS = bison2cpp.h jstree.h jsexec.h jserror.h builtin.h
noinst_HEADERS = t1.h
EXTRA_DIST = t1.y t2.l
mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libjscript_la_DEPENDENCIES =
libjscript_la_OBJECTS = t1.lo t2.lo cpp2bison.lo jstree.lo jsexec.lo \
builtin.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
DIST_COMMON = README Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
SOURCES = $(libjscript_la_SOURCES)
OBJECTS = $(libjscript_la_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cpp .lo .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps jscript/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libLTLIBRARIES:
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
distclean-libLTLIBRARIES:
maintainer-clean-libLTLIBRARIES:
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
list='$(lib_LTLIBRARIES)'; for p in $$list; do \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
done
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
.c.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.s.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
.S.lo:
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
maintainer-clean-libtool:
libjscript.la: $(libjscript_la_OBJECTS) $(libjscript_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libjscript_la_LDFLAGS) $(libjscript_la_OBJECTS) $(libjscript_la_LIBADD) $(LIBS)
.cpp.o:
$(CXXCOMPILE) -c $<
.cpp.lo:
$(LTCXXCOMPILE) -c $<
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p"; \
$(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$p; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
list='$(include_HEADERS)'; for p in $$list; do \
rm -f $(DESTDIR)$(includedir)/$$p; \
done
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = jscript
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
install-exec: install-exec-am
install-data-am: install-includeHEADERS
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES uninstall-includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-tags \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \
clean-generic mostlyclean-am
clean: clean-am
rm -f makedepend
distclean-am: distclean-libLTLIBRARIES distclean-compile \
distclean-libtool distclean-tags distclean-generic \
clean-am
-rm -f libtool
distclean: distclean-am
maintainer-clean-am: maintainer-clean-libLTLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \
clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \
uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \
distclean-compile clean-compile maintainer-clean-compile \
mostlyclean-libtool distclean-libtool clean-libtool \
maintainer-clean-libtool uninstall-includeHEADERS \
install-includeHEADERS tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
grammarfiles: t1.y t2.l
$(YACC) $(YFLAGS) t1.y $< && mv y.tab.c t1.c
if test -f y.tab.h; then \
if cmp -s y.tab.h t1.h; then rm -f y.tab.h; \
else mv y.tab.h t1.h; fi \
else :; fi
$(LEX) -Pyyjscript t2.l && mv lex.yyjscript.c t2.c
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
--- NEW FILE: t1.c ---
/* A Bison parser, made from t1.y
by GNU Bison version 1.28 */
#define YYBISON 1 /* Identify Bison output. */
#define yyparse yyjscriptparse
#define yylex yyjscriptlex
#define yyerror yyjscripterror
#define yylval yyjscriptlval
#define yychar yyjscriptchar
#define yydebug yyjscriptdebug
#define yynerrs yyjscriptnerrs
#define FUNCTION 257
#define IF 258
#define ELSE 259
#define IN 260
#define WITH 261
#define WHILE 262
[...1554 lines suppressed...]
}
#line 278 "t1.y"
void yyerror ( char *s ) /* Called by yyparse on error */
{
printf ("ERROR: %s\n", s);
}
void mainParse( const char *_code )
{
initFlex( _code );
yyparse();
}
--- NEW FILE: jserror.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef JSERROR_H
#define JSERROR_H
#define ERROR_JSNone 0
#define ERROR_JSInternal 1
#define ERROR_JSNotALeftValue 2
#define ERROR_JSNotARightValue 3
#define ERROR_JSUnknownIdentifier 4
#define ERROR_JSOperatorNotAllowed 5
#define ERROR_JSNotAFunction 6
#define ERROR_JSNoInstance 7
#define ERROR_JSIndexOutOfRange 8
#define ERROR_JSNotAInteger 9
#endif
--- NEW FILE: t2.c ---
#define yy_create_buffer yyjscript_create_buffer
#define yy_delete_buffer yyjscript_delete_buffer
#define yy_scan_buffer yyjscript_scan_buffer
#define yy_scan_string yyjscript_scan_string
#define yy_scan_bytes yyjscript_scan_bytes
#define yy_flex_debug yyjscript_flex_debug
#define yy_init_buffer yyjscript_init_buffer
#define yy_flush_buffer yyjscript_flush_buffer
#define yy_load_buffer_state yyjscript_load_buffer_state
#define yy_switch_to_buffer yyjscript_switch_to_buffer
#define yyin yyjscriptin
#define yyleng yyjscriptleng
#define yylex yyjscriptlex
#define yyout yyjscriptout
#define yyrestart yyjscriptrestart
#define yytext yyjscripttext
#define yywrap yyjscriptwrap
/* A lexical scanner generated by flex */
[...1822 lines suppressed...]
*d++ = '\r';
else if ( *s == 't' )
*d++ = '\t';
s++;
}
}
*d = 0;
return p;
}
int yywrap()
{
yy_delete_buffer( YY_CURRENT_BUFFER );
return 1;
}
void initFlex( const char *_code )
{
yy_switch_to_buffer( yy_scan_string( _code ) );
}
--- NEW FILE: Makefile.new ---
include ../makeinclude
YACC = bison -y
YFLAGS = -d -p yyjscript
LEX = flex
SOURCES = t1.c t2.c cpp2bison.cpp jstree.cpp jsexec.cpp builtin.cpp
OBJS = t1.o t2.o cpp2bison.o jstree.o jsexec.o builtin.o
INCLUDES=-I../src/fltk
OBJECTS = $(CPPFILES:.cxx=.o) $(CFILES:.c=.o)
all: grammarfiles $(OBJS)
grammarfiles: t1.y t2.l
$(YACC) $(YFLAGS) t1.y $< && mv y.tab.c t1.c
if test -f y.tab.h; then \
if cmp -s y.tab.h t1.h; then rm -f y.tab.h; \
else mv y.tab.h t1.h; fi \
else :; fi
$(LEX) -Pyyjscript t2.l && mv lex.yyjscript.c t2.c
.SUFFIXES: .cpp .h .o
.cpp.o :
$(CXX) $(INCLUDES) -I.. $(CXXFLAGS) -c -o $@ $<
.c.o :
$(CC) -I.. $(INCLUDES) $(CFLAGS) -c -o $@ $<
clean :
-@ rm -f *.o *.do $(DSONAME) $(LIBRARY) $(CLEAN) core *~ ../include/*~ makedepend cmap
--- NEW FILE: builtin.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef BUILTIN_H
#define BUILTIN_H
#include "jstree.h"
void initBuiltin( JSScope *_scope );
class JSPrintFunction : public JSFunction
{
public:
JSPrintFunction();
~JSPrintFunction() { }
virtual int rightValue( JSScopeStack* _s, JSValue *rv, JSParameterListObject *_param );
};
#endif
--- NEW FILE: Makefile.am ---
# This file is part of the KDE libraries
# Copyright (C) 1997 Torben Weis (weis at kde.org)
# (C) 1997 Stephan Kulow (coolo at kde.org)
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
####### General stuff
INCLUDES = $(QT_INCLUDES) $(X_INCLUDES)
lib_LTLIBRARIES = libjscript.la
YACC = bison -y
LEX = flex
YFLAGS = -d -p yyjscript
SOMAJOR = 2
SOMINOR = 0
####### Files
libjscript_la_SOURCES = t1.c t2.c cpp2bison.cpp jstree.cpp jsexec.cpp builtin.cpp
libjscript_la_LDFLAGS = -version-info $(SOMAJOR):$(SOMINOR)
libjscript_la_LIBADD =
include_HEADERS = bison2cpp.h jstree.h jsexec.h jserror.h builtin.h
noinst_HEADERS = t1.h
grammarfiles: t1.y t2.l
$(YACC) $(YFLAGS) t1.y $< && mv y.tab.c t1.c
if test -f y.tab.h; then \
if cmp -s y.tab.h t1.h; then rm -f y.tab.h; \
else mv y.tab.h t1.h; fi \
else :; fi
$(LEX) -Pyyjscript t2.l && mv lex.yyjscript.c t2.c
EXTRA_DIST = t1.y t2.l
--- NEW FILE: jstree.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "jstree.h"
#include "jsexec.h"
#include "jserror.h"
#include "bison2cpp.h"
#include <stdio.h>
/**********************************************************
*
* JSNode
*
*********************************************************/
JSNode::JSNode()
{
}
int JSNode::leftValue( JSScopeStack *, JSValue * )
{
return ERROR_JSNotALeftValue;
}
int JSNode::rightValue( JSScopeStack *, JSValue * )
{
return ERROR_JSNotARightValue;
}
/**********************************************************
*
* JSInteger
*
*********************************************************/
JSInteger::JSInteger( int _value ) : JSNode()
{
value = _value;
}
int JSInteger::rightValue( JSScopeStack * , JSValue *_rv )
{
_rv->setObject( new JSIntegerObject( value ) );
_rv->setAutoDelete( TRUE );
_rv->setLeftValue( FALSE );
return 0;
}
/**********************************************************
*
* JSBool
*
*********************************************************/
JSBool::JSBool( bool _value ) : JSNode()
{
value = _value;
}
int JSBool::rightValue( JSScopeStack *, JSValue *_rv )
{
_rv->setObject( new JSBoolObject( value ) );
_rv->setAutoDelete( TRUE );
_rv->setLeftValue( FALSE );
return 0;
}
/**********************************************************
*
* JSFloat
*
*********************************************************/
JSFloat::JSFloat( double _value ) : JSNode()
{
value = _value;
}
int JSFloat::rightValue( JSScopeStack *, JSValue *_rv )
{
_rv->setObject( new JSFloatObject( value ) );
_rv->setAutoDelete( TRUE );
_rv->setLeftValue( FALSE );
return 0;
}
/**********************************************************
*
* JSBinaryOperator
*
*********************************************************/
JSBinaryOperator::JSBinaryOperator( int _op, JSNode *_left, JSNode *_right ) : JSNode()
{
op = _op;
leftNode = _left;
rightNode = _right;
}
int JSBinaryOperator::rightValue( JSScopeStack *_scope, JSValue *_val )
{
int ret = 0;
if ( !leftNode || !rightNode )
return ERROR_JSInternal;
JSValue *lv = new JSValue();
ret = leftNode->rightValue( _scope, lv );
if ( ret )
{
delete lv;
return ret;
}
JSValue* rv = new JSValue();
ret = rightNode->rightValue( _scope, rv );
if ( ret )
{
delete lv;
delete rv;
return ret;
}
// Is at least one of the operands null ?
if ( lv->getObject()->isA() == TYPE_JSObject || rv->getObject()->isA() == TYPE_JSObject )
{
_val->setLeftValue( FALSE );
_val->setAutoDelete( TRUE );
JSObject *obj;
switch ( op )
{
case OP_EQ:
obj = new JSBoolObject( lv->getObject()->isA() == rv->getObject()->isA() );
break;
case OP_NEQ:
obj = new JSBoolObject( lv->getObject()->isA() != rv->getObject()->isA() );
break;
default:
delete lv;
delete rv;
return ERROR_JSOperatorNotAllowed;
}
_val->setObject( obj );
delete lv;
delete rv;
return ret;
}
switch ( lv->getObject()->isA() )
{
case TYPE_JSIntegerObject:
{
JSIntegerObject *i1 = (JSIntegerObject*) lv->getObject();
// TODO: Convert rv to integer;
JSIntegerObject *i2 = (JSIntegerObject*) rv->getObject();
_val->setLeftValue( FALSE );
_val->setAutoDelete( TRUE );
JSObject *obj;
switch ( op )
{
case OP_ADD:
obj = new JSIntegerObject( i1->getValue() + i2->getValue() );
break;
case OP_MUL:
obj = new JSIntegerObject( i1->getValue() * i2->getValue() );
break;
case OP_DIV:
obj = new JSIntegerObject( i1->getValue() / i2->getValue() );
break;
case OP_SUB:
obj = new JSIntegerObject( i1->getValue() - i2->getValue() );
break;
case OP_EQ:
obj = new JSBoolObject( i1->getValue() == i2->getValue() );
break;
case OP_NEQ:
obj = new JSBoolObject( i1->getValue() != i2->getValue() );
break;
case OP_LEQ:
obj = new JSBoolObject( i1->getValue() <= i2->getValue() );
break;
case OP_GEQ:
obj = new JSBoolObject( i1->getValue() >= i2->getValue() );
break;
case OP_LT:
obj = new JSBoolObject( i1->getValue() < i2->getValue() );
break;
case OP_GT:
obj = new JSBoolObject( i1->getValue() > i2->getValue() );
break;
case OP_SL:
obj = new JSIntegerObject( i1->getValue() << i2->getValue() );
break;
case OP_SR:
obj = new JSIntegerObject( i1->getValue() >> i2->getValue() );
break;
case OP_BAND:
obj = new JSIntegerObject( i1->getValue() & i2->getValue() );
break;
case OP_BOR:
obj = new JSIntegerObject( i1->getValue() | i2->getValue() );
break;
case OP_BXOR:
obj = new JSIntegerObject( i1->getValue() ^ i2->getValue() );
break;
default:
delete lv;
delete rv;
return ERROR_JSOperatorNotAllowed;
}
_val->setObject( obj );
}
break;
case TYPE_JSFloatObject:
{
JSFloatObject *i1 = (JSFloatObject*) lv->getObject();
// TODO: Convert rv to float;
JSFloatObject *i2 = (JSFloatObject*) rv->getObject();
_val->setLeftValue( FALSE );
_val->setAutoDelete( TRUE );
JSObject *obj;
switch ( op )
{
case OP_ADD:
obj = new JSFloatObject( i1->getValue() + i2->getValue() );
break;
case OP_MUL:
obj = new JSFloatObject( i1->getValue() * i2->getValue() );
break;
case OP_DIV:
obj = new JSFloatObject( i1->getValue() / i2->getValue() );
break;
case OP_SUB:
obj = new JSFloatObject( i1->getValue() - i2->getValue() );
break;
case OP_EQ:
obj = new JSBoolObject( i1->getValue() == i2->getValue() );
break;
case OP_NEQ:
obj = new JSBoolObject( i1->getValue() != i2->getValue() );
break;
case OP_LEQ:
obj = new JSBoolObject( i1->getValue() <= i2->getValue() );
break;
case OP_GEQ:
obj = new JSBoolObject( i1->getValue() >= i2->getValue() );
break;
case OP_LT:
obj = new JSBoolObject( i1->getValue() < i2->getValue() );
break;
case OP_GT:
obj = new JSBoolObject( i1->getValue() > i2->getValue() );
break;
default:
delete lv;
delete rv;
return ERROR_JSOperatorNotAllowed;
}
_val->setObject( obj );
}
break;
case TYPE_JSStringObject:
{
JSStringObject *s1 = (JSStringObject*) lv->getObject();
// TODO: Convert rv to integer;
JSStringObject *s2 = (JSStringObject*) rv->getObject();
_val->setLeftValue( FALSE );
switch ( op )
{
case OP_ADD:
{
_val->setAutoDelete( TRUE );
JSStringObject *obj = new JSStringObject( QString(s1->getQString() + s2->getQString()) );
_val->setObject( obj );
}
break;
case OP_EQ:
{
_val->setAutoDelete( TRUE );
JSBoolObject *obj = new JSBoolObject( strcmp( s1->getString(), s2->getString() ) == 0L );
_val->setObject( obj );
}
break;
case OP_NEQ:
{
_val->setAutoDelete( TRUE );
JSBoolObject *obj = new JSBoolObject( strcmp( s1->getString(), s2->getString() ) != 0L );
_val->setObject( obj );
}
break;
default:
delete lv;
delete rv;
return ERROR_JSOperatorNotAllowed;
}
}
break;
case TYPE_JSBoolObject:
{
JSBoolObject *s1 = (JSBoolObject*) lv->getObject();
// TODO: Convert rv to integer;
JSBoolObject *s2 = (JSBoolObject*) rv->getObject();
_val->setLeftValue( FALSE );
_val->setAutoDelete( TRUE );
JSObject *obj;
switch ( op )
{
case OP_EQ:
obj = new JSBoolObject( s1->getValue() == s2->getValue() );
break;
case OP_NEQ:
obj = new JSBoolObject( s1->getValue() != s2->getValue() );
break;
case OP_AND:
obj = new JSBoolObject( s1->getValue() && s2->getValue() );
break;
case OP_OR:
obj = new JSBoolObject( s1->getValue() || s2->getValue() );
break;
default:
delete lv;
delete rv;
return ERROR_JSOperatorNotAllowed;
}
_val->setObject( obj );
}
break;
default:
delete lv;
delete rv;
return ERROR_JSOperatorNotAllowed;
}
delete lv;
delete rv;
return ret;
}
/**********************************************************
*
* JSAssignment
*
*********************************************************/
JSAssignment::JSAssignment( int _op, JSNode *_left, JSNode *_right ) :
JSBinaryOperator( _op, _left, _right )
{
}
int JSAssignment::rightValue( JSScopeStack *_scopes, JSValue * )
{
int ret = 0;
if ( !leftNode || !rightNode )
return ERROR_JSInternal;
JSValue *lv = new JSValue();
ret = leftNode->leftValue( _scopes, lv );
if ( ret )
{
delete lv;
return ret;
}
JSValue* rv = new JSValue();
ret = rightNode->rightValue( _scopes, rv );
if ( ret )
{
delete lv;
delete rv;
return ret;
}
if ( !lv->isLeftValue() )
{
delete lv;
delete rv;
return ERROR_JSNotALeftValue;
}
// We can only assign to JSVariableOvbjects.
if ( lv->getObject()->inherits( TYPE_JSVariableObject ) )
{
JSVariableObject *var = (JSVariableObject*)(lv->getObject() );
if ( var->isConst() )
{
delete lv;
delete rv;
return ERROR_JSNotALeftValue;
}
var->clear();
if ( rv->isAutoDelete() )
{
// 'rv' should not delete the object since we reuse it in 'var'
rv->setAutoDelete( FALSE );
var->setValue( rv->getObject() );
}
else
var->setValue( rv->getObject()->copy() );
}
else
{
delete lv;
delete rv;
return ERROR_JSInternal;
}
delete lv;
delete rv;
return ret;
}
/**********************************************************
*
* JSIdentifier
*
*********************************************************/
JSIdentifier::JSIdentifier( const char *_name )
{
name = _name;
name.detach();
}
int JSIdentifier::rightValue( JSScopeStack *_scopes, JSValue *_rv )
{
// int ret = 0;
// Is it a function ?
JSFunctionObject* func;
func = _scopes->findFunction( name );
if ( func )
{
_rv->setObject( func );
_rv->setAutoDelete( FALSE );
_rv->setLeftValue( FALSE );
return 0;
}
// Is it a variable ?
JSVariableObject* var;
var = _scopes->findVariable( name, FALSE );
if ( !var )
return ERROR_JSUnknownIdentifier;
_rv->setObject( var->getValue() );
if ( var->isDynamic() )
_rv->setAutoDelete( TRUE );
else
_rv->setAutoDelete( FALSE );
_rv->setLeftValue( FALSE );
return 0;
}
int JSIdentifier::leftValue( JSScopeStack *_scopes, JSValue *_lv )
{
JSVariableObject* var;
// int ret = 0;
var = _scopes->findVariable( name, TRUE );
if ( !var )
{
JSScope* scope = _scopes->topScope();
scope->insertObject( var = new JSVariableObject() );
var->setName( name );
}
_lv->setObject( var );
_lv->setAutoDelete( FALSE );
_lv->setLeftValue( TRUE );
return 0;
}
/**********************************************************
*
* JSStatement
*
*********************************************************/
JSStatement::JSStatement( JSNode *_code, JSNode *_next_code ) : JSNode()
{
code = _code;
nextCode = _next_code;
}
int JSStatement::rightValue( JSScopeStack *_scopes, JSValue *_rv )
{
int ret = 0;
if ( code )
{
ret = code->rightValue( _scopes, _rv );
if ( ret )
return ret;
}
if ( nextCode )
ret = nextCode->rightValue( _scopes, _rv );
return ret;
}
/**********************************************************
*
* JSFunction
*
*********************************************************/
JSFunction::JSFunction( const char *_name, JSParameter* _param, JSNode *_code ) : JSNode()
{
parameters = _param;
code = _code;
name = _name;
}
int JSFunction::rightValue( JSScopeStack* , JSValue *rv )
{
// This is NOT a call to this function. The programmer just wants a
// reference to this function ( read: pointer ).
JSFunctionObject *func = new JSFunctionObject( this );
rv->setObject( func );
rv->setAutoDelete( TRUE );
rv->setLeftValue( FALSE );
return 0;
}
int JSFunction::rightValue( JSScopeStack *_scopes, JSValue *_rv, JSParameterListObject* )
{
// TODO: Scope change and fill parameters
return code->rightValue( _scopes, _rv );
}
/**********************************************************
*
* JSParameter
*
*********************************************************/
JSParameter::JSParameter( const char *_name, JSParameter *_next )
{
name = _name;
nextParameter = _next;
}
/**********************************************************
*
* JSFunctionCall
*
*********************************************************/
JSFunctionCall::JSFunctionCall( JSNode *_function, JSArgument *_arguments )
{
function = _function;
arguments = _arguments;
}
int JSFunctionCall::rightValue( JSScopeStack* _scopes, JSValue *rv )
{
int ret = 0;
JSValue v;
ret = function->rightValue( _scopes, &v );
if ( ret )
return ret;
if ( ! v.getObject()->inherits( TYPE_JSFunctionObject ) )
{
printf("isA=%i\n",v.getObject()->isA());
return ERROR_JSNotAFunction;
}
JSParameterListObject param;
if ( arguments )
{
ret = arguments->rightValue( _scopes, ¶m );
if ( ret )
return ret;
}
JSFunctionObject *func = (JSFunctionObject*)( v.getObject() );
// Add new temporary scope
_scopes->pushScope( new JSScope() );
if ( func->getObject() )
{
// Add obj to scope
_scopes->pushInstanceScope( func->getObject()->getScope() );
}
ret = func->getFunction()->rightValue( _scopes, rv, ¶m );
if ( func->getObject() )
{
// Remove obj from scope
_scopes->popInstanceScope();
}
// Remove temporary scope
_scopes->popScope();
return ret;
}
/**********************************************************
*
* JSConstructorCall
*
*********************************************************/
JSConstructorCall::JSConstructorCall( JSNode *_function, JSArgument *_arguments )
{
function = _function;
arguments = _arguments;
}
int JSConstructorCall::rightValue( JSScopeStack* _scopes, JSValue *rv )
{
int ret = 0;
JSValue v;
ret = function->rightValue( _scopes, &v );
if ( ret )
return ret;
if ( ! v.getObject()->inherits( TYPE_JSFunctionObject ) )
return ERROR_JSNotAFunction;
JSParameterListObject param;
if ( arguments )
{
ret = arguments->rightValue( _scopes, ¶m );
if ( ret )
return ret;
}
JSFunctionObject *func = (JSFunctionObject*)( v.getObject() );
JSUserDefinedObject *obj = new JSUserDefinedObject();
// Add obj to scope
_scopes->pushInstanceScope( obj->getScope() );
// Add new temporary scope
_scopes->pushScope( new JSScope() );
ret = func->getFunction()->rightValue( _scopes, &v, ¶m );
if ( ret )
{
delete obj;
return ret;
}
// Remove temporary scope
_scopes->popScope();
// Remove obj from scope
_scopes->popInstanceScope();
rv->setObject( obj );
rv->setAutoDelete( TRUE );
rv->setLeftValue( FALSE );
return ret;
}
/**********************************************************
*
* JSArgument
*
*********************************************************/
JSArgument::JSArgument( JSNode *_code, JSArgument *_next ) : JSNode()
{
code = _code;
nextArgument = _next;
}
int JSArgument::rightValue( JSScopeStack *_scopes, JSParameterListObject *_param )
{
int ret = 0;
JSValue *v = new JSValue();
ret = code->rightValue( _scopes, v );
if ( ret )
return ret;
_param->appendValue( v );
if ( nextArgument )
ret = nextArgument->rightValue( _scopes, _param );
return ret;
}
/**********************************************************
*
* JSThis
*
*********************************************************/
JSThis::JSThis() : JSNode()
{
}
int JSThis::rightValue( JSScopeStack* _scopes, JSValue *rv )
{
int ret = 0;
JSInstanceScope *s = _scopes->topInstanceScope();
if ( s == 0L )
return ERROR_JSNoInstance;
rv->setObject( s->getObject() );
rv->setAutoDelete( FALSE );
rv->setLeftValue( FALSE );
return ret;
}
/**********************************************************
*
* JSMember
*
*********************************************************/
JSMember::JSMember( JSNode *_obj, const char *_name )
{
object = _obj;
name = _name;
}
JSMember::~JSMember()
{
if ( object )
delete object;
}
int JSMember::rightValue( JSScopeStack* _s, JSValue *rv )
{
int ret = 0;
JSValue v;
ret = object->rightValue( _s, &v );
if ( ret )
return ret;
if ( ! v.getObject()->inherits( TYPE_JSUserDefinedObject ) )
return ERROR_JSUnknownIdentifier;
JSInstanceScope *s = ((JSUserDefinedObject*)v.getObject())->getScope();
// Test for variables.
// Mention that variables may be function pointers, too.
JSVariableObject* var = s->findVariable( name );
if ( var )
{
// Is it a reference to a function ?
if ( var->getValue()->inherits( TYPE_JSFunctionObject ) )
{
JSFunctionObject *f = (JSFunctionObject*)( var->getValue()->copy() );
f->setObject( (JSUserDefinedObject*)(v.getObject()) );
rv->setObject( f );
rv->setAutoDelete( TRUE );
rv->setLeftValue( FALSE );
return ret;
}
// It is a usual variable
rv->setObject( var->getValue() );
if ( var->isDynamic() )
rv->setAutoDelete( TRUE );
else
rv->setAutoDelete( FALSE );
rv->setLeftValue( FALSE );
return ret;
}
// Test for hard coded functions
JSFunctionObject* func = s->findFunction( name );
if ( !func )
return ERROR_JSUnknownIdentifier;
rv->setObject( func );
rv->setAutoDelete( FALSE );
rv->setLeftValue( FALSE );
return ret;
}
int JSMember::leftValue( JSScopeStack* _s, JSValue *rv )
{
int ret = 0;
JSValue v;
ret = object->rightValue( _s, &v );
if ( ret )
return ret;
if ( ! v.getObject()->inherits( TYPE_JSUserDefinedObject ) )
return ERROR_JSUnknownIdentifier;
JSInstanceScope *s = ((JSUserDefinedObject*)v.getObject())->getScope();
// Test for variables.
// Mention that variables may be function pointers, too.
JSVariableObject* var = s->findVariable( name );
if ( var )
{
rv->setObject( var );
rv->setAutoDelete( FALSE );
rv->setLeftValue( TRUE );
return ret;
}
// Hard coded functions can not be overwritten
JSFunctionObject* func = s->findFunction( name );
if ( func )
{
rv->setObject( func );
rv->setAutoDelete( FALSE );
rv->setLeftValue( FALSE );
return ERROR_JSNotALeftValue;
}
// Insert new variable
s->insertObject( var = new JSVariableObject() );
var->setName( name );
rv->setObject( var );
rv->setAutoDelete( FALSE );
rv->setLeftValue( TRUE );
return ret;
}
/**********************************************************
*
* JSString
*
*********************************************************/
JSString::JSString( const char *_string )
{
object = new JSStringObject( _string );
}
JSString::~JSString()
{
delete object;
}
int JSString::rightValue( JSScopeStack* , JSValue *rv )
{
int ret = 0;
rv->setObject( object );
rv->setLeftValue( FALSE );
rv->setAutoDelete( FALSE );
return ret;
}
/**********************************************************
*
* JSNull
*
*********************************************************/
JSNull::JSNull()
{
object = new JSObject();
}
JSNull::~JSNull()
{
delete object;
}
int JSNull::rightValue( JSScopeStack*, JSValue *rv )
{
int ret = 0;
rv->setObject( object );
rv->setLeftValue( FALSE );
rv->setAutoDelete( FALSE );
return ret;
}
/**********************************************************
*
* JSArrayAccess
*
*********************************************************/
JSArrayAccess::JSArrayAccess( JSNode *_array, JSNode *_index )
{
array = _array;
index = _index;
}
int JSArrayAccess::rightValue( JSScopeStack* _scopes, JSValue *rv )
{
int ret = 0;
JSValue v;
ret = array->rightValue( _scopes, &v );
if ( ret )
return ret;
if ( ! v.getObject()->inherits( TYPE_JSAbstractArrayObject ) )
{
printf("isA=%i\n",v.getObject()->isA());
return ERROR_JSNotAFunction;
}
JSAbstractArrayObject *a = (JSAbstractArrayObject*)( v.getObject() );
JSValue iv;
ret = index->rightValue( _scopes, &iv );
if ( ret )
return ret;
ret = a->rightValue( iv.getObject(), rv );
return ret;
}
int JSArrayAccess::leftValue( JSScopeStack* _scopes, JSValue *rv )
{
int ret = 0;
JSValue v;
ret = array->rightValue( _scopes, &v );
if ( ret )
return ret;
if ( ! v.getObject()->inherits( TYPE_JSAbstractArrayObject ) )
{
printf("isA=%i\n",v.getObject()->isA());
return ERROR_JSNotAFunction;
}
JSAbstractArrayObject *a = (JSAbstractArrayObject*)( v.getObject() );
JSValue iv;
ret = index->rightValue( _scopes, &iv );
if ( ret )
return ret;
ret = a->leftValue( iv.getObject(), rv );
return ret;
}
--- NEW FILE: t1.h ---
typedef union
{
int vali;
double vald;
char *name;
void *ptr;
} YYSTYPE;
#define FUNCTION 257
#define IF 258
#define ELSE 259
#define IN 260
#define WITH 261
#define WHILE 262
#define FOR 263
#define SHIFT_LEFT 264
#define SHIFT_RIGHT 265
#define EQ 266
#define NEQ 267
#define OR 268
#define AND 269
#define THIS 270
#define B_NULL 271
#define FLOAT 272
#define B_TRUE 273
#define B_FALSE 274
#define NEW 275
#define DELETE 276
#define BREAK 277
#define CONTINUE 278
#define RETURN 279
#define VAR 280
#define PP 281
#define MM 282
#define STRING 283
#define LEQ 284
#define GEQ 285
#define MAS 286
#define DAS 287
#define AAS 288
#define SAS 289
#define PAS 290
#define RAS 291
#define BAAS 292
#define BOAS 293
#define NUM 294
#define IDENTIFIER 295
extern YYSTYPE yyjscriptlval;
--- NEW FILE: README ---
KDE JavaScript library
Version 0.1 alpha
This is the very first version of an JavaScript interpreter
for the KDE project. You need to
make
make install
before you can compile the latest khtmlwidget.
Torben Weis, weis at stud.uni-frankfurt.de, weis at kde.org
Last Change:
Torben Weis
25.6.97
--- NEW FILE: builtin.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "builtin.h"
#include <stdlib.h>
#include <stdio.h>
JSPrintFunction *jsPrint = 0L;
void initBuiltin( JSScope *_scope )
{
if ( jsPrint == 0L )
jsPrint = new JSPrintFunction();
_scope->insertObject( new JSFunctionObject( jsPrint ) );
}
JSPrintFunction::JSPrintFunction() : JSFunction( "print", 0L, 0L )
{
}
int JSPrintFunction::rightValue( JSScopeStack* , JSValue *rv, JSParameterListObject *_param )
{
// int ret = 0;
if ( _param )
{
JSValue *v;
for ( v = _param->firstValue(); v != 0L; v = _param->nextValue() )
{
if ( v->getObject()->isA() == TYPE_JSIntegerObject )
printf( "%i ", ((JSIntegerObject*)(v->getObject()))->getValue() );
else if ( v->getObject()->isA() == TYPE_JSStringObject )
printf( "%s ", ((JSStringObject*)(v->getObject()))->getString() );
else if ( v->getObject()->isA() == TYPE_JSBoolObject )
{
if ( ((JSBoolObject*)(v->getObject()))->getValue() )
printf( "TRUE " );
else
printf( "FALSE " );
}
else if ( v->getObject()->isA() == TYPE_JSFloatObject )
printf( "%f ", ((JSFloatObject*)(v->getObject()))->getValue() );
}
}
rv->setObject( new JSObject() );
rv->setAutoDelete( TRUE );
rv->setLeftValue( FALSE );
return 0;
}
--- NEW FILE: jsexec.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef JSEXEC_H
#define JSEXEC_H
class JSObject;
class JSScope;
class JSVariableObject;
class JSFunctionObject;
class JSUserDefinedObject;
class JSInstanceScope;
#include <qlist.h>
#include <qstack.h>
#include "jstree.h"
#include "jserror.h"
#define TYPE_JSObject 1
#define TYPE_JSIntegerObject 2
#define TYPE_JSStringObject 3
#define TYPE_JSVariableObject 4
#define TYPE_JSParameterListObject 5
#define TYPE_JSFunctionObject 6
#define TYPE_JSUserDefinedObject 7
#define TYPE_JSScope 8
#define TYPE_JSInstanceScope 9
#define TYPE_JSBoolObject 10
#define TYPE_JSFloatObject 11
#define TYPE_JSAbstractArrayObject 12
typedef QList<JSNode> JSCode;
int execJavaScript( JSCode *_code, JSScope *_global_scope, JSInstanceScope *_instanceScope );
int parseJavaScript( const char *_script, JSCode* _code, JSScope* _global );
JSScope* makeGlobalScope();
class JSValue
{
public:
JSValue();
virtual ~JSValue();
bool isLeftValue() { return bLeftValue; }
void setLeftValue( bool _b ) { bLeftValue = _b; }
JSObject *getObject() { return object; }
void setObject( JSObject *_o );
void setAutoDelete( bool _b ) { bAutoDelete = _b; }
bool isAutoDelete() { return bAutoDelete; }
protected:
JSObject *object;
bool bAutoDelete;
bool bLeftValue;
};
class JSObject
{
public:
JSObject() { }
virtual ~JSObject() { }
virtual int isA() { return TYPE_JSObject; }
virtual bool inherits( int _type ) { return ( _type == TYPE_JSObject ); }
virtual JSObject* copy() { return new JSObject(); }
virtual void release() { delete this; }
};
/**********************************************************
*
* JSScope
*
*********************************************************/
class JSScope
{
public:
JSScope();
virtual ~JSScope() { }
virtual int isA() { return TYPE_JSScope; }
void insertObject( JSObject* _obj );
JSVariableObject* findVariable( const char *_name );
JSFunctionObject* findFunction( const char *_name );
QList<JSObject>* getObjectList() { return &objectList; }
protected:
QList<JSObject> objectList;
};
/**********************************************************
*
* JSInstanceScope
*
*********************************************************/
class JSInstanceScope : public JSScope
{
public:
JSInstanceScope() { }
virtual ~JSInstanceScope() { }
virtual int isA() { return TYPE_JSInstanceScope; }
void setObject( JSUserDefinedObject* _obj ) { object = _obj; }
JSUserDefinedObject* getObject() { return object; }
protected:
JSUserDefinedObject *object;
};
/**********************************************************
*
* JSScopeStack
*
*********************************************************/
class JSScopeStack
{
public:
JSScopeStack( JSScope *_globalScope, JSInstanceScope *_instanceScope = 0L );
virtual ~JSScopeStack();
/**
* @param _top_only causes only the upper most scope to be searched.
*
* @see JSIdentifier::leftValue
*/
JSVariableObject* findVariable( const char *_name, bool _top_only = FALSE );
JSFunctionObject* findFunction( const char *_name );
void pushScope( JSScope* _scope );
void popScope();
JSScope* topScope();
void pushInstanceScope( JSInstanceScope* _scope );
void popInstanceScope();
JSInstanceScope* topInstanceScope();
protected:
QList<JSScope> scopeList;
QStack<JSInstanceScope> instanceScopeStack;
/**
* If this pointer is NOT 0L, then this scope may not be deleted. Mention that all other
* scopes are deleted if @ref #scopeList is deleted.
*/
JSScope* globalScope;
};
class JSUserDefinedObject : public JSObject
{
public:
JSUserDefinedObject();
virtual ~JSUserDefinedObject() { }
virtual int isA() { return TYPE_JSUserDefinedObject; }
virtual bool inherits( int _type )
{ if ( _type == TYPE_JSUserDefinedObject ) return TRUE; else return JSObject::inherits( _type ); }
virtual JSObject* copy() { lock++; return this; }
virtual void release() { if ( lock == 1 ) delete this; else lock--; }
JSInstanceScope* getScope() { return &scope; }
protected:
JSInstanceScope scope;
/**
* Amount of references hold to this object.
*
* @see copy
* @see release
*/
int lock;
};
/**
* @short Abstract class for Arrays.
*
* This class is only an abstract class. If your object is going to accept the "ident[ index ]"
* Operator then you have to derive from this class.
*
* @see JSAbstractArrayAccess
*/
class JSAbstractArrayObject : public JSUserDefinedObject
{
public:
JSAbstractArrayObject() { }
virtual ~JSAbstractArrayObject() { }
virtual int isA() { return TYPE_JSAbstractArrayObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSAbstractArrayObject ) return TRUE;
else return JSUserDefinedObject::inherits( _type ); }
virtual int rightValue( JSObject *, JSValue * ) { return ERROR_JSNotARightValue; }
virtual int leftValue( JSObject *, JSValue * ) { return ERROR_JSNotALeftValue; }
};
class JSStringObject : public JSUserDefinedObject
{
public:
JSStringObject( const char *_string );
virtual ~JSStringObject() { }
virtual int isA() { return TYPE_JSStringObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSStringObject ) return TRUE;
else return JSUserDefinedObject::inherits( _type ); }
const char* getString() { return string.data(); }
QString& getQString() { return string; }
protected:
QString string;
};
class JSParameterListObject : public JSObject
{
public:
JSParameterListObject();
virtual ~JSParameterListObject() { }
virtual int isA() { return TYPE_JSParameterListObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSParameterListObject ) return TRUE;
else return JSObject::inherits( _type ); }
void appendValue( JSValue* _val ) { parameterValues.append( _val ); }
JSValue* firstValue() { return parameterValues.first(); }
JSValue* nextValue() { return parameterValues.next(); }
protected:
QList<JSValue> parameterValues;
};
class JSFunctionObject : public JSObject
{
public:
JSFunctionObject( JSFunction *_func );
virtual ~JSFunctionObject() { }
virtual int isA() { return TYPE_JSFunctionObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSFunctionObject ) return TRUE;
else return JSObject::inherits( _type ); }
virtual JSObject* copy() { return new JSFunctionObject( function ); }
JSFunction* getFunction() { return function; }
const char* getName();
void setObject( JSUserDefinedObject *_obj ) { object = _obj; }
JSUserDefinedObject* getObject() { return object; }
protected:
JSFunction *function;
JSUserDefinedObject *object;
};
class JSVariableObject : public JSObject
{
public:
JSVariableObject();
virtual ~JSVariableObject();
virtual int isA() { return TYPE_JSVariableObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSVariableObject ) return TRUE;
else return JSObject::inherits( _type ); }
virtual void setName( const char *_name ) { if ( bConst ) return; name = _name; }
virtual const char* getName() { return name.data(); }
virtual JSObject *getValue() { return value; }
virtual void setValue( JSObject* _val ) { if ( bConst ) return; value = _val; }
virtual void clear();
/**
* If a variable is const, then you can not assign anything to this variable. Use this to
* implement for example builtin objects like "document".
* This function is for extensions only, it is not called by the interpreter.
*/
void setConst( bool _c ) { bConst = _c; }
bool isConst() { return bConst; }
/**
* Set this flag if the value of this variable changes sometimes ( examples: time, status bar, ... ).
* If this flag is set, the object returned from @ref #getValue will be deleted if not
* further used.
*/
void setDynamic( bool _c ) { bDynamic = _c; }
bool isDynamic() { return bDynamic; }
protected:
QString name;
JSObject *value;
bool bConst;
bool bDynamic;
};
/* class JSStringObject : public JSObject
{
public:
JSStringObject( const char *_str );
virtual ~JSStringObject() { }
virtual int isA() { return TYPE_JSStringObject; }
protected:
QString string;
}; */
class JSIntegerObject : public JSObject
{
public:
JSIntegerObject( int _i );
JSIntegerObject() { }
virtual int isA() { return TYPE_JSIntegerObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSIntegerObject ) return TRUE;
else return JSObject::inherits( _type ); }
virtual JSObject* copy() { return new JSIntegerObject( value ); }
int getValue() { return value; }
protected:
int value;
};
class JSBoolObject : public JSObject
{
public:
JSBoolObject( bool _i );
JSBoolObject() { }
virtual int isA() { return TYPE_JSBoolObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSBoolObject ) return TRUE;
else return JSObject::inherits( _type ); }
virtual JSObject* copy() { return new JSBoolObject( value ); }
bool getValue() { return value; }
protected:
bool value;
};
class JSFloatObject : public JSObject
{
public:
JSFloatObject( double _i );
JSFloatObject() { }
virtual int isA() { return TYPE_JSFloatObject; }
virtual bool inherits( int _type ) { if ( _type == TYPE_JSFloatObject ) return TRUE;
else return JSObject::inherits( _type ); }
virtual JSObject* copy() { return new JSFloatObject( value ); }
double getValue() { return value; }
protected:
double value;
};
#endif
--- NEW FILE: jsexec.cpp ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "jsexec.h"
#include "jstree.h"
#include "builtin.h"
#include <stdio.h>
/**********************************************************
*
* JSIntegerObject
*
*********************************************************/
JSIntegerObject::JSIntegerObject( int _i ) : JSObject()
{
value = _i;
}
/**********************************************************
*
* JSBoolObject
*
*********************************************************/
JSBoolObject::JSBoolObject( bool _i ) : JSObject()
{
value = _i;
}
/**********************************************************
*
* JSFloatObject
*
*********************************************************/
JSFloatObject::JSFloatObject( double _i ) : JSObject()
{
value = _i;
}
/**********************************************************
*
* JSStringObject
*
*********************************************************/
JSStringObject::JSStringObject( const char *_string )
{
string = _string;
}
/**********************************************************
*
* JSVariableObject
*
*********************************************************/
JSVariableObject::JSVariableObject() : JSObject()
{
value = 0L;
bConst = FALSE;
bDynamic = FALSE;
}
void JSVariableObject::clear()
{
if ( bConst )
return;
if ( value )
value->release();
value = 0L;
}
JSVariableObject::~JSVariableObject()
{
if ( value )
delete value;
}
/**********************************************************
*
* JSFunctionObject
*
*********************************************************/
JSFunctionObject::JSFunctionObject( JSFunction * _func ) : JSObject()
{
function = _func;
object = 0L;
}
const char* JSFunctionObject::getName()
{
if ( function )
return function->getName();
else
return 0L;
}
/**********************************************************
*
* JSParameterListObject
*
*********************************************************/
JSParameterListObject::JSParameterListObject() : JSObject()
{
parameterValues.setAutoDelete( TRUE );
}
/**********************************************************
*
* JSUserDefinedObject
*
*********************************************************/
JSUserDefinedObject::JSUserDefinedObject()
{
scope.setObject( this );
lock = 1;
}
/**********************************************************
*
* JSValue
*
*********************************************************/
JSValue::JSValue()
{
object = 0L;
bAutoDelete = FALSE;
bLeftValue = FALSE;
}
JSValue::~JSValue()
{
if ( bAutoDelete && object ) object->release();
}
void JSValue::setObject( JSObject *_o )
{
if ( object && bAutoDelete )
object->release();
object = _o;
}
/**********************************************************
*
* JSScope
*
*********************************************************/
JSScope::JSScope()
{
objectList.setAutoDelete( TRUE );
}
void JSScope::insertObject( JSObject* _obj )
{
objectList.append( _obj );
}
JSVariableObject* JSScope::findVariable( const char *_name )
{
JSObject *obj;
for ( obj = objectList.first(); obj != 0L; obj = objectList.next() )
{
if ( obj->inherits( TYPE_JSVariableObject ) )
{
JSVariableObject *var = (JSVariableObject*) obj;
if ( strcmp( var->getName(), _name ) == 0L )
return var;
}
}
return 0L;
}
JSFunctionObject* JSScope::findFunction( const char *_name )
{
JSObject *obj;
for ( obj = objectList.first(); obj != 0L; obj = objectList.next() )
{
if ( obj->inherits( TYPE_JSFunctionObject ) )
{
JSFunctionObject *func = (JSFunctionObject*) obj;
if ( strcmp( func->getName(), _name ) == 0L )
return func;
}
}
return 0L;
}
/**********************************************************
*
* JSScopeStack
*
*********************************************************/
JSScopeStack::JSScopeStack( JSScope *_globalScope, JSInstanceScope *_instanceScope )
{
globalScope = _globalScope;
scopeList.setAutoDelete( TRUE );
scopeList.append( _globalScope );
instanceScopeStack.setAutoDelete( FALSE );
if ( _instanceScope )
instanceScopeStack.push( _instanceScope );
}
JSScopeStack::~JSScopeStack()
{
// Remove the global scope without deleting it
if ( globalScope )
{
scopeList.setAutoDelete( FALSE );
scopeList.removeRef( globalScope );
scopeList.setAutoDelete( TRUE );
}
}
JSVariableObject* JSScopeStack::findVariable( const char *_name, bool _top_only )
{
JSVariableObject *var;
JSScope *scope;
if ( _top_only )
return scopeList.getLast()->findVariable( _name );
for ( scope = scopeList.last(); scope != 0L; scope = scopeList.prev() )
{
var = scope->findVariable( _name );
if ( var != 0L )
return var;
}
return 0L;
}
JSFunctionObject* JSScopeStack::findFunction( const char *_name )
{
JSFunctionObject *func;
JSScope *scope;
for ( scope = scopeList.last(); scope != 0L; scope = scopeList.prev() )
{
func = scope->findFunction( _name );
if ( func != 0L )
return func;
}
return 0L;
}
void JSScopeStack::pushScope( JSScope* _scope )
{
scopeList.append( _scope );
}
void JSScopeStack::popScope()
{
JSScope *s = scopeList.getLast();
if ( s )
scopeList.removeRef( s );
}
JSScope* JSScopeStack::topScope()
{
return scopeList.getLast();
}
void JSScopeStack::pushInstanceScope( JSInstanceScope* _scope )
{
instanceScopeStack.push( _scope );
}
void JSScopeStack::popInstanceScope()
{
instanceScopeStack.pop();
}
JSInstanceScope* JSScopeStack::topInstanceScope()
{
return instanceScopeStack.top();
}
/**********************************************************
*
* execJavaScript
*
*********************************************************/
int execJavaScript( JSCode *_code, JSScope *_global, JSInstanceScope *_instanceScope )
{
int ret;
/* JSScope *global = new JSScope();
initBuiltin( global );
if ( _builtin != 0L )
_builtin( global ); */
JSScopeStack scopes( _global, _instanceScope );
JSValue rv;
/* JSNode *c;
for ( c = _code->first(); c != 0L; c = _code->next() )
{
if ( c->isA() == ID_JSFunction )
{
JSFunction *func = (JSFunction*)c;
global->insertObject( new JSFunctionObject( func ) );
}
} */
JSNode *c;
for ( c = _code->first(); c != 0L; c = _code->next() )
{
printf("Exec '%i'\n",c->isA());
ret = c->rightValue( &scopes, &rv );
if ( ret )
return ret;
}
return 0;
}
/**********************************************************
*
* makeGlobalScope
*
*********************************************************/
JSScope* makeGlobalScope()
{
JSScope *global = new JSScope();
initBuiltin( global );
return global;
}
--- NEW FILE: jstree.h ---
/* This file is part of the KDE libraries
Copyright (C) 1997 Torben Weis (weis at kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef JSTREE_H
#define JSTREE_H
class JSValue;
class JSNode;
class JSScope;
class JSScopeStack;
class JSFunction;
class JSParameter;
class JSFunctionCall;
class JSConstructorCall;
class JSArgument;
class JSParameterListObject;
class JSThis;
class JSStringObject;
class JSArrayaAccess;
#include <qstring.h>
#define ID_JSNode 1
#define ID_JSInteger 2
#define ID_JSBinaryOperator 3
#define ID_JSAssignment 4
#define ID_JSIdentifier 5
#define ID_JSStatement 6
#define ID_JSFunction 7
#define ID_JSParameter 8
#define ID_JSFunctionCall 9
#define ID_JSArgument 10
#define ID_JSConstructorCall 11
#define ID_JSThis 12
#define ID_JSMember 13
#define ID_JSString 14
#define ID_JSBool 15
#define ID_JSFloat 16
#define ID_JSNull 17
#define ID_JSArrayAccess 18
class JSNode
{
public:
JSNode();
virtual ~JSNode() { }
virtual int isA() { return ID_JSNode; }
virtual int leftValue( JSScopeStack* _s, JSValue *lv );
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
};
#include "jsexec.h"
class JSStatement : public JSNode
{
public:
JSStatement( JSNode *_code, JSNode *_next_code );
virtual ~JSStatement() { if ( code ) delete code; if ( nextCode ) delete nextCode; }
virtual int isA() { return ID_JSStatement; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
JSNode *code;
JSNode *nextCode;
};
class JSInteger : public JSNode
{
public:
JSInteger( int );
virtual ~JSInteger() { }
virtual int isA() { return ID_JSInteger; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
int value;
};
class JSBool : public JSNode
{
public:
JSBool( bool );
virtual ~JSBool() { }
virtual int isA() { return ID_JSBool; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
bool value;
};
class JSFloat : public JSNode
{
public:
JSFloat( double );
virtual ~JSFloat() { }
virtual int isA() { return ID_JSFloat; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
double value;
};
class JSBinaryOperator : public JSNode
{
public:
JSBinaryOperator( int _op, JSNode *_left, JSNode *_right );
virtual ~JSBinaryOperator() { if ( leftNode ) delete leftNode; if ( rightNode ) delete rightNode; }
virtual int isA() { return ID_JSBinaryOperator; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
int op;
JSNode *leftNode;
JSNode *rightNode;
};
class JSAssignment : public JSBinaryOperator
{
public:
JSAssignment( int _op, JSNode *_left, JSNode *_right );
virtual ~JSAssignment() { }
virtual int isA() { return ID_JSAssignment; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
};
class JSIdentifier : public JSNode
{
public:
JSIdentifier( const char *_name );
virtual ~JSIdentifier() { }
virtual int isA() { return ID_JSIdentifier; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
virtual int leftValue( JSScopeStack* _s, JSValue *rv );
protected:
QString name;
};
class JSFunction : public JSNode
{
public:
JSFunction( const char *_name, JSParameter* _param, JSNode *_code );
virtual ~JSFunction() { }
virtual int isA() { return ID_JSFunction; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
virtual int rightValue( JSScopeStack* _s, JSValue *rv, JSParameterListObject *_param );
const char* getName() { return name.data(); }
protected:
QString name;
JSNode *code;
JSParameter *parameters;
};
class JSParameter : public JSNode
{
public:
/**
* JSParameter may be 0L to indicate that there are no parameters to this
* function.
*/
JSParameter( const char *_name, JSParameter *_next );
virtual ~JSParameter() { }
virtual int isA() { return ID_JSParameter; }
JSParameter* getNextParameter() { return nextParameter; }
protected:
QString name;
JSParameter *nextParameter;
};
class JSFunctionCall : public JSNode
{
public:
JSFunctionCall( JSNode *_function, JSArgument *_arguments );
virtual ~JSFunctionCall() { }
virtual int isA() { return ID_JSFunctionCall; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
JSNode *function;
JSArgument *arguments;
};
class JSArgument : public JSNode
{
public:
JSArgument( JSNode *_code, JSArgument *_next );
virtual ~JSArgument() { }
virtual int isA() { return ID_JSArgument; }
virtual int rightValue( JSScopeStack *_scopes, JSParameterListObject *_param );
JSArgument* getNextArgument() { return nextArgument; }
protected:
JSNode *code;
JSArgument *nextArgument;
};
class JSConstructorCall : public JSNode
{
public:
JSConstructorCall( JSNode *_function, JSArgument *_arguments );
virtual ~JSConstructorCall() { }
virtual int isA() { return ID_JSConstructorCall; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
JSNode *function;
JSArgument *arguments;
};
class JSThis : public JSNode
{
public:
JSThis();
virtual ~JSThis() { }
virtual int isA() { return ID_JSThis; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
};
class JSMember : public JSNode
{
public:
JSMember( JSNode *_obj, const char *_name );
virtual ~JSMember();
virtual int isA() { return ID_JSMember; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
virtual int leftValue( JSScopeStack* _s, JSValue *lv );
protected:
QString name;
JSNode *object;
};
class JSString : public JSNode
{
public:
JSString( const char *_string );
virtual ~JSString();
virtual int isA() { return ID_JSString; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
JSStringObject *object;
};
class JSNull : public JSNode
{
public:
JSNull();
virtual ~JSNull();
virtual int isA() { return ID_JSNull; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
protected:
JSObject *object;
};
class JSArrayAccess : public JSNode
{
public:
JSArrayAccess( JSNode *_array, JSNode *_index );
virtual ~JSArrayAccess() { }
virtual int isA() { return ID_JSArrayAccess; }
virtual int rightValue( JSScopeStack* _s, JSValue *rv );
virtual int leftValue( JSScopeStack* _s, JSValue *rv );
protected:
JSNode *index;
JSNode *array;
};
#endif
More information about the dslinux-commit
mailing list