winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2011
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
996 discussions
Start a n
N
ew thread
Jacek Caban : vbscript: Added lexer support for string literals.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 0e415e0c0f512bf3ab937aedb917650847488d55 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0e415e0c0f512bf3ab937aedb…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:56:48 2011 +0200 vbscript: Added lexer support for string literals. --- dlls/vbscript/lex.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/parser.y | 2 +- 2 files changed, 46 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index 04ade1e..2fd51bc 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -197,6 +197,49 @@ static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret) return tIdentifier; } +static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret) +{ + const WCHAR *ptr = ++ctx->ptr; + WCHAR *rptr; + int len = 0; + + while(ctx->ptr < ctx->end) { + if(*ctx->ptr == '\n') { + FIXME("newline inside string literal\n"); + return 0; + } + + if(*ctx->ptr == '"') { + if(ctx->ptr[1] != '"') + break; + len--; + ctx->ptr++; + } + ctx->ptr++; + } + + if(ctx->ptr == ctx->end) { + FIXME("unterminated string literal\n"); + return 0; + } + + len += ctx->ptr-ptr; + + *ret = rptr = parser_alloc(ctx, (len+1)*sizeof(WCHAR)); + if(!rptr) + return 0; + + while(ptr < ctx->ptr) { + if(*ptr == '"') + ptr++; + *rptr++ = *ptr++; + } + + *rptr = 0; + ctx->ptr++; + return tString; +} + static int parse_next_token(void *lval, parser_ctx_t *ctx) { WCHAR c; @@ -238,6 +281,8 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) case '\\': case '.': return *ctx->ptr++; + case '"': + return parse_string_literal(ctx, lval); default: FIXME("Unhandled char %c in %s\n", *ctx->ptr, debugstr_w(ctx->ptr)); } diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 3761b13..06a0eb3 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -68,7 +68,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %token tNOTHING tEMPTY tNULL %token tCLASS tSET tNEW tPUBLIC tPRIVATE tDEFAULT tME %token tERROR tNEXT tON tRESUME tGOTO -%token <string> tIdentifier +%token <string> tIdentifier tString %type <statement> Statement StatementNl %type <expression> Expression LiteralExpression
1
0
0
0
Jacek Caban : vbscript: Added bool literals parsing support.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: d145d0c03735685486a52b66477c2c855721788b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d145d0c03735685486a52b664…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:56:36 2011 +0200 vbscript: Added bool literals parsing support. --- dlls/vbscript/parse.h | 6 ++++++ dlls/vbscript/parser.y | 30 ++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 7c9ab26..df337d2 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -17,6 +17,7 @@ */ typedef enum { + EXPR_BOOL, EXPR_MEMBER } expression_type_t; @@ -27,6 +28,11 @@ typedef struct _expression_t { typedef struct { expression_t expr; + VARIANT_BOOL value; +} bool_expression_t; + +typedef struct { + expression_t expr; expression_t *obj_expr; const WCHAR *identifier; expression_t *args; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 2fe9bdb..3761b13 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -35,6 +35,8 @@ static void parse_complete(parser_ctx_t*); static void source_add_statement(parser_ctx_t*,statement_t*); +static expression_t *new_bool_expression(parser_ctx_t*,VARIANT_BOOL); + static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*); static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); @@ -69,8 +71,9 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %token <string> tIdentifier %type <statement> Statement StatementNl +%type <expression> Expression LiteralExpression %type <member> MemberExpression -%type <expression> Arguments_opt ArgumentList_opt +%type <expression> Arguments_opt ArgumentList_opt ArgumentList %% @@ -98,7 +101,18 @@ Arguments_opt ArgumentList_opt : /* empty */ { $$ = NULL; } - /* | ArgumentList { $$ = $1; } */ + | ArgumentList { $$ = $1; } + +ArgumentList + : Expression { $$ = $1; } + | Expression ',' ArgumentList { $1->next = $3; $$ = $1; } + +Expression + : LiteralExpression /* FIXME */ { $$ = $1; } + +LiteralExpression + : tTRUE { $$ = new_bool_expression(ctx, VARIANT_TRUE); CHECK_ERROR; } + | tFALSE { $$ = new_bool_expression(ctx, VARIANT_FALSE); CHECK_ERROR; } %% @@ -135,6 +149,18 @@ static void *new_expression(parser_ctx_t *ctx, expression_type_t type, unsigned return expr; } +static expression_t *new_bool_expression(parser_ctx_t *ctx, VARIANT_BOOL value) +{ + bool_expression_t *expr; + + expr = new_expression(ctx, EXPR_BOOL, sizeof(*expr)); + if(!expr) + return NULL; + + expr->value = value; + return &expr->expr; +} + static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier) { member_expression_t *expr;
1
0
0
0
Jacek Caban : vbscript: Added more keywords to lexer.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 7cbc5235bdd9904b06361e1be09285b43da1f006 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=7cbc5235bdd9904b06361e1be…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:56:18 2011 +0200 vbscript: Added more keywords to lexer. --- dlls/vbscript/lex.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++- dlls/vbscript/parser.y | 15 ++++++- 2 files changed, 110 insertions(+), 3 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index af01220..04ade1e 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -26,13 +26,109 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript); +static const WCHAR andW[] = {'a','n','d',0}; +static const WCHAR byrefW[] = {'b','y','r','e','f',0}; +static const WCHAR byvalW[] = {'b','y','v','a','l',0}; static const WCHAR callW[] = {'c','a','l','l',0}; +static const WCHAR classW[] = {'c','l','a','s','s',0}; +static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0}; +static const WCHAR dimW[] = {'d','i','m',0}; +static const WCHAR doW[] = {'d','o',0}; +static const WCHAR elseW[] = {'e','l','s','e',0}; +static const WCHAR elseifW[] = {'e','l','s','e','i','f',0}; +static const WCHAR emptyW[] = {'e','m','p','t','y',0}; +static const WCHAR endW[] = {'e','n','d',0}; +static const WCHAR eqvW[] = {'e','q','v',0}; +static const WCHAR errorW[] = {'e','r','r','o','r',0}; +static const WCHAR exitW[] = {'e','x','i','t',0}; +static const WCHAR explicitW[] = {'e','x','p','l','i','c','i','t',0}; +static const WCHAR falseW[] = {'f','a','l','s','e',0}; +static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0}; +static const WCHAR getW[] = {'g','e','t',0}; +static const WCHAR gotoW[] = {'g','o','t','o',0}; +static const WCHAR ifW[] = {'i','f',0}; +static const WCHAR impW[] = {'i','m','p',0}; +static const WCHAR isW[] = {'i','s',0}; +static const WCHAR letW[] = {'l','e','t',0}; +static const WCHAR loopW[] = {'l','o','o','p',0}; +static const WCHAR meW[] = {'m','e',0}; +static const WCHAR modW[] = {'m','o','d',0}; +static const WCHAR newW[] = {'n','e','w',0}; +static const WCHAR nextW[] = {'n','e','x','t',0}; +static const WCHAR notW[] = {'n','o','t',0}; +static const WCHAR nothingW[] = {'n','o','t','h','i','n','g',0}; +static const WCHAR nullW[] = {'n','u','l','l',0}; +static const WCHAR onW[] = {'o','n',0}; +static const WCHAR optionW[] = {'o','p','t','i','o','n',0}; +static const WCHAR orW[] = {'o','r',0}; +static const WCHAR privateW[] = {'p','r','i','v','a','t','e',0}; +static const WCHAR propertyW[] = {'p','r','o','p','e','r','t','y',0}; +static const WCHAR publicW[] = {'p','u','b','l','i','c',0}; +static const WCHAR remW[] = {'r','e','m',0}; +static const WCHAR resumeW[] = {'r','e','s','u','m','e',0}; +static const WCHAR setW[] = {'s','e','t',0}; +static const WCHAR stopW[] = {'s','t','o','p',0}; +static const WCHAR subW[] = {'s','u','b',0}; +static const WCHAR thenW[] = {'t','h','e','n',0}; +static const WCHAR trueW[] = {'t','r','u','e',0}; +static const WCHAR untilW[] = {'u','n','t','i','l',0}; +static const WCHAR wendW[] = {'w','e','n','d',0}; +static const WCHAR whileW[] = {'w','h','i','l','e',0}; +static const WCHAR xorW[] = {'x','o','r',0}; static const struct { const WCHAR *word; int token; } keywords[] = { - {callW, tCALL} + {andW, tAND}, + {byrefW, tBYREF}, + {byvalW, tBYVAL}, + {callW, tCALL}, + {classW, tCLASS}, + {defaultW, tDEFAULT}, + {dimW, tDIM}, + {doW, tDO}, + {elseW, tELSE}, + {elseifW, tELSEIF}, + {emptyW, tEMPTY}, + {endW, tEND}, + {eqvW, tEQV}, + {errorW, tERROR}, + {exitW, tEXIT}, + {explicitW, tEXPLICIT}, + {falseW, tFALSE}, + {functionW, tFUNCTION}, + {getW, tGET}, + {gotoW, tGOTO}, + {ifW, tIF}, + {impW, tIMP}, + {isW, tIS}, + {letW, tLET}, + {loopW, tLOOP}, + {meW, tME}, + {modW, tMOD}, + {newW, tNEW}, + {nextW, tNEXT}, + {notW, tNOT}, + {nothingW, tNOTHING}, + {nullW, tNULL}, + {onW, tON}, + {optionW, tOPTION}, + {orW, tOR}, + {privateW, tPRIVATE}, + {propertyW, tPROPERTY}, + {publicW, tPUBLIC}, + {remW, tREM}, + {resumeW, tRESUME}, + {setW, tSET}, + {stopW, tSTOP}, + {subW, tSUB}, + {thenW, tTHEN}, + {trueW, tTRUE}, + {untilW, tUNTIL}, + {wendW, tWEND}, + {whileW, tWHILE}, + {xorW, tXOR} }; static inline BOOL is_identifier_char(WCHAR c) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index caf6f49..2fe9bdb 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -53,8 +53,19 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); member_expression_t *member; } -%token tEOF tNL blah -%token tCALL +%token tEOF tNL tREM +%token tTRUE tFALSE +%token tNOT tAND tOR tXOR tEQV tIMP tNEQ +%token tIS tLTEQ tGTEQ tMOD +%token tCALL tDIM tSUB tFUNCTION tPROPERTY tGET tLET +%token tIF tELSE tELSEIF tEND tTHEN tEXIT +%token tWHILE tWEND tDO tLOOP tUNTIL +%token tBYREF tBYVAL +%token tOPTION tEXPLICIT +%token tSTOP +%token tNOTHING tEMPTY tNULL +%token tCLASS tSET tNEW tPUBLIC tPRIVATE tDEFAULT tME +%token tERROR tNEXT tON tRESUME tGOTO %token <string> tIdentifier %type <statement> Statement StatementNl
1
0
0
0
Jacek Caban : vbscript: Added Call statement implementation.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 23fc7678deea6a753ebed46acd3bd4e65910cca5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=23fc7678deea6a753ebed46ac…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:56:05 2011 +0200 vbscript: Added Call statement implementation. --- dlls/vbscript/parser.y | 3 ++- dlls/vbscript/tests/run.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 447aa12..caf6f49 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -74,7 +74,8 @@ StatementNl : Statement tNL { $$ = $1; } Statement - : MemberExpression Arguments_opt { $1->args = $2; $$ = new_call_statement(ctx, $1); CHECK_ERROR; } + : MemberExpression Arguments_opt { $1->args = $2; $$ = new_call_statement(ctx, $1); CHECK_ERROR; } + | tCALL MemberExpression Arguments_opt { $2->args = $3; $$ = new_call_statement(ctx, $2); CHECK_ERROR; } MemberExpression : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 9b1abd4..6f1a967 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -475,6 +475,12 @@ static void run_tests(void) parse_script_a("reportSuccess()"); CHECK_CALLED(global_success_d); CHECK_CALLED(global_success_i); + + SET_EXPECT(global_success_d); + SET_EXPECT(global_success_i); + parse_script_a("Call reportSuccess"); + CHECK_CALLED(global_success_d); + CHECK_CALLED(global_success_i); } static BOOL check_vbscript(void)
1
0
0
0
Jacek Caban : vbscript: Added support for call keyword in lexer.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: b6e9a83d781e33b261fa880ef78a85025449913c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b6e9a83d781e33b261fa880ef…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:55:51 2011 +0200 vbscript: Added support for call keyword in lexer. --- dlls/vbscript/lex.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++- dlls/vbscript/parser.y | 1 + 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index d41c582..af01220 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -26,11 +26,61 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript); +static const WCHAR callW[] = {'c','a','l','l',0}; + +static const struct { + const WCHAR *word; + int token; +} keywords[] = { + {callW, tCALL} +}; + static inline BOOL is_identifier_char(WCHAR c) { return isalnumW(c) || c == '_'; } +static int check_keyword(parser_ctx_t *ctx, const WCHAR *word) +{ + const WCHAR *p1 = ctx->ptr; + const WCHAR *p2 = word; + WCHAR c; + + while(p1 < ctx->end && *p2) { + c = tolowerW(*p1); + if(c != *p2) + return c - *p2; + p1++; + p2++; + } + + if(*p2 || (p1 < ctx->end && is_identifier_char(*p1))) + return 1; + + ctx->ptr = p1; + return 0; +} + +static int check_keywords(parser_ctx_t *ctx) +{ + int min = 0, max = sizeof(keywords)/sizeof(keywords[0])-1, r, i; + + while(min <= max) { + i = (min+max)/2; + + r = check_keyword(ctx, keywords[i].word); + if(!r) + return keywords[i].token; + + if(r > 0) + min = i+1; + else + max = i-1; + } + + return 0; +} + static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret) { const WCHAR *ptr = ctx->ptr++; @@ -62,8 +112,12 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) c = *ctx->ptr; - if(isalphaW(c)) - return parse_identifier(ctx, lval); + if(isalphaW(c)) { + int ret = check_keywords(ctx); + if(!ret) + return parse_identifier(ctx, lval); + return ret; + } switch(c) { case '\n': diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index d5c7d40..447aa12 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -54,6 +54,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); } %token tEOF tNL blah +%token tCALL %token <string> tIdentifier %type <statement> Statement StatementNl
1
0
0
0
Jacek Caban : vbscript: Better function call parsing.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 69dcc641dfbc14066a9faa55c643e4bf2f6e7758 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=69dcc641dfbc14066a9faa55c…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:55:35 2011 +0200 vbscript: Better function call parsing. --- dlls/vbscript/parser.y | 16 ++++++++++++++-- dlls/vbscript/tests/run.c | 6 ++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 5fb6bd2..d5c7d40 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -39,6 +39,8 @@ static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,co static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); +#define CHECK_ERROR if(((parser_ctx_t*)ctx)->hres != S_OK) YYABORT + %} %pure_parser @@ -47,6 +49,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %union { const WCHAR *string; statement_t *statement; + expression_t *expression; member_expression_t *member; } @@ -55,6 +58,7 @@ static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); %type <statement> Statement StatementNl %type <member> MemberExpression +%type <expression> Arguments_opt ArgumentList_opt %% @@ -69,12 +73,20 @@ StatementNl : Statement tNL { $$ = $1; } Statement - : MemberExpression /* FIXME: Arguments_opt */ { $$ = new_call_statement(ctx, $1); } + : MemberExpression Arguments_opt { $1->args = $2; $$ = new_call_statement(ctx, $1); CHECK_ERROR; } MemberExpression - : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); } + : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; } /* FIXME: MemberExpressionArgs '.' tIdentifier */ +Arguments_opt + : /* empty */ { $$ = NULL; } + | '(' ArgumentList_opt ')' { $$ = $2; } + +ArgumentList_opt + : /* empty */ { $$ = NULL; } + /* | ArgumentList { $$ = $1; } */ + %% static int parser_error(const char *str) diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 4f70224..9b1abd4 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -469,6 +469,12 @@ static void run_tests(void) parse_script_a("reportSuccess"); CHECK_CALLED(global_success_d); CHECK_CALLED(global_success_i); + + SET_EXPECT(global_success_d); + SET_EXPECT(global_success_i); + parse_script_a("reportSuccess()"); + CHECK_CALLED(global_success_d); + CHECK_CALLED(global_success_i); } static BOOL check_vbscript(void)
1
0
0
0
Jacek Caban : vbscript: Added support for a few more characters in lexer.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 1ac1ffba11104fced99ce0bd6d5f5b4d0f61e39f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1ac1ffba11104fced99ce0bd6…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:55:14 2011 +0200 vbscript: Added support for a few more characters in lexer. --- dlls/vbscript/lex.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c index d481e6a..d41c582 100644 --- a/dlls/vbscript/lex.c +++ b/dlls/vbscript/lex.c @@ -76,6 +76,18 @@ static int parse_next_token(void *lval, parser_ctx_t *ctx) else ctx->ptr = ctx->end; return tNL; + case '(': + case ')': + case ',': + case '=': + case '+': + case '-': + case '*': + case '/': + case '^': + case '\\': + case '.': + return *ctx->ptr++; default: FIXME("Unhandled char %c in %s\n", *ctx->ptr, debugstr_w(ctx->ptr)); }
1
0
0
0
Jacek Caban : vbscript: Added simple call test.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 6e749ba5dc02052eea066bd90fe9aa3293a65171 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6e749ba5dc02052eea066bd90…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:54:51 2011 +0200 vbscript: Added simple call test. --- dlls/vbscript/tests/run.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index d61b81f..4f70224 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -463,6 +463,12 @@ static void run_tests(void) parse_script_a(""); parse_script_a("' empty ;"); + + SET_EXPECT(global_success_d); + SET_EXPECT(global_success_i); + parse_script_a("reportSuccess"); + CHECK_CALLED(global_success_d); + CHECK_CALLED(global_success_i); } static BOOL check_vbscript(void)
1
0
0
0
Jacek Caban : vbscript: Added interp_icallv implementation.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 9d7552205c5aa43c42db252b3f62eb6ca8d460be URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9d7552205c5aa43c42db252b3…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:54:37 2011 +0200 vbscript: Added interp_icallv implementation. --- dlls/vbscript/interp.c | 67 +++++++++++++++++++++++++++++++++++++++-- dlls/vbscript/vbdisp.c | 43 ++++++++++++++++++++++++++ dlls/vbscript/vbscript.h | 8 ++++- dlls/vbscript/vbscript_main.c | 2 + 4 files changed, 115 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 3ff6bbd..b309397 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -28,15 +28,75 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript); typedef struct { vbscode_t *code; instr_t *instr; + script_ctx_t *script; } exec_ctx_t; - typedef HRESULT (*instr_func_t)(exec_ctx_t*); +typedef enum { + REF_NONE, + REF_DISP +} ref_type_t; + +typedef struct { + ref_type_t type; + union { + struct { + IDispatch *disp; + DISPID id; + } d; + } u; +} ref_t; + +static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref) +{ + named_item_t *item; + DISPID id; + HRESULT hres; + + LIST_FOR_EACH_ENTRY(item, &ctx->script->named_items, named_item_t, entry) { + if(item->flags & SCRIPTITEM_GLOBALMEMBERS) { + hres = disp_get_id(item->disp, name, &id); + if(SUCCEEDED(hres)) { + ref->type = REF_DISP; + ref->u.d.disp = item->disp; + ref->u.d.id = id; + return S_OK; + } + } + } + + FIXME("create if no option explicit\n"); + + ref->type = REF_NONE; + return S_OK; +} + static HRESULT interp_icallv(exec_ctx_t *ctx) { - FIXME("\n"); - return E_NOTIMPL; + BSTR identifier = ctx->instr->arg1.bstr; + DISPPARAMS dp = {0}; + ref_t ref; + HRESULT hres; + + TRACE("\n"); + + hres = lookup_identifier(ctx, identifier, &ref); + if(FAILED(hres)) + return hres; + + switch(ref.type) { + case REF_DISP: + hres = disp_call(ctx->script, ref.u.d.disp, ref.u.d.id, &dp, NULL); + if(FAILED(hres)) + return hres; + break; + default: + FIXME("%s not found\n", debugstr_w(identifier)); + return DISP_E_UNKNOWNNAME; + } + + return S_OK; } static HRESULT interp_ret(exec_ctx_t *ctx) @@ -67,6 +127,7 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func) exec.code = func->code_ctx; exec.instr = exec.code->instrs + func->code_off; + exec.script = ctx; while(exec.instr) { op = exec.instr->op; diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c index 3c81789..c115199 100644 --- a/dlls/vbscript/vbdisp.c +++ b/dlls/vbscript/vbdisp.c @@ -203,3 +203,46 @@ HRESULT init_global(script_ctx_t *ctx) { return create_vbdisp(&ctx->script_obj); } + +HRESULT disp_get_id(IDispatch *disp, BSTR name, DISPID *id) +{ + IDispatchEx *dispex; + HRESULT hres; + + if(disp->lpVtbl == (IDispatchVtbl*)&DispatchExVtbl) + FIXME("properly handle builtin objects\n"); + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(FAILED(hres)) { + TRACE("unsing IDispatch\n"); + return IDispatch_GetIDsOfNames(disp, &IID_NULL, &name, 1, 0, id); + } + + hres = IDispatchEx_GetDispID(dispex, name, fdexNameCaseInsensitive, id); + IDispatchEx_Release(dispex); + return hres; +} + +HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, DISPPARAMS *dp, VARIANT *retv) +{ + const WORD flags = DISPATCH_METHOD|(retv ? DISPATCH_PROPERTYGET : 0); + IDispatchEx *dispex; + EXCEPINFO ei; + HRESULT hres; + + memset(&ei, 0, sizeof(ei)); + if(retv) + V_VT(retv) = VT_EMPTY; + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(FAILED(hres)) { + UINT err = 0; + + TRACE("using IDispatch\n"); + return IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, flags, dp, retv, &ei, &err); + } + + hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, flags, dp, retv, &ei, NULL /* CALLER_FIXME */); + IDispatchEx_Release(dispex); + return hres; +} diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 9942ac7..8aca01c 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -33,6 +33,7 @@ typedef struct _function_t function_t; typedef struct _vbscode_t vbscode_t; +typedef struct _script_ctx_t script_ctx_t; typedef struct named_item_t { IDispatch *disp; @@ -48,7 +49,10 @@ typedef struct { LONG ref; } vbdisp_t; -typedef struct { +HRESULT disp_get_id(IDispatch*,BSTR,DISPID*); +HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*,VARIANT*); + +struct _script_ctx_t { IActiveScriptSite *site; LCID lcid; @@ -58,7 +62,7 @@ typedef struct { struct list code_list; struct list named_items; -} script_ctx_t; +}; HRESULT init_global(script_ctx_t*); diff --git a/dlls/vbscript/vbscript_main.c b/dlls/vbscript/vbscript_main.c index fc31aed..9d74026 100644 --- a/dlls/vbscript/vbscript_main.c +++ b/dlls/vbscript/vbscript_main.c @@ -27,6 +27,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript); +DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); + static HINSTANCE vbscript_hinstance; static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1
0
0
0
Jacek Caban : vbscript: Store call identifier as BSTR.
by Alexandre Julliard
08 Sep '11
08 Sep '11
Module: wine Branch: master Commit: 060255d0841d517c6cc48ccaadf6bca4e4a8c2ab URL:
http://source.winehq.org/git/wine.git/?a=commit;h=060255d0841d517c6cc48ccaa…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Sep 8 14:54:23 2011 +0200 vbscript: Store call identifier as BSTR. --- dlls/vbscript/Makefile.in | 1 + dlls/vbscript/compile.c | 47 ++++++++++++++++++++++++++++++++++++++++++-- dlls/vbscript/vbscript.h | 10 +++++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/Makefile.in b/dlls/vbscript/Makefile.in index 9e27dd4..cd7e18d 100644 --- a/dlls/vbscript/Makefile.in +++ b/dlls/vbscript/Makefile.in @@ -1,4 +1,5 @@ MODULE = vbscript.dll +IMPORTS = oleaut32 C_SRCS = \ compile.c \ diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index d57abcf..49d933b 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -59,15 +59,45 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op) return ctx->instr_cnt++; } -static HRESULT push_instr_str(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg) +static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str) +{ + if(!ctx->code->bstr_pool_size) { + ctx->code->bstr_pool = heap_alloc(8 * sizeof(BSTR)); + if(!ctx->code->bstr_pool) + return NULL; + ctx->code->bstr_pool_size = 8; + }else if(ctx->code->bstr_pool_size == ctx->code->bstr_cnt) { + BSTR *new_pool; + + new_pool = heap_realloc(ctx->code->bstr_pool, ctx->code->bstr_pool_size*2*sizeof(BSTR)); + if(!new_pool) + return NULL; + + ctx->code->bstr_pool = new_pool; + ctx->code->bstr_pool_size *= 2; + } + + ctx->code->bstr_pool[ctx->code->bstr_cnt] = SysAllocString(str); + if(!ctx->code->bstr_pool[ctx->code->bstr_cnt]) + return NULL; + + return ctx->code->bstr_pool[ctx->code->bstr_cnt++]; +} + +static HRESULT push_instr_bstr(compile_ctx_t *ctx, vbsop_t op, const WCHAR *arg) { unsigned instr; + BSTR bstr; + + bstr = alloc_bstr_arg(ctx, arg); + if(!bstr) + return E_OUTOFMEMORY; instr = push_instr(ctx, op); if(instr == -1) return E_OUTOFMEMORY; - instr_ptr(ctx, instr)->arg1.str = arg; + instr_ptr(ctx, instr)->arg1.bstr = bstr; return S_OK; } @@ -84,7 +114,7 @@ static HRESULT compile_member_expression(compile_ctx_t *ctx, member_expression_t FIXME("obj_expr not implemented\n"); hres = E_NOTIMPL; }else { - hres = push_instr_str(ctx, OP_icallv, expr->identifier); + hres = push_instr_bstr(ctx, OP_icallv, expr->identifier); } return hres; @@ -130,7 +160,14 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f void release_vbscode(vbscode_t *code) { + unsigned i; + list_remove(&code->entry); + + for(i=0; i < code->bstr_cnt; i++) + SysFreeString(code->bstr_pool[i]); + + heap_free(code->bstr_pool); heap_free(code->source); heap_free(code->instrs); heap_free(code); @@ -159,6 +196,10 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ctx->instr_cnt = 0; ctx->instr_size = 32; + ret->bstr_pool = NULL; + ret->bstr_pool_size = 0; + ret->bstr_cnt = 0; + ret->global_code.code_ctx = ret; list_init(&ret->entry); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index bca630a..9942ac7 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -64,11 +64,12 @@ HRESULT init_global(script_ctx_t*); typedef enum { ARG_NONE = 0, - ARG_STR + ARG_STR, + ARG_BSTR } instr_arg_type_t; #define OP_LIST \ - X(icallv, 1, ARG_STR, 0) \ + X(icallv, 1, ARG_BSTR, 0) \ X(ret, 0, 0, 0) typedef enum { @@ -80,6 +81,7 @@ OP_LIST typedef union { const WCHAR *str; + BSTR bstr; } instr_arg_t; typedef struct { @@ -100,6 +102,10 @@ struct _vbscode_t { BOOL global_executed; function_t global_code; + BSTR *bstr_pool; + unsigned bstr_pool_size; + unsigned bstr_cnt; + struct list entry; };
1
0
0
0
← Newer
1
...
72
73
74
75
76
77
78
...
100
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Results per page:
10
25
50
100
200