diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-08 17:47:31 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-08 18:22:26 -0700 |
| commit | 780a0bcd3724cad77cb65f931f111273776c9ca4 (patch) | |
| tree | 559e7c1d6c8cd43121f8e16d8f7686fc1608bb8a /source/slang/emit.cpp | |
| parent | a40b6679931f672a911070fcc7eeb41c52e8b8fd (diff) | |
Add back `UnparsedStmt`
If the user doesn't use any `import` declarations, there is no reason to parse their code at all, so having the option of falling back to `UnparsedStmt` can potentially save us some headaches down the road.
The new rule now is that if you have the "no checking" flag on, *and* the parser hasn't yet seen any `import` declarations, then it still used `UnparsedStmt` to avoid touching function bodies.
Otherwise, I go ahead and parse function bodies, and assume I can rewrite any code I can semantically understand.
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 24b0dd717..20b9856c5 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -2121,6 +2121,17 @@ struct EmitVisitor } } + void EmitUnparsedStmt(RefPtr<UnparsedStmt> stmt) + { + // TODO: actually emit the tokens that made up the statement... + Emit("{\n"); + for( auto& token : stmt->tokens ) + { + emitTokenWithLocation(token); + } + Emit("}\n"); + } + void EmitStmt(RefPtr<StatementSyntaxNode> stmt) { // Try to ensure that debugging can find the right location @@ -2139,6 +2150,11 @@ struct EmitVisitor } return; } + else if( auto unparsedStmt = stmt.As<UnparsedStmt>() ) + { + EmitUnparsedStmt(unparsedStmt); + return; + } else if (auto exprStmt = stmt.As<ExpressionStatementSyntaxNode>()) { EmitExpr(exprStmt->Expression); |
