tint/sem: Add FunctionExpression
Will be generated for expressions that resolve to functions. Bug: tint:1810 Change-Id: I334729c9499be7b1c4ab229c1845a4d5f06fa107 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119701 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
7c2fa23a7e
commit
03b09f1099
|
@ -361,6 +361,7 @@ libtint_source_set("libtint_syntax_tree_src") {
|
|||
"sem/expression.h",
|
||||
"sem/for_loop_statement.h",
|
||||
"sem/function.h",
|
||||
"sem/function_expression.h",
|
||||
"sem/if_statement.h",
|
||||
"sem/index_accessor_expression.h",
|
||||
"sem/info.h",
|
||||
|
@ -741,6 +742,8 @@ libtint_source_set("libtint_sem_src") {
|
|||
"sem/for_loop_statement.h",
|
||||
"sem/function.cc",
|
||||
"sem/function.h",
|
||||
"sem/function_expression.cc",
|
||||
"sem/function_expression.h",
|
||||
"sem/if_statement.cc",
|
||||
"sem/if_statement.h",
|
||||
"sem/index_accessor_expression.cc",
|
||||
|
|
|
@ -316,6 +316,8 @@ list(APPEND TINT_LIB_SRCS
|
|||
sem/expression.h
|
||||
sem/for_loop_statement.cc
|
||||
sem/for_loop_statement.h
|
||||
sem/function_expression.cc
|
||||
sem/function_expression.h
|
||||
sem/function.cc
|
||||
sem/if_statement.cc
|
||||
sem/if_statement.h
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2023 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/tint/sem/function_expression.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::sem::FunctionExpression);
|
||||
|
||||
namespace tint::sem {
|
||||
|
||||
FunctionExpression::FunctionExpression(const ast::Expression* declaration,
|
||||
const Statement* statement,
|
||||
const sem::Function* function)
|
||||
: Base(declaration, statement), function_(function) {}
|
||||
|
||||
FunctionExpression::~FunctionExpression() = default;
|
||||
|
||||
} // namespace tint::sem
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2023 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef SRC_TINT_SEM_FUNCTION_EXPRESSION_H_
|
||||
#define SRC_TINT_SEM_FUNCTION_EXPRESSION_H_
|
||||
|
||||
#include "src/tint/sem/expression.h"
|
||||
|
||||
// Forward declarations
|
||||
namespace tint::sem {
|
||||
class Function;
|
||||
} // namespace tint::sem
|
||||
|
||||
namespace tint::sem {
|
||||
|
||||
/// FunctionExpression holds the semantic information for expression nodes that resolve to
|
||||
/// functions.
|
||||
class FunctionExpression : public Castable<FunctionExpression, Expression> {
|
||||
public:
|
||||
/// Constructor
|
||||
/// @param declaration the AST node
|
||||
/// @param statement the statement that owns this expression
|
||||
/// @param function the function that the expression resolved to
|
||||
FunctionExpression(const ast::Expression* declaration,
|
||||
const Statement* statement,
|
||||
const sem::Function* function);
|
||||
|
||||
/// Destructor
|
||||
~FunctionExpression() override;
|
||||
|
||||
/// @return the function that the expression resolved to
|
||||
const sem::Function* Function() const { return function_; }
|
||||
|
||||
private:
|
||||
sem::Function const* const function_;
|
||||
};
|
||||
|
||||
} // namespace tint::sem
|
||||
|
||||
#endif // SRC_TINT_SEM_FUNCTION_EXPRESSION_H_
|
Loading…
Reference in New Issue