Module: wine Branch: master Commit: 2ad2c5fa018f7189c41ae6be461daee10ac3e6e1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=2ad2c5fa018f7189c41ae6be46...
Author: Matteo Bruni mbruni@codeweavers.com Date: Mon Jun 4 17:58:23 2012 +0200
d3dcompiler: Add identifiers parsing.
---
dlls/d3dcompiler_43/d3dcompiler_private.h | 3 +++ dlls/d3dcompiler_43/hlsl.l | 12 ++++++++++++ dlls/d3dcompiler_43/hlsl.y | 1 + dlls/d3dcompiler_43/utils.c | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 72c2511..ec6e6e4 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -614,6 +614,9 @@ struct hlsl_parse_ctx extern struct hlsl_parse_ctx hlsl_ctx DECLSPEC_HIDDEN;
void hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN; +struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN; +struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN; +BOOL find_function(const char *name) DECLSPEC_HIDDEN; struct bwriter_shader *parse_hlsl_shader(const char *text, enum shader_type type, DWORD version, const char *entrypoint, char **messages) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dcompiler_43/hlsl.l b/dlls/d3dcompiler_43/hlsl.l index 0a18326..ef12ab9 100644 --- a/dlls/d3dcompiler_43/hlsl.l +++ b/dlls/d3dcompiler_43/hlsl.l @@ -45,6 +45,7 @@ WS [ \t] NEWLINE (\n)|(\r\n) DOUBLESLASHCOMMENT "//"[^\n]* STRING "[^"]*" +IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
ANY (.)
@@ -166,6 +167,17 @@ while {return KW_WHILE; } column_major {return KW_COLUMN_MAJOR; } row_major {return KW_ROW_MAJOR; }
+{IDENTIFIER} { + hlsl_lval.name = d3dcompiler_strdup(yytext); + if (get_variable(hlsl_ctx.cur_scope, yytext) + || find_function(yytext)) + return VAR_IDENTIFIER; + else if (get_type(hlsl_ctx.cur_scope, yytext, TRUE)) + return TYPE_IDENTIFIER; + else + return NEW_IDENTIFIER; + } + [+-]?[0-9]*.[0-9]+([eE][+-]?[0-9]+)?[h|H|f|F]? { hlsl_lval.floatval = atof(yytext); return C_FLOAT; diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y index d20360d..a9a8f0c 100644 --- a/dlls/d3dcompiler_43/hlsl.y +++ b/dlls/d3dcompiler_43/hlsl.y @@ -159,6 +159,7 @@ static void hlsl_error(const char *s)
%token <intval> PRE_LINE
+%token <name> VAR_IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER %token <name> STRING %token <floatval> C_FLOAT %token <intval> C_INTEGER diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 4cbad5b..d512a14 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -3,6 +3,7 @@ * Copyright 2009 Matteo Bruni * Copyright 2008-2009 Henri Verbeet for CodeWeavers * Copyright 2010 Rico Schüller + * Copyright 2012 Matteo Bruni for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -759,3 +760,21 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, va_l } } } + +struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) +{ + FIXME("stub.\n"); + return NULL; +} + +struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) +{ + FIXME("stub.\n"); + return NULL; +} + +BOOL find_function(const char *name) +{ + FIXME("stub.\n"); + return FALSE; +}