Commit Graph

75 Commits

Author SHA1 Message Date
Ian Romanick bb7e00a1cd Add glsl_type::get_base_type query
Retreives the glsl_type that corresponds to the base type of a numeric scalar /
vector / matrix type.  So vec4 returns float, etc.
2010-03-23 17:31:39 -07:00
Ian Romanick 7aeb6abda7 Add glsl_type::is_numeric and glsl_type::is_boolean queries 2010-03-23 17:31:03 -07:00
Ian Romanick abef955764 Begin processing constructors
Right now, reject constructors for samplers because the are illegal.
2010-03-23 15:08:30 -07:00
Ian Romanick cb7d066967 Add query to determine whether a type is a sampler 2010-03-23 15:03:46 -07:00
Ian Romanick 1e5cd2b05b Add test for invalid assignment of function return value 2010-03-23 13:23:53 -07:00
Ian Romanick 0bb1c3c153 Add *some* type checking for assignments 2010-03-23 13:23:31 -07:00
Ian Romanick 71d0bbfcb2 Disallow passing NULL for state to _mesa_glsl_error
The two places that were still passing NULL had a state pointer to
pass.  Not passing it in these places prevented termination of
compilation of erroneous programs.
2010-03-23 13:21:19 -07:00
Ian Romanick f3f111eac4 Fix typographical errors of "FINISHME" 2010-03-23 13:04:19 -07:00
Ian Romanick cec65a6b76 Generate an error for variables declared with type void 2010-03-23 12:28:44 -07:00
Ian Romanick 8400bc4d35 Add is_error and is_void type queries 2010-03-23 12:28:28 -07:00
Ian Romanick 9e7c34b865 Set the type of a function call to be the return type of the callee 2010-03-23 12:21:18 -07:00
Ian Romanick e39cc69fa3 Set, and require, a return type for function signatures 2010-03-23 12:19:13 -07:00
Ian Romanick 7563b50075 Add `void' type to table of available types
This will make void-01.glsl test fail, so I may regret this later.
However, this will make supporting functions that return void or
functions that have a void parameter list easier to handle.
2010-03-23 12:11:50 -07:00
Ian Romanick 693bb11b5f Rename test GLSL sources from .txt to .glsl 2010-03-23 11:57:24 -07:00
Ian Romanick f8f1085e5e Add test for declaring variables of type void. 2010-03-23 11:54:03 -07:00
Ian Romanick 41ec6a47ab Track the function that is currently being defined
Later this will allow type checking for return statements.
2010-03-19 17:08:05 -07:00
Ian Romanick 16a246c049 Initial bits for converting AST return nodes to IR return instructions 2010-03-19 16:51:16 -07:00
Ian Romanick 9578c87ce2 Implement IR return instructions 2010-03-19 16:44:52 -07:00
Ian Romanick 3359e58eac Use glsl_symbol_table::name_declared_this_scope
Prevent most illegal name reuse.
2010-03-19 15:38:52 -07:00
Ian Romanick ac4fdc255b Add query to determine whether a name was declared at this scope
This will be used to prevent a variable and a function with the same
name from being declared.  As a side effect, the calls to
add_{type,name,function} should never fail.
2010-03-19 15:37:01 -07:00
Ian Romanick 38395c1aad Use separate namespaces for types, variables, and functions
This will allow types and their constructors to be easily stored in
the same symbol table.  This does add a potential problem that a
shader could declare a variable and a function with the same name.
This appears to be forbidden by the GLSL spec.
2010-03-19 15:34:13 -07:00
Ian Romanick 95517faf69 Add function to determine the scope where a variable is declared 2010-03-19 15:32:57 -07:00
Ian Romanick 8bde4cec6b Use glsl_symbol_table instead of using _mesa_symbol_table directly 2010-03-19 11:57:24 -07:00
Ian Romanick 82de85e264 Add a GLSL-specific facade to _mesa_symbol_table
This adds some type saftey and will enable elimination of a bunch of
type casts and other ugly crap in the code.
2010-03-19 11:43:36 -07:00
Ian Romanick b0bb781e1d Don't track new type names during pass-1 parsing
This implementation was wrong anyway because it did not respect
scoping rules.  This will need to be revisited soon.  The most likely
result is that the grammar is going to need some significant re-work
to be able to use a IDENTIFIER in all the places where a TYPE_NAME is
currently used.
2010-03-19 11:12:33 -07:00
Ian Romanick e309a6051d Add multiple include protection to ir.h 2010-03-15 15:20:15 -07:00
Ian Romanick 5c2bd09888 Trivial clean-ups to ast_type_specifier(int) constructor 2010-03-15 14:31:48 -07:00
Ian Romanick ed85a5dd4b Add new constructors for ast_type_specifier
Add a constructor that uses an ast_struct_specifier and one that uses
a type name.  This saves a (trivial) bit of code, but it also ensures
some of the class invariants (i.e., type_name != NULL) are met.
2010-03-15 14:28:17 -07:00
Ian Romanick 7f9d309743 Ensure that ast_type always has type_name set
For built-in types, type_name would be NULL.  This ensures that
type_name is set even for the built-in types.  This simplifies code in
a few places and centralizes the name setting code.
2010-03-15 14:18:32 -07:00
Ian Romanick bbddcb3092 Factor ast_type_specifier code out to ast_type.cpp 2010-03-15 14:09:23 -07:00
Ian Romanick f4749610ed Factor guts of function matching code out to match_function_by_name
This function will be used for matching some types of constructors as well.
2010-03-15 13:26:02 -07:00
Ian Romanick 548fa293a3 Move ast_function_expression::hir to ast_function.cpp 2010-03-15 13:04:13 -07:00
Ian Romanick 728330e3b2 Remove DOA hir_function.c file 2010-03-15 13:02:08 -07:00
Ian Romanick f13d4295f9 Change type of function_identifier to silence bison warning
When the implementation of function_call_header and
function_identifier were changed a few commits ago, the types of the
production changed.  This just updates the types specified for the
productions to match reality.
2010-03-11 16:12:25 -08:00
Ian Romanick 44eb13d0b5 Add parameters to function declarations in the correct order 2010-03-11 16:11:07 -08:00
Ian Romanick 471471f834 Initial pass at resolving function calls
The code is still really rough and *REALLY* incomplete.  This at least
passes the first few trivially simple test cases.
2010-03-11 14:57:26 -08:00
Ian Romanick cdb8d54b68 Default function parameters to 'in' instead of auto 2010-03-11 14:48:51 -08:00
Ian Romanick 7e3ed40200 Add a handful of simple tests for function calls in constructors 2010-03-11 14:46:19 -08:00
Ian Romanick ed45ec6a51 Add ir_call call to represent function calls. 2010-03-11 14:35:37 -08:00
Ian Romanick d27ec2461b Fix broken constructor of ir_instruction base class
Make the constructor inline-able, and don't try to initialize it as a
simple_node.  It hasn't been derived from simple_node in a long time.
2010-03-11 14:23:41 -08:00
Ian Romanick 1f58518059 Track generation of errors and halt compilation appropriately 2010-03-11 14:08:33 -08:00
Ian Romanick 3821761e45 Differentiate in ast_function_expression between constructors and func. calls 2010-03-10 14:12:22 -08:00
Ian Romanick 986b8f7982 Tell emacs that C++ .h files are C++ 2010-03-10 13:58:12 -08:00
Ian Romanick 7cfddf1941 Make ast_function_expression subclass of ast_expression 2010-03-10 13:26:52 -08:00
Ian Romanick d10fe19495 Simplified constructor for identifier expressions 2010-03-10 13:25:56 -08:00
Ian Romanick adfb0cd740 IR variable: Initial work to support GLSL built-in variables 2010-03-10 10:43:54 -08:00
Ian Romanick f52888fac0 Include cstdlib to be sure size_t is available 2010-03-10 10:42:37 -08:00
Ian Romanick d949a9afb0 Move top-level AST to HIR conversion to _mesa_ast_to_hir 2010-03-10 09:55:22 -08:00
Ian Romanick 8e6cd3bf54 Require the shader target be specified to the driver program 2010-03-10 09:31:30 -08:00
Ian Romanick 1c4156ffac Use ir_print_visitor to dump IR tree 2010-03-10 09:27:03 -08:00