|
30 | 30 | import org.enso.compiler.core.IR$Module$Scope$Import$Module;
|
31 | 31 | import org.enso.compiler.core.IR$Module$Scope$Import$Polyglot;
|
32 | 32 | import org.enso.compiler.core.IR$Module$Scope$Import$Polyglot$Java;
|
| 33 | +import org.enso.compiler.core.IR$Name$Annotation; |
33 | 34 | import org.enso.compiler.core.IR$Name$Blank;
|
34 | 35 | import org.enso.compiler.core.IR$Name$Literal;
|
35 | 36 | import org.enso.compiler.core.IR$Name$MethodReference;
|
@@ -151,6 +152,12 @@ IR.Module translateModule(Tree module) {
|
151 | 152 | var t = translateComment(app);
|
152 | 153 | bindings = cons(t, bindings);
|
153 | 154 | }
|
| 155 | + case Tree.Annotated anno -> { |
| 156 | + var n = new IR$Name$Annotation("@" + anno.getAnnotation().codeRepr(), getIdentifiedLocation(anno), meta(), diag()); |
| 157 | + bindings = cons(n, bindings); |
| 158 | + var t = translateModuleSymbol(anno.getExpression()); |
| 159 | + bindings = cons(t, bindings); |
| 160 | + } |
154 | 161 | case null -> {
|
155 | 162 | }
|
156 | 163 | default -> {
|
@@ -404,7 +411,7 @@ case Left(reason) =>
|
404 | 411 | }
|
405 | 412 | */
|
406 | 413 | }
|
407 |
| - default -> new IR$Error$Syntax(inputAst, new IR$Error$Syntax$UnexpectedExpression$(), meta(), diag()); |
| 414 | + default -> new IR$Error$Syntax(inputAst, new IR$Error$Syntax$UnexpectedExpression$(), meta(), diag()); |
408 | 415 | };
|
409 | 416 | }
|
410 | 417 |
|
@@ -817,6 +824,10 @@ yield switch (ast) {
|
817 | 824 | case Tree.Wildcard wild -> {
|
818 | 825 | yield new IR$Name$Blank(getIdentifiedLocation(wild), meta(), diag());
|
819 | 826 | }
|
| 827 | + case Tree.Annotated anno -> { |
| 828 | + var ir = new IR$Name$Annotation("@" + anno.getAnnotation().codeRepr(), getIdentifiedLocation(anno), meta(), diag()); |
| 829 | + yield translateAnnotation(ir, anno.getExpression(), nil()); |
| 830 | + } |
820 | 831 | default -> throw new UnhandledEntity(tree, "translateExpression");
|
821 | 832 | };
|
822 | 833 | /*
|
@@ -947,6 +958,30 @@ yield switch (ast) {
|
947 | 958 | */
|
948 | 959 | }
|
949 | 960 |
|
| 961 | + private IR$Application$Prefix translateAnnotation(IR$Name$Annotation ir, Tree expr, List<IR.CallArgument> callArgs) { |
| 962 | + boolean insideTypeSignature = false; |
| 963 | + return switch (expr) { |
| 964 | + case Tree.App fn -> { |
| 965 | + var fnAsArg = translateCallArgument(fn.getArg(), insideTypeSignature); |
| 966 | + yield translateAnnotation(ir, fn.getFunc(), cons(fnAsArg, callArgs)); |
| 967 | + } |
| 968 | + case Tree.ArgumentBlockApplication fn -> { |
| 969 | + var fnAsArg = translateCallArgument(fn.getLhs(), insideTypeSignature); |
| 970 | + var arg = translateCallArgument(expr, insideTypeSignature); |
| 971 | + callArgs = cons(fnAsArg, cons(arg, callArgs)); |
| 972 | + yield translateAnnotation(ir, null, callArgs); |
| 973 | + } |
| 974 | + case null -> { |
| 975 | + yield new IR$Application$Prefix(ir, callArgs, false, ir.location(), meta(), diag()); |
| 976 | + } |
| 977 | + default -> { |
| 978 | + var arg = translateCallArgument(expr, insideTypeSignature); |
| 979 | + callArgs = cons(arg, callArgs); |
| 980 | + yield translateAnnotation(ir, null, callArgs); |
| 981 | + } |
| 982 | + }; |
| 983 | + } |
| 984 | + |
950 | 985 | IR.Expression translateDecimalLiteral(Tree.Number ast) {
|
951 | 986 | return translateDecimalLiteral(ast, ast.getInteger(), ast.getFractionalDigits());
|
952 | 987 | }
|
|
0 commit comments