|
1 | 1 | package com.laytonsmith.core.functions; |
2 | 2 |
|
3 | 3 | import com.laytonsmith.PureUtilities.Common.StreamUtils; |
| 4 | +import com.laytonsmith.PureUtilities.Version; |
4 | 5 | import com.laytonsmith.abstraction.Implementation; |
5 | 6 | import com.laytonsmith.annotations.MEnum; |
6 | 7 | import com.laytonsmith.annotations.api; |
7 | 8 | import com.laytonsmith.annotations.core; |
| 9 | +import com.laytonsmith.annotations.hide; |
8 | 10 | import com.laytonsmith.annotations.seealso; |
9 | 11 | import com.laytonsmith.core.CHVersion; |
10 | 12 | import com.laytonsmith.core.ObjectGenerator; |
| 13 | +import com.laytonsmith.core.Optimizable; |
11 | 14 | import com.laytonsmith.core.ParseTree; |
12 | 15 | import com.laytonsmith.core.Prefs; |
13 | 16 | import com.laytonsmith.core.Script; |
14 | 17 | import com.laytonsmith.core.SimpleDocumentation; |
| 18 | +import com.laytonsmith.core.compiler.FileOptions; |
15 | 19 | import com.laytonsmith.core.constructs.CArray; |
16 | 20 | import com.laytonsmith.core.constructs.CClosure; |
17 | 21 | import com.laytonsmith.core.constructs.CNull; |
|
28 | 32 | import com.laytonsmith.core.exceptions.ConfigRuntimeException; |
29 | 33 | import java.util.ArrayList; |
30 | 34 | import java.util.Arrays; |
| 35 | +import java.util.EnumSet; |
31 | 36 | import java.util.List; |
| 37 | +import java.util.Set; |
32 | 38 |
|
33 | 39 | /** |
34 | 40 | * |
@@ -595,4 +601,78 @@ public ExampleScript[] examples() throws ConfigCompileException { |
595 | 601 | } |
596 | 602 |
|
597 | 603 | } |
| 604 | + |
| 605 | + @api |
| 606 | + @hide("In general, this should never be used in the functional syntax, and should only be" |
| 607 | + + " automatically generated by the try keyword.") |
| 608 | + public static class complex_try extends AbstractFunction implements Optimizable { |
| 609 | + |
| 610 | + @Override |
| 611 | + public ExceptionType[] thrown() { |
| 612 | + return new ExceptionType[]{}; |
| 613 | + } |
| 614 | + |
| 615 | + @Override |
| 616 | + public boolean isRestricted() { |
| 617 | + return false; |
| 618 | + } |
| 619 | + |
| 620 | + @Override |
| 621 | + public Boolean runAsync() { |
| 622 | + return null; |
| 623 | + } |
| 624 | + |
| 625 | + @Override |
| 626 | + public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException { |
| 627 | + return CVoid.VOID; |
| 628 | + } |
| 629 | + |
| 630 | + @Override |
| 631 | + public Construct execs(Target t, Environment env, Script parent, ParseTree... nodes) { |
| 632 | + // TODO |
| 633 | + return CVoid.VOID; |
| 634 | + } |
| 635 | + |
| 636 | + @Override |
| 637 | + public String getName() { |
| 638 | + return "complex_try"; |
| 639 | + } |
| 640 | + |
| 641 | + @Override |
| 642 | + public Integer[] numArgs() { |
| 643 | + return new Integer[]{Integer.MAX_VALUE}; |
| 644 | + } |
| 645 | + |
| 646 | + @Override |
| 647 | + public String docs() { |
| 648 | + return "void {tryBlock, [catchVariable, catchBlock]+, [catchBlock]}"; |
| 649 | + } |
| 650 | + |
| 651 | + @Override |
| 652 | + public Version since() { |
| 653 | + return CHVersion.V3_3_1; |
| 654 | + } |
| 655 | + |
| 656 | + @Override |
| 657 | + public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { |
| 658 | + //TODO |
| 659 | + return super.optimizeDynamic(t, children, fileOptions); //To change body of generated methods, choose Tools | Templates. |
| 660 | + } |
| 661 | + |
| 662 | + @Override |
| 663 | + public Set<OptimizationOption> optimizationOptions() { |
| 664 | + return EnumSet.of(OptimizationOption.OPTIMIZE_DYNAMIC); |
| 665 | + } |
| 666 | + |
| 667 | + @Override |
| 668 | + public boolean preResolveVariables() { |
| 669 | + return false; |
| 670 | + } |
| 671 | + |
| 672 | + @Override |
| 673 | + public boolean useSpecialExec() { |
| 674 | + return true; |
| 675 | + } |
| 676 | + |
| 677 | + } |
598 | 678 | } |
0 commit comments