HLSL: Add function call syntax and AST building.

This commit is contained in:
John Kessenich
2016-05-13 09:33:42 -06:00
parent 9db3117e38
commit 4678ca9dac
6 changed files with 83 additions and 25 deletions

View File

@@ -608,7 +608,7 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node)
return false;
// arguments
TIntermAggregate* arguments = nullptr;
TIntermTyped* arguments = nullptr;
if (! acceptArguments(constructorFunction, arguments)) {
expected("constructor arguments");
return false;
@@ -628,10 +628,17 @@ bool HlslGrammar::acceptConstructor(TIntermTyped*& node)
// function_call
// : [idToken] arguments
//
bool HlslGrammar::acceptFunctionCall(HlslToken idToken, TIntermTyped*&)
bool HlslGrammar::acceptFunctionCall(HlslToken idToken, TIntermTyped*& node)
{
// todo
return false;
// arguments
TFunction* function = new TFunction(idToken.string, TType(EbtVoid));
TIntermTyped* arguments = nullptr;
if (! acceptArguments(function, arguments))
return false;
node = parseContext.handleFunctionCall(idToken.loc, function, arguments);
return true;
}
// arguments
@@ -640,7 +647,7 @@ bool HlslGrammar::acceptFunctionCall(HlslToken idToken, TIntermTyped*&)
// The arguments are pushed onto the 'function' argument list and
// onto the 'arguments' aggregate.
//
bool HlslGrammar::acceptArguments(TFunction* function, TIntermAggregate*& arguments)
bool HlslGrammar::acceptArguments(TFunction* function, TIntermTyped*& arguments)
{
// LEFT_PAREN
if (! acceptTokenClass(EHTokLeftParen))
@@ -649,7 +656,7 @@ bool HlslGrammar::acceptArguments(TFunction* function, TIntermAggregate*& argume
do {
// expression
TIntermTyped* arg;
if (! acceptExpression(arg))
if (! acceptAssignmentExpression(arg))
break;
// hook it up