src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java

Print this page




 115         this.allocatorClassName = allocatorClassName;
 116         this.allocatorMap       = allocatorMap;
 117     }
 118 
 119     @Override
 120     String toSource() {
 121         if (source != null && token != 0) {
 122             return source.getString(Token.descPosition(token), Token.descLength(token));
 123         }
 124 
 125         return "function " + (name == null ? "" : name) + "() { [native code] }";
 126     }
 127 
 128     @Override
 129     public String toString() {
 130         final StringBuilder sb = new StringBuilder();
 131 
 132         if (source != null) {
 133             sb.append(source.getName())
 134                 .append(':')
 135                 .append(source.getLine(Token.descPosition(token)))
 136                 .append(' ');
 137         }
 138 
 139         return sb.toString() + super.toString();
 140     }
 141 
 142     private static long tokenFor(final FunctionNode fn) {
 143         final int  position   = Token.descPosition(fn.getFirstToken());
 144         final int  length     = Token.descPosition(fn.getLastToken()) - position + Token.descLength(fn.getLastToken());
 145 
 146         return Token.toDesc(TokenType.FUNCTION, position, length);
 147     }
 148 
 149     @Override
 150     ScriptObject allocate() {
 151         try {
 152             ensureHasAllocator(); //if allocatorClass name is set to null (e.g. for bound functions) we don't even try
 153             return allocator == null ? null : (ScriptObject)allocator.invokeExact(allocatorMap);
 154         } catch (final RuntimeException | Error e) {
 155             throw e;




 115         this.allocatorClassName = allocatorClassName;
 116         this.allocatorMap       = allocatorMap;
 117     }
 118 
 119     @Override
 120     String toSource() {
 121         if (source != null && token != 0) {
 122             return source.getString(Token.descPosition(token), Token.descLength(token));
 123         }
 124 
 125         return "function " + (name == null ? "" : name) + "() { [native code] }";
 126     }
 127 
 128     @Override
 129     public String toString() {
 130         final StringBuilder sb = new StringBuilder();
 131 
 132         if (source != null) {
 133             sb.append(source.getName())
 134                 .append(':')
 135                 .append(functionNode.getLineNumber())
 136                 .append(' ');
 137         }
 138 
 139         return sb.toString() + super.toString();
 140     }
 141 
 142     private static long tokenFor(final FunctionNode fn) {
 143         final int  position   = Token.descPosition(fn.getFirstToken());
 144         final int  length     = Token.descPosition(fn.getLastToken()) - position + Token.descLength(fn.getLastToken());
 145 
 146         return Token.toDesc(TokenType.FUNCTION, position, length);
 147     }
 148 
 149     @Override
 150     ScriptObject allocate() {
 151         try {
 152             ensureHasAllocator(); //if allocatorClass name is set to null (e.g. for bound functions) we don't even try
 153             return allocator == null ? null : (ScriptObject)allocator.invokeExact(allocatorMap);
 154         } catch (final RuntimeException | Error e) {
 155             throw e;