< prev index next >

src/jdk.jshell/share/classes/jdk/jshell/Eval.java

Print this page




 403      * @param diags the failure diagnostics
 404      * @param userSource the incoming bad user source
 405      * @return a rejected snippet event
 406      */
 407     private List<SnippetEvent> compileFailResult(DiagList diags, String userSource) {
 408         ErroneousKey key = state.keyMap.keyForErroneous();
 409         Snippet snip = new ErroneousSnippet(key, userSource, null, SubKind.UNKNOWN_SUBKIND);
 410         snip.setFailed(diags);
 411         state.maps.installSnippet(snip);
 412         return Collections.singletonList(new SnippetEvent(
 413                 snip, Status.NONEXISTENT, Status.REJECTED,
 414                 false, null, null, null)
 415         );
 416     }
 417 
 418     private ExpressionInfo typeOfExpression(String expression) {
 419         Wrap guts = Wrap.methodReturnWrap(expression);
 420         TaskFactory.AnalyzeTask at = trialCompile(guts);
 421         if (!at.hasErrors() && at.firstCuTree() != null) {
 422             return TreeDissector.createByFirstClass(at)
 423                     .typeOfReturnStatement(at.messages(), state.maps::fullClassNameAndPackageToClass);
 424         }
 425         return null;
 426     }
 427 
 428     /**
 429      * Should a temp var wrap the expression. TODO make this user configurable.
 430      *
 431      * @param snippetKind
 432      * @return
 433      */
 434     private boolean shouldGenTempVar(SubKind snippetKind) {
 435         return snippetKind == SubKind.OTHER_EXPRESSION_SUBKIND;
 436     }
 437 
 438     List<SnippetEvent> drop(Snippet si) {
 439         Unit c = new Unit(state, si);
 440 
 441         Set<Unit> ins = c.dependents().collect(toSet());
 442         Set<Unit> outs = compileAndLoad(ins);
 443 




 403      * @param diags the failure diagnostics
 404      * @param userSource the incoming bad user source
 405      * @return a rejected snippet event
 406      */
 407     private List<SnippetEvent> compileFailResult(DiagList diags, String userSource) {
 408         ErroneousKey key = state.keyMap.keyForErroneous();
 409         Snippet snip = new ErroneousSnippet(key, userSource, null, SubKind.UNKNOWN_SUBKIND);
 410         snip.setFailed(diags);
 411         state.maps.installSnippet(snip);
 412         return Collections.singletonList(new SnippetEvent(
 413                 snip, Status.NONEXISTENT, Status.REJECTED,
 414                 false, null, null, null)
 415         );
 416     }
 417 
 418     private ExpressionInfo typeOfExpression(String expression) {
 419         Wrap guts = Wrap.methodReturnWrap(expression);
 420         TaskFactory.AnalyzeTask at = trialCompile(guts);
 421         if (!at.hasErrors() && at.firstCuTree() != null) {
 422             return TreeDissector.createByFirstClass(at)
 423                     .typeOfReturnStatement(at, state);
 424         }
 425         return null;
 426     }
 427 
 428     /**
 429      * Should a temp var wrap the expression. TODO make this user configurable.
 430      *
 431      * @param snippetKind
 432      * @return
 433      */
 434     private boolean shouldGenTempVar(SubKind snippetKind) {
 435         return snippetKind == SubKind.OTHER_EXPRESSION_SUBKIND;
 436     }
 437 
 438     List<SnippetEvent> drop(Snippet si) {
 439         Unit c = new Unit(state, si);
 440 
 441         Set<Unit> ins = c.dependents().collect(toSet());
 442         Set<Unit> outs = compileAndLoad(ins);
 443 


< prev index next >