Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
6c557029
Commit
6c557029
authored
13 years ago
by
Jacek Caban
Committed by
Alexandre Julliard
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
vbscript: Added function call statement parsing beginning implementation.
parent
91cc7bd7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dlls/vbscript/compile.c
+7
-2
7 additions, 2 deletions
dlls/vbscript/compile.c
dlls/vbscript/parse.h
+33
-0
33 additions, 0 deletions
dlls/vbscript/parse.h
dlls/vbscript/parser.y
+91
-2
91 additions, 2 deletions
dlls/vbscript/parser.y
with
131 additions
and
4 deletions
dlls/vbscript/compile.c
+
7
−
2
View file @
6c557029
...
...
@@ -53,13 +53,18 @@ static unsigned push_instr(compile_ctx_t *ctx, vbsop_t op)
return
ctx
->
instr_cnt
++
;
}
static
HRESULT
compile_func
(
compile_ctx_t
*
ctx
,
function_t
*
func
)
static
HRESULT
compile_func
(
compile_ctx_t
*
ctx
,
statement_t
*
stat
,
function_t
*
func
)
{
func
->
code_off
=
ctx
->
instr_cnt
;
if
(
push_instr
(
ctx
,
OP_ret
)
==
-
1
)
return
E_OUTOFMEMORY
;
if
(
stat
)
{
FIXME
(
"statements compilation not implemented
\n
"
);
return
E_NOTIMPL
;
}
return
S_OK
;
}
...
...
@@ -113,7 +118,7 @@ HRESULT compile_script(script_ctx_t *script, const WCHAR *src, vbscode_t **ret)
if
(
!
ctx
.
code
)
return
E_OUTOFMEMORY
;
hres
=
compile_func
(
&
ctx
,
&
ctx
.
code
->
global_code
);
hres
=
compile_func
(
&
ctx
,
ctx
.
parser
.
stats
,
&
ctx
.
code
->
global_code
);
if
(
FAILED
(
hres
))
{
release_vbscode
(
ctx
.
code
);
return
hres
;
...
...
This diff is collapsed.
Click to expand it.
dlls/vbscript/parse.h
+
33
−
0
View file @
6c557029
...
...
@@ -16,6 +16,36 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
typedef
enum
{
EXPR_MEMBER
}
expression_type_t
;
typedef
struct
_expression_t
{
expression_type_t
type
;
struct
_expression_t
*
next
;
}
expression_t
;
typedef
struct
{
expression_t
expr
;
expression_t
*
obj_expr
;
const
WCHAR
*
identifier
;
expression_t
*
args
;
}
member_expression_t
;
typedef
enum
{
STAT_CALL
}
statement_type_t
;
typedef
struct
_statement_t
{
statement_type_t
type
;
struct
_statement_t
*
next
;
}
statement_t
;
typedef
struct
{
statement_t
stat
;
member_expression_t
*
expr
;
}
call_statement_t
;
typedef
struct
{
const
WCHAR
*
code
;
const
WCHAR
*
ptr
;
...
...
@@ -26,6 +56,9 @@ typedef struct {
int
last_token
;
unsigned
last_nl
;
statement_t
*
stats
;
statement_t
*
stats_tail
;
}
parser_ctx_t
;
HRESULT
parse_script
(
parser_ctx_t
*
,
const
WCHAR
*
)
DECLSPEC_HIDDEN
;
...
...
This diff is collapsed.
Click to expand it.
dlls/vbscript/parser.y
+
91
−
2
View file @
6c557029
...
...
@@ -33,6 +33,12 @@ static int parser_error(const char*);
static void parse_complete(parser_ctx_t*);
static void source_add_statement(parser_ctx_t*,statement_t*);
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*);
%}
%pure_parser
...
...
@@ -40,14 +46,34 @@ static void parse_complete(parser_ctx_t*);
%union {
const WCHAR *string;
statement_t *statement;
member_expression_t *member;
}
%token tEOF tNL
%token tEOF tNL
blah
%token <string> tIdentifier
%type <statement> Statement StatementNl
%type <member> MemberExpression
%%
Program : tEOF { parse_complete(ctx); }
Program
: SourceElements tEOF { parse_complete(ctx); }
SourceElements
: /* empty */
| SourceElements StatementNl { source_add_statement(ctx, $2); }
StatementNl
: Statement tNL { $$ = $1; }
Statement
: MemberExpression /* FIXME: Arguments_opt */ { $$ = new_call_statement(ctx, $1); }
MemberExpression
: tIdentifier { $$ = new_member_expression(ctx, NULL, $1); }
/* FIXME: MemberExpressionArgs '.' tIdentifier */
%%
...
...
@@ -56,11 +82,73 @@ static int parser_error(const char *str)
return 0;
}
static void source_add_statement(parser_ctx_t *ctx, statement_t *stat)
{
if(ctx->stats) {
ctx->stats_tail->next = stat;
ctx->stats_tail = stat;
}else {
ctx->stats = ctx->stats_tail = stat;
}
}
static void parse_complete(parser_ctx_t *ctx)
{
ctx->parse_complete = TRUE;
}
static void *new_expression(parser_ctx_t *ctx, expression_type_t type, unsigned size)
{
expression_t *expr;
expr = parser_alloc(ctx, size ? size : sizeof(*expr));
if(expr) {
expr->type = type;
expr->next = NULL;
}
return expr;
}
static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_t *obj_expr, const WCHAR *identifier)
{
member_expression_t *expr;
expr = new_expression(ctx, EXPR_MEMBER, sizeof(*expr));
if(!expr)
return NULL;
expr->obj_expr = obj_expr;
expr->identifier = identifier;
expr->args = NULL;
return expr;
}
static void *new_statement(parser_ctx_t *ctx, statement_type_t type, unsigned size)
{
statement_t *stat;
stat = parser_alloc(ctx, size);
if(stat) {
stat->type = type;
stat->next = NULL;
}
return stat;
}
static statement_t *new_call_statement(parser_ctx_t *ctx, member_expression_t *expr)
{
call_statement_t *stat;
stat = new_statement(ctx, STAT_CALL, sizeof(*stat));
if(!stat)
return NULL;
stat->expr = expr;
return &stat->stat;
}
void *parser_alloc(parser_ctx_t *ctx, size_t size)
{
void *ret;
...
...
@@ -82,6 +170,7 @@ HRESULT parse_script(parser_ctx_t *ctx, const WCHAR *code)
ctx->last_token = tNL;
ctx->last_nl = 0;
ctx->stats = ctx->stats_tail = NULL;
parser_parse(ctx);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment