|
7 | 7 | using TypeCobol.Compiler.Parser; |
8 | 8 | using TypeCobol.Compiler.Preprocessor; |
9 | 9 | using TypeCobol.Compiler.Scanner; |
| 10 | +using TypeCobol.Compiler.Sql.CodeElements; |
10 | 11 | using TypeCobol.Compiler.Sql.CodeElements.Statements; |
11 | 12 | using TypeCobol.Compiler.Sql.Model; |
12 | 13 | using TypeCobol.Compiler.Text; |
@@ -713,6 +714,11 @@ private void DumpObject(string name, object value) |
713 | 714 | SqlObject.DumpProperty(_writer, name, value, 0); |
714 | 715 | } |
715 | 716 |
|
| 717 | + private void DumpString(string name, string value) |
| 718 | + { |
| 719 | + _writer.WriteLine($"- {name} = {value ?? "<NULL>"}"); |
| 720 | + } |
| 721 | + |
716 | 722 | public override bool Visit(SelectStatement selectStatement) |
717 | 723 | { |
718 | 724 | _writer.WriteLine($"line {selectStatement.Line}: {nameof(SelectStatement)}"); |
@@ -835,6 +841,47 @@ public override bool Visit(ExecuteImmediateStatement executeImmediateStatement) |
835 | 841 | DumpObject(nameof(executeImmediateStatement.StatementExpression), executeImmediateStatement.StatementExpression); |
836 | 842 | return true; |
837 | 843 | } |
| 844 | + |
| 845 | + public override bool Visit(InsertStatement insertStatement) |
| 846 | + { |
| 847 | + _writer.WriteLine($"line {insertStatement.Line}: {nameof(InsertStatement)}"); |
| 848 | + DumpString(nameof(insertStatement.TableName), insertStatement.TableName); |
| 849 | + DumpStringList(nameof(insertStatement.Columns), insertStatement.Columns); |
| 850 | + DumpObject(nameof(insertStatement.HasSubselect), insertStatement.HasSubselect); |
| 851 | + DumpHostVariableBindings(insertStatement.HostVariables); |
| 852 | + return true; |
| 853 | + } |
| 854 | + |
| 855 | + public override bool Visit(UnsupportedSqlStatement unsupportedSqlStatement) |
| 856 | + { |
| 857 | + _writer.WriteLine($"line {unsupportedSqlStatement.Line}: {nameof(UnsupportedSqlStatement)}"); |
| 858 | + DumpString(nameof(unsupportedSqlStatement.SqlKeyword), unsupportedSqlStatement.SqlKeyword); |
| 859 | + return true; |
| 860 | + } |
| 861 | + |
| 862 | + private void DumpStringList(string name, IList<string> values) |
| 863 | + { |
| 864 | + if (values == null) |
| 865 | + { |
| 866 | + _writer.WriteLine($"- {name} = <NULL>"); |
| 867 | + return; |
| 868 | + } |
| 869 | + _writer.WriteLine($"- {name} = [{string.Join(", ", values)}]"); |
| 870 | + } |
| 871 | + |
| 872 | + private void DumpHostVariableBindings(IList<HostVariableBinding> bindings, string name = "HostVariables") |
| 873 | + { |
| 874 | + if (bindings == null || bindings.Count == 0) |
| 875 | + { |
| 876 | + _writer.WriteLine($"- {name} = <NONE>"); |
| 877 | + return; |
| 878 | + } |
| 879 | + _writer.WriteLine($"- {name}:"); |
| 880 | + foreach (var b in bindings) |
| 881 | + { |
| 882 | + _writer.WriteLine($" - {b.Direction} {b.VariableName} -> {b.ColumnName ?? "<NULL>"}"); |
| 883 | + } |
| 884 | + } |
838 | 885 | } |
839 | 886 |
|
840 | 887 | public string Format(CompilationUnit compilationResult, IncrementalChangesHistory history) |
|
0 commit comments