idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
31,800
public static String classNameToSignature ( String name ) { int nameLength = name . length ( ) ; int colonPos = 1 + nameLength ; char [ ] buf = new char [ colonPos + 1 ] ; buf [ 0 ] = 'L' ; buf [ colonPos ] = ';' ; name . getChars ( 0 , nameLength , buf , 1 ) ; for ( int i = 1 ; i != colonPos ; ++ i ) { if ( buf [ i ] ...
Convert Java class name in dot notation into Lname - with - dots - replaced - by - slashes ; form suitable for use as JVM type signatures .
31,801
public void addVariableDescriptor ( String name , String type , int startPC , int register ) { int nameIndex = itsConstantPool . addUtf8 ( name ) ; int descriptorIndex = itsConstantPool . addUtf8 ( type ) ; int [ ] chunk = { nameIndex , descriptorIndex , startPC , register } ; if ( itsVarDescriptors == null ) { itsVarD...
Add Information about java variable to use when generating the local variable table .
31,802
public void startMethod ( String methodName , String type , short flags ) { short methodNameIndex = itsConstantPool . addUtf8 ( methodName ) ; short typeIndex = itsConstantPool . addUtf8 ( type ) ; itsCurrentMethod = new ClassFileMethod ( methodName , methodNameIndex , type , typeIndex , flags ) ; itsJumpFroms = new Ui...
Add a method and begin adding code .
31,803
public void add ( int theOpCode ) { if ( opcodeCount ( theOpCode ) != 0 ) throw new IllegalArgumentException ( "Unexpected operands" ) ; int newStack = itsStackTop + stackChange ( theOpCode ) ; if ( newStack < 0 || Short . MAX_VALUE < newStack ) badStack ( newStack ) ; if ( DEBUGCODE ) System . out . println ( "Add " +...
Add the single - byte opcode to the current method .
31,804
public void addLoadConstant ( int k ) { switch ( k ) { case 0 : add ( ByteCode . ICONST_0 ) ; break ; case 1 : add ( ByteCode . ICONST_1 ) ; break ; case 2 : add ( ByteCode . ICONST_2 ) ; break ; case 3 : add ( ByteCode . ICONST_3 ) ; break ; case 4 : add ( ByteCode . ICONST_4 ) ; break ; case 5 : add ( ByteCode . ICON...
Generate the load constant bytecode for the given integer .
31,805
public void add ( int theOpCode , int theOperand1 , int theOperand2 ) { if ( DEBUGCODE ) { System . out . println ( "Add " + bytecodeStr ( theOpCode ) + ", " + Integer . toHexString ( theOperand1 ) + ", " + Integer . toHexString ( theOperand2 ) ) ; } int newStack = itsStackTop + stackChange ( theOpCode ) ; if ( newStac...
Add the given two - operand bytecode to the current method .
31,806
public void addPush ( int k ) { if ( ( byte ) k == k ) { if ( k == - 1 ) { add ( ByteCode . ICONST_M1 ) ; } else if ( 0 <= k && k <= 5 ) { add ( ( byte ) ( ByteCode . ICONST_0 + k ) ) ; } else { add ( ByteCode . BIPUSH , ( byte ) k ) ; } } else if ( ( short ) k == k ) { add ( ByteCode . SIPUSH , ( short ) k ) ; } else ...
Generate code to load the given integer on stack .
31,807
public void addPush ( long k ) { int ik = ( int ) k ; if ( ik == k ) { addPush ( ik ) ; add ( ByteCode . I2L ) ; } else { addLoadConstant ( k ) ; } }
Generate code to load the given long on stack .
31,808
public void addPush ( double k ) { if ( k == 0.0 ) { add ( ByteCode . DCONST_0 ) ; if ( 1.0 / k < 0 ) { add ( ByteCode . DNEG ) ; } } else if ( k == 1.0 || k == - 1.0 ) { add ( ByteCode . DCONST_1 ) ; if ( k < 0 ) { add ( ByteCode . DNEG ) ; } } else { addLoadConstant ( k ) ; } }
Generate code to load the given double on stack .
31,809
public void addPush ( String k ) { int length = k . length ( ) ; int limit = itsConstantPool . getUtfEncodingLimit ( k , 0 , length ) ; if ( limit == length ) { addLoadConstant ( k ) ; return ; } final String SB = "java/lang/StringBuilder" ; add ( ByteCode . NEW , SB ) ; add ( ByteCode . DUP ) ; addPush ( length ) ; ad...
Generate the code to leave on stack the given string even if the string encoding exeeds the class file limit for single string constant
31,810
public void setTableSwitchJump ( int switchStart , int caseIndex , int jumpTarget ) { if ( jumpTarget < 0 || itsCodeBufferTop < jumpTarget ) throw new IllegalArgumentException ( "Bad jump target: " + jumpTarget ) ; if ( caseIndex < - 1 ) throw new IllegalArgumentException ( "Bad case index: " + caseIndex ) ; int padSiz...
Set a jump case for a tableswitch instruction . The jump target should be marked as a super block start for stack map generation .
31,811
private static char arrayTypeToName ( int type ) { switch ( type ) { case ByteCode . T_BOOLEAN : return 'Z' ; case ByteCode . T_CHAR : return 'C' ; case ByteCode . T_FLOAT : return 'F' ; case ByteCode . T_DOUBLE : return 'D' ; case ByteCode . T_BYTE : return 'B' ; case ByteCode . T_SHORT : return 'S' ; case ByteCode . ...
Convert a newarray operand into an internal type .
31,812
private static String descriptorToInternalName ( String descriptor ) { switch ( descriptor . charAt ( 0 ) ) { case 'B' : case 'C' : case 'D' : case 'F' : case 'I' : case 'J' : case 'S' : case 'Z' : case 'V' : case '[' : return descriptor ; case 'L' : return classDescriptorToInternalName ( descriptor ) ; default : throw...
Convert a non - method type descriptor into an internal type .
31,813
private int [ ] createInitialLocals ( ) { int [ ] initialLocals = new int [ itsMaxLocals ] ; int localsTop = 0 ; if ( ( itsCurrentMethod . getFlags ( ) & ACC_STATIC ) == 0 ) { if ( "<init>" . equals ( itsCurrentMethod . getName ( ) ) ) { initialLocals [ localsTop ++ ] = TypeInfo . UNINITIALIZED_THIS ; } else { initialL...
Compute the initial local variable array for the current method .
31,814
private void addSuperBlockStart ( int pc ) { if ( GenerateStackMap ) { if ( itsSuperBlockStarts == null ) { itsSuperBlockStarts = new int [ SuperBlockStartsSize ] ; } else if ( itsSuperBlockStarts . length == itsSuperBlockStartsTop ) { int [ ] tmp = new int [ itsSuperBlockStartsTop * 2 ] ; System . arraycopy ( itsSuper...
Add a pc as the start of super block .
31,815
private void finalizeSuperBlockStarts ( ) { if ( GenerateStackMap ) { for ( int i = 0 ; i < itsExceptionTableTop ; i ++ ) { ExceptionTableEntry ete = itsExceptionTable [ i ] ; int handlerPC = getLabelPC ( ete . itsHandlerLabel ) ; addSuperBlockStart ( handlerPC ) ; } Arrays . sort ( itsSuperBlockStarts , 0 , itsSuperBl...
Sort the list of recorded super block starts and remove duplicates .
31,816
public void setVariables ( List < VariableInitializer > variables ) { assertNotNull ( variables ) ; this . variables . clear ( ) ; for ( VariableInitializer vi : variables ) { addVariable ( vi ) ; } }
Sets variable list
31,817
public void addVariable ( VariableInitializer v ) { assertNotNull ( v ) ; variables . add ( v ) ; v . setParent ( this ) ; }
Adds a variable initializer node to the child list . Sets initializer node s parent to this node .
31,818
public org . mozilla . javascript . Node setType ( int type ) { if ( type != Token . VAR && type != Token . CONST && type != Token . LET ) throw new IllegalArgumentException ( "invalid decl type: " + type ) ; return super . setType ( type ) ; }
Sets the node type and returns this node .
31,819
void addStrictWarning ( String messageId , String messageArg ) { int beg = - 1 , end = - 1 ; if ( ts != null ) { beg = ts . tokenBeg ; end = ts . tokenEnd - ts . tokenBeg ; } addStrictWarning ( messageId , messageArg , beg , end ) ; }
Add a strict warning on the last matched token .
31,820
private int peekToken ( ) throws IOException { if ( currentFlaggedToken != Token . EOF ) { return currentToken ; } int lineno = ts . getLineno ( ) ; int tt = ts . getToken ( ) ; boolean sawEOL = false ; while ( tt == Token . EOL || tt == Token . COMMENT ) { if ( tt == Token . EOL ) { lineno ++ ; sawEOL = true ; tt = ts...
The flags if any are saved in currentFlaggedToken .
31,821
public AstRoot parse ( String sourceString , String sourceURI , int lineno ) { if ( parseFinished ) throw new IllegalStateException ( "parser reused" ) ; this . sourceURI = sourceURI ; if ( compilerEnv . isIdeMode ( ) ) { this . sourceChars = sourceString . toCharArray ( ) ; } this . ts = new TokenStream ( this , null ...
Builds a parse tree from the given source string .
31,822
public AstRoot parse ( Reader sourceReader , String sourceURI , int lineno ) throws IOException { if ( parseFinished ) throw new IllegalStateException ( "parser reused" ) ; if ( compilerEnv . isIdeMode ( ) ) { return parse ( readFully ( sourceReader ) , sourceURI , lineno ) ; } try { this . sourceURI = sourceURI ; ts =...
Builds a parse tree from the given sourcereader .
31,823
private AstNode statements ( AstNode parent ) throws IOException { if ( currentToken != Token . LC && ! compilerEnv . isIdeMode ( ) ) codeBug ( ) ; int pos = ts . tokenBeg ; AstNode block = parent != null ? parent : new Block ( pos ) ; block . setLineno ( ts . lineno ) ; int tt ; while ( ( tt = peekToken ( ) ) > Token ...
node are given relative start positions and correct lengths .
31,824
private ConditionData condition ( ) throws IOException { ConditionData data = new ConditionData ( ) ; if ( mustMatchToken ( Token . LP , "msg.no.paren.cond" , true ) ) data . lp = ts . tokenBeg ; data . condition = expr ( ) ; if ( mustMatchToken ( Token . RP , "msg.no.paren.after.cond" , true ) ) data . rp = ts . token...
parse and return a parenthesized expression
31,825
private static final boolean nowAllSet ( int before , int after , int mask ) { return ( ( before & mask ) != mask ) && ( ( after & mask ) == mask ) ; }
Returns whether or not the bits in the mask have changed to all set .
31,826
private VariableDeclaration variables ( int declType , int pos , boolean isStatement ) throws IOException { int end ; VariableDeclaration pn = new VariableDeclaration ( pos ) ; pn . setType ( declType ) ; pn . setLineno ( ts . lineno ) ; Comment varjsdocNode = getAndResetJsDoc ( ) ; if ( varjsdocNode != null ) { pn . s...
Parse a var or const statement or a var init list in a for statement .
31,827
private AstNode let ( boolean isStatement , int pos ) throws IOException { LetNode pn = new LetNode ( pos ) ; pn . setLineno ( ts . lineno ) ; if ( mustMatchToken ( Token . LP , "msg.no.paren.after.let" , true ) ) pn . setLp ( ts . tokenBeg - pos ) ; pushScope ( pn ) ; try { VariableDeclaration vars = variables ( Token...
have to pass in let kwd position to compute kid offsets properly
31,828
private AstNode propertyAccess ( int tt , AstNode pn ) throws IOException { if ( pn == null ) codeBug ( ) ; int memberTypeFlags = 0 , lineno = ts . lineno , dotPos = ts . tokenBeg ; consumeToken ( ) ; if ( tt == Token . DOTDOT ) { mustHaveXML ( ) ; memberTypeFlags = Node . DESCENDANTS_FLAG ; } if ( ! compilerEnv . isXm...
Handles any construct following a . or .. operator .
31,829
private AstNode arrayComprehension ( AstNode result , int pos ) throws IOException { List < ArrayComprehensionLoop > loops = new ArrayList < ArrayComprehensionLoop > ( ) ; while ( peekToken ( ) == Token . FOR ) { loops . add ( arrayComprehensionLoop ( ) ) ; } int ifPos = - 1 ; ConditionData data = null ; if ( peekToken...
Parse a JavaScript 1 . 7 Array comprehension .
31,830
private int lineBeginningFor ( int pos ) { if ( sourceChars == null ) { return - 1 ; } if ( pos <= 0 ) { return 0 ; } char [ ] buf = sourceChars ; if ( pos >= buf . length ) { pos = buf . length - 1 ; } while ( -- pos >= 0 ) { char c = buf [ pos ] ; if ( ScriptRuntime . isJSLineTerminator ( c ) ) { return pos + 1 ; } }...
Return the file offset of the beginning of the input source line containing the passed position .
31,831
Node createDestructuringAssignment ( int type , Node left , Node right ) { String tempName = currentScriptOrFn . getNextTempName ( ) ; Node result = destructuringAssignmentHelper ( type , left , right , tempName ) ; Node comma = result . getLastChild ( ) ; comma . addChildToBack ( createName ( tempName ) ) ; return res...
Given a destructuring assignment with a left hand side parsed as an array or object literal and a right hand side expression rewrite as a series of assignments to the variables defined in left from property accesses to the expression on the right .
31,832
protected Node simpleAssignment ( Node left , Node right ) { int nodeType = left . getType ( ) ; switch ( nodeType ) { case Token . NAME : String name = ( ( Name ) left ) . getIdentifier ( ) ; if ( inUseStrictDirective && ( "eval" . equals ( name ) || "arguments" . equals ( name ) ) ) { reportError ( "msg.bad.id.strict...
side effects in the RHS .
31,833
protected AstNode removeParens ( AstNode node ) { while ( node instanceof ParenthesizedExpression ) { node = ( ( ParenthesizedExpression ) node ) . getExpression ( ) ; } return node ; }
remove any ParenthesizedExpression wrappers
31,834
private RuntimeException codeBug ( ) throws RuntimeException { throw Kit . codeBug ( "ts.cursor=" + ts . cursor + ", ts.tokenBeg=" + ts . tokenBeg + ", currentToken=" + currentToken ) ; }
throw a failed - assertion with some helpful debugging info
31,835
protected Iterator < ? > getJavaIterator ( Context cx , Scriptable scope , Object obj ) { if ( obj instanceof Wrapper ) { Object unwrapped = ( ( Wrapper ) obj ) . unwrap ( ) ; Iterator < ? > iterator = null ; if ( unwrapped instanceof Iterator ) iterator = ( Iterator < ? > ) unwrapped ; if ( unwrapped instanceof Iterab...
If obj is a java . util . Iterator or a java . lang . Iterable return a wrapping as a JavaScript Iterator . Otherwise return null . This method is in VMBridge since Iterable is a JDK 1 . 5 addition .
31,836
public void visit ( NodeVisitor v ) { if ( v . visit ( this ) ) { getTarget ( ) . visit ( v ) ; getProperty ( ) . visit ( v ) ; } }
Visits this node the target expression and the property name .
31,837
public void visit ( NodeVisitor v ) { if ( v . visit ( this ) ) { body . visit ( v ) ; condition . visit ( v ) ; } }
Visits this node the body and then the while - expression .
31,838
static Object create ( Context cx , Class < ? > cl , ScriptableObject object ) { if ( ! cl . isInterface ( ) ) throw new IllegalArgumentException ( ) ; Scriptable topScope = ScriptRuntime . getTopCallScope ( cx ) ; ClassCache cache = ClassCache . get ( topScope ) ; InterfaceAdapter adapter ; adapter = ( InterfaceAdapte...
Make glue object implementing interface cl that will call the supplied JS function when called . Only interfaces were all methods have the same signature is supported .
31,839
public void visit ( NodeVisitor v ) { if ( ! v . visit ( this ) ) { return ; } result . visit ( v ) ; for ( ArrayComprehensionLoop loop : loops ) { loop . visit ( v ) ; } if ( filter != null ) { filter . visit ( v ) ; } }
Visits this node the result expression the loops and the optional filter .
31,840
public void setExpression ( AstNode expression ) { assertNotNull ( expression ) ; expr = expression ; expression . setParent ( this ) ; setLineno ( expression . getLineno ( ) ) ; }
Sets the wrapped expression and sets its parent to this node .
31,841
public void setLeft ( AstNode left ) { assertNotNull ( left ) ; this . left = left ; setLineno ( left . getLineno ( ) ) ; left . setParent ( this ) ; }
Sets the left - hand side of the expression and sets its parent to this node .
31,842
public void visit ( NodeVisitor v ) { if ( v . visit ( this ) ) { left . visit ( v ) ; right . visit ( v ) ; } }
Visits this node the left operand and the right operand .
31,843
public static double toNumber ( Object val ) { for ( ; ; ) { if ( val instanceof Number ) return ( ( Number ) val ) . doubleValue ( ) ; if ( val == null ) return + 0.0 ; if ( val == Undefined . instance ) return NaN ; if ( val instanceof String ) return toNumber ( ( String ) val ) ; if ( val instanceof CharSequence ) r...
Convert the value to a number .
31,844
public static Object [ ] padArguments ( Object [ ] args , int count ) { if ( count < args . length ) return args ; int i ; Object [ ] result = new Object [ count ] ; for ( i = 0 ; i < args . length ; i ++ ) { result [ i ] = args [ i ] ; } for ( ; i < count ; i ++ ) { result [ i ] = Undefined . instance ; } return resul...
Helper function for builtin objects that use the varargs form . ECMA function formal arguments are undefined if not supplied ; this function pads the argument array out to the expected length if necessary .
31,845
public static String escapeString ( String s , char escapeQuote ) { if ( ! ( escapeQuote == '"' || escapeQuote == '\'' || escapeQuote == '`' ) ) Kit . codeBug ( ) ; StringBuilder sb = null ; for ( int i = 0 , L = s . length ( ) ; i != L ; ++ i ) { int c = s . charAt ( i ) ; if ( ' ' <= c && c <= '~' && c != escapeQuote...
For escaping strings printed by object and array literals ; not quite the same as escape .
31,846
public static Scriptable toObject ( Context cx , Scriptable scope , Object val ) { if ( val == null ) { throw typeError0 ( "msg.null.to.object" ) ; } if ( Undefined . isUndefined ( val ) ) { throw typeError0 ( "msg.undef.to.object" ) ; } if ( isSymbol ( val ) ) { NativeSymbol result = new NativeSymbol ( ( NativeSymbol ...
Convert the value to an object .
31,847
public static long indexFromString ( String str ) { final int MAX_VALUE_LENGTH = 10 ; int len = str . length ( ) ; if ( len > 0 ) { int i = 0 ; boolean negate = false ; int c = str . charAt ( 0 ) ; if ( c == '-' ) { if ( len > 1 ) { c = str . charAt ( 1 ) ; if ( c == '0' ) return - 1L ; i = 1 ; negate = true ; } } c -=...
Return - 1L if str is not an index or the index value as lower 32 bits of the result . Note that the result needs to be cast to an int in order to produce the actual index which may be negative .
31,848
static Object getIndexObject ( String s ) { long indexTest = indexFromString ( s ) ; if ( indexTest >= 0 ) { return Integer . valueOf ( ( int ) indexTest ) ; } return s ; }
If s represents index then return index value wrapped as Integer and othewise return s .
31,849
static Object getIndexObject ( double d ) { int i = ( int ) d ; if ( i == d ) { return Integer . valueOf ( i ) ; } return toString ( d ) ; }
If d is exact int value return its value wrapped as Integer and othewise return d converted to String .
31,850
public static Object name ( Context cx , Scriptable scope , String name ) { Scriptable parent = scope . getParentScope ( ) ; if ( parent == null ) { Object result = topScopeName ( cx , scope , name ) ; if ( result == Scriptable . NOT_FOUND ) { throw notFoundError ( scope , name ) ; } return result ; } return nameOrFunc...
Looks up a name in the scope chain and returns its value .
31,851
public static Scriptable bind ( Context cx , Scriptable scope , String id ) { Scriptable firstXMLObject = null ; Scriptable parent = scope . getParentScope ( ) ; childScopesChecks : if ( parent != null ) { while ( scope instanceof NativeWith ) { Scriptable withObj = scope . getPrototype ( ) ; if ( withObj instanceof XM...
Returns the object in the scope chain that has a given property .
31,852
public static Object enumInit ( Object value , Context cx , boolean enumValues ) { return enumInit ( value , cx , enumValues ? ENUMERATE_VALUES : ENUMERATE_KEYS ) ; }
For backwards compatibility with generated class files
31,853
public static Scriptable newObject ( Object fun , Context cx , Scriptable scope , Object [ ] args ) { if ( ! ( fun instanceof Function ) ) { throw notFunctionError ( fun ) ; } Function function = ( Function ) fun ; return function . construct ( cx , scope , args ) ; }
Operator new .
31,854
public static Object applyOrCall ( boolean isApply , Context cx , Scriptable scope , Scriptable thisObj , Object [ ] args ) { int L = args . length ; Callable function = getCallable ( thisObj ) ; Scriptable callThis = null ; if ( L != 0 ) { if ( cx . hasFeature ( Context . FEATURE_OLD_UNDEF_NULL_THIS ) ) { callThis = t...
Function . prototype . apply and Function . prototype . call
31,855
public static Object evalSpecial ( Context cx , Scriptable scope , Object thisArg , Object [ ] args , String filename , int lineNumber ) { if ( args . length < 1 ) return Undefined . instance ; Object x = args [ 0 ] ; if ( ! ( x instanceof CharSequence ) ) { if ( cx . hasFeature ( Context . FEATURE_STRICT_MODE ) || cx ...
The eval function property of the global object .
31,856
public static String typeof ( Object value ) { if ( value == null ) return "object" ; if ( value == Undefined . instance ) return "undefined" ; if ( value instanceof ScriptableObject ) return ( ( ScriptableObject ) value ) . getTypeOf ( ) ; if ( value instanceof Scriptable ) return ( value instanceof Callable ) ? "func...
The typeof operator
31,857
public static String typeofName ( Scriptable scope , String id ) { Context cx = Context . getContext ( ) ; Scriptable val = bind ( cx , scope , id ) ; if ( val == null ) return "undefined" ; return typeof ( getObjectProp ( val , id , cx ) ) ; }
The typeof operator that correctly handles the undefined case
31,858
public static Object nameIncrDecr ( Scriptable scopeChain , String id , int incrDecrMask ) { return nameIncrDecr ( scopeChain , id , Context . getContext ( ) , incrDecrMask ) ; }
The method is only present for compatibility .
31,859
public static boolean sameZero ( Object x , Object y ) { if ( ! typeof ( x ) . equals ( typeof ( y ) ) ) { return false ; } if ( x instanceof Number ) { if ( isNaN ( x ) && isNaN ( y ) ) { return true ; } final double dx = ( ( Number ) x ) . doubleValue ( ) ; if ( y instanceof Number ) { final double dy = ( ( Number ) ...
Implement SameValueZero from ECMA 7 . 2 . 9
31,860
public static boolean instanceOf ( Object a , Object b , Context cx ) { if ( ! ( b instanceof Scriptable ) ) { throw typeError0 ( "msg.instanceof.not.object" ) ; } if ( ! ( a instanceof Scriptable ) ) return false ; return ( ( Scriptable ) b ) . hasInstance ( ( Scriptable ) a ) ; }
The instanceof operator .
31,861
public static boolean in ( Object a , Object b , Context cx ) { if ( ! ( b instanceof Scriptable ) ) { throw typeError0 ( "msg.in.not.object" ) ; } return hasObjectElem ( ( Scriptable ) b , a , cx ) ; }
The in operator .
31,862
public static String escapeAttributeValue ( Object value , Context cx ) { XMLLib xmlLib = currentXMLLib ( cx ) ; return xmlLib . escapeAttributeValue ( value ) ; }
Escapes the reserved characters in a value of an attribute
31,863
static boolean isSymbol ( Object obj ) { return ( ( ( obj instanceof NativeSymbol ) && ( ( NativeSymbol ) obj ) . isSymbol ( ) ) ) || ( obj instanceof SymbolKey ) ; }
Not all NativeSymbol instances are actually symbols . So account for that here rather than just by using an instanceof check .
31,864
private static void writeMember ( ObjectOutputStream out , Executable member ) throws IOException { if ( member == null ) { out . writeBoolean ( false ) ; return ; } out . writeBoolean ( true ) ; if ( ! ( member instanceof Method || member instanceof Constructor ) ) throw new IllegalArgumentException ( "not Method or C...
Writes a Constructor or Method object .
31,865
private static Executable readMember ( ObjectInputStream in ) throws IOException , ClassNotFoundException { if ( ! in . readBoolean ( ) ) return null ; boolean isMethod = in . readBoolean ( ) ; String name = ( String ) in . readObject ( ) ; Class < ? > declaring = ( Class < ? > ) in . readObject ( ) ; Class < ? > [ ] p...
Reads a Method or a Constructor from the stream .
31,866
private static void writeParameters ( ObjectOutputStream out , Class < ? > [ ] parms ) throws IOException { out . writeShort ( parms . length ) ; outer : for ( int i = 0 ; i < parms . length ; i ++ ) { Class < ? > parm = parms [ i ] ; boolean primitive = parm . isPrimitive ( ) ; out . writeBoolean ( primitive ) ; if ( ...
Writes an array of parameter types to the stream .
31,867
private static Class < ? > [ ] readParameters ( ObjectInputStream in ) throws IOException , ClassNotFoundException { Class < ? > [ ] result = new Class [ in . readShort ( ) ] ; for ( int i = 0 ; i < result . length ; i ++ ) { if ( ! in . readBoolean ( ) ) { result [ i ] = ( Class < ? > ) in . readObject ( ) ; continue ...
Reads an array of parameter types from the stream .
31,868
public void attachTo ( ContextFactory factory ) { detach ( ) ; this . contextFactory = factory ; this . listener = new DimIProxy ( this , IPROXY_LISTEN ) ; factory . addListener ( this . listener ) ; }
Attaches the debugger to the given ContextFactory .
31,869
public void detach ( ) { if ( listener != null ) { contextFactory . removeListener ( listener ) ; contextFactory = null ; listener = null ; } }
Detaches the debugger from the current ContextFactory .
31,870
private FunctionSource getFunctionSource ( DebuggableScript fnOrScript ) { FunctionSource fsource = functionSource ( fnOrScript ) ; if ( fsource == null ) { String url = getNormalizedUrl ( fnOrScript ) ; SourceInfo si = sourceInfo ( url ) ; if ( si == null ) { if ( ! fnOrScript . isGeneratedScript ( ) ) { String source...
Returns the FunctionSource object for the given script or function .
31,871
private String loadSource ( String sourceUrl ) { String source = null ; int hash = sourceUrl . indexOf ( '#' ) ; if ( hash >= 0 ) { sourceUrl = sourceUrl . substring ( 0 , hash ) ; } try { InputStream is ; openStream : { if ( sourceUrl . indexOf ( ':' ) < 0 ) { try { if ( sourceUrl . startsWith ( "~/" ) ) { String home...
Loads the script at the given URL .
31,872
private void registerTopScript ( DebuggableScript topScript , String source ) { if ( ! topScript . isTopLevel ( ) ) { throw new IllegalArgumentException ( ) ; } String url = getNormalizedUrl ( topScript ) ; DebuggableScript [ ] functions = getAllFunctions ( topScript ) ; if ( sourceProvider != null ) { final String pro...
Registers the given script as a top - level script in the debugger .
31,873
private String getNormalizedUrl ( DebuggableScript fnOrScript ) { String url = fnOrScript . getSourceName ( ) ; if ( url == null ) { url = "<stdin>" ; } else { char evalSeparator = '#' ; StringBuilder sb = null ; int urlLength = url . length ( ) ; int cursor = 0 ; for ( ; ; ) { int searchStart = url . indexOf ( evalSep...
Returns the source URL for the given script or function .
31,874
private static DebuggableScript [ ] getAllFunctions ( DebuggableScript function ) { ObjArray functions = new ObjArray ( ) ; collectFunctions_r ( function , functions ) ; DebuggableScript [ ] result = new DebuggableScript [ functions . size ( ) ] ; functions . toArray ( result ) ; return result ; }
Returns an array of all functions in the given script .
31,875
private void handleBreakpointHit ( StackFrame frame , Context cx ) { breakFlag = false ; interrupted ( cx , frame , null ) ; }
Called when a breakpoint has been hit .
31,876
private void handleExceptionThrown ( Context cx , Throwable ex , StackFrame frame ) { if ( breakOnExceptions ) { ContextData cd = frame . contextData ( ) ; if ( cd . lastProcessedException != ex ) { interrupted ( cx , frame , ex ) ; cd . lastProcessedException = ex ; } } }
Called when a script exception has been thrown .
31,877
public void compileScript ( String url , String text ) { DimIProxy action = new DimIProxy ( this , IPROXY_COMPILE_SCRIPT ) ; action . url = url ; action . text = text ; action . withContext ( ) ; }
Compiles the given script .
31,878
public String objectToString ( Object object ) { DimIProxy action = new DimIProxy ( this , IPROXY_OBJECT_TO_STRING ) ; action . object = object ; action . withContext ( ) ; return action . stringResult ; }
Converts the given script object to a string .
31,879
public boolean stringIsCompilableUnit ( String str ) { DimIProxy action = new DimIProxy ( this , IPROXY_STRING_IS_COMPILABLE ) ; action . text = str ; action . withContext ( ) ; return action . booleanResult ; }
Returns whether the given string is syntactically valid script .
31,880
private static String do_eval ( Context cx , StackFrame frame , String expr ) { String resultString ; Debugger saved_debugger = cx . getDebugger ( ) ; Object saved_data = cx . getDebuggerContextData ( ) ; int saved_level = cx . getOptimizationLevel ( ) ; cx . setDebugger ( null , null ) ; cx . setOptimizationLevel ( - ...
Evaluates script in the given stack frame .
31,881
public void setDeclType ( int declType ) { if ( ! ( declType == Token . FUNCTION || declType == Token . LP || declType == Token . VAR || declType == Token . LET || declType == Token . CONST ) ) throw new IllegalArgumentException ( "Invalid declType: " + declType ) ; this . declType = declType ; }
Sets symbol declaration type
31,882
public boolean associate ( ScriptableObject topScope ) { if ( topScope . getParentScope ( ) != null ) { throw new IllegalArgumentException ( ) ; } if ( this == topScope . associateValue ( AKEY , this ) ) { associatedScope = topScope ; return true ; } return false ; }
Associate ClassCache object with the given top - level scope . The ClassCache object can only be associated with the given scope once .
31,883
public static Object varargs ( Context cx , Scriptable thisObj , Object [ ] args , Function funObj ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( "this = " ) ; buf . append ( Context . toString ( thisObj ) ) ; buf . append ( "; args = [" ) ; for ( int i = 0 ; i < args . length ; i ++ ) { buf . append ( ...
An example of a variable - arguments method .
31,884
private Scriptable makeIteratorResult ( Context cx , Scriptable scope , boolean done , Object value ) { Scriptable iteratorResult = cx . newObject ( scope ) ; ScriptableObject . putProperty ( iteratorResult , VALUE_PROPERTY , value ) ; ScriptableObject . putProperty ( iteratorResult , DONE_PROPERTY , done ) ; return it...
25 . 1 . 1 . 3 The IteratorResult Interface
31,885
void subtract ( DiyFp other ) { assert ( e == other . e ) ; assert uint64_gte ( f , other . f ) ; f -= other . f ; }
The result will not be normalized .
31,886
static DiyFp minus ( DiyFp a , DiyFp b ) { DiyFp result = new DiyFp ( a . f , a . e ) ; result . subtract ( b ) ; return result ; }
than other . The result will not be normalized .
31,887
public void setCases ( List < SwitchCase > cases ) { if ( cases == null ) { this . cases = null ; } else { if ( this . cases != null ) this . cases . clear ( ) ; for ( SwitchCase sc : cases ) addCase ( sc ) ; } }
Sets case statement list and sets the parent of each child case to this node .
31,888
public void addCase ( SwitchCase switchCase ) { assertNotNull ( switchCase ) ; if ( cases == null ) { cases = new ArrayList < SwitchCase > ( ) ; } cases . add ( switchCase ) ; switchCase . setParent ( this ) ; }
Adds a switch case statement to the end of the list .
31,889
public void visit ( NodeVisitor v ) { if ( v . visit ( this ) ) { expression . visit ( v ) ; for ( SwitchCase sc : getCases ( ) ) { sc . visit ( v ) ; } } }
Visits this node then the switch - expression then the cases in lexical order .
31,890
public ScriptNode transformTree ( AstRoot root ) { currentScriptOrFn = root ; this . inUseStrictDirective = root . isInStrictMode ( ) ; int sourceStartOffset = decompiler . getCurrentOffset ( ) ; if ( Token . printTrees ) { System . out . println ( "IRFactory.transformTree" ) ; System . out . println ( root . debugPrin...
Transforms the tree into a lower - level IR suitable for codegen . Optionally generates the encoded source .
31,891
private Node transformXmlRef ( XmlRef node ) { int memberTypeFlags = node . isAttributeAccess ( ) ? Node . ATTRIBUTE_FLAG : 0 ; return transformXmlRef ( null , node , memberTypeFlags ) ; }
We get here if we weren t a child of a . or .. infix node
31,892
private void addSwitchCase ( Node switchBlock , Node caseExpression , Node statements ) { if ( switchBlock . getType ( ) != Token . BLOCK ) throw Kit . codeBug ( ) ; Jump switchNode = ( Jump ) switchBlock . getFirstChild ( ) ; if ( switchNode . getType ( ) != Token . SWITCH ) throw Kit . codeBug ( ) ; Node gotoTarget =...
If caseExpression argument is null it indicates a default label .
31,893
private Scope createLoopNode ( Node loopLabel , int lineno ) { Scope result = createScopeNode ( Token . LOOP , lineno ) ; if ( loopLabel != null ) { ( ( Jump ) loopLabel ) . setLoop ( result ) ; } return result ; }
Create loop node . The code generator will later call createWhile|createDoWhile|createFor|createForIn to finish loop generation .
31,894
private Node createForIn ( int declType , Node loop , Node lhs , Node obj , Node body , boolean isForEach , boolean isForOf ) { int destructuring = - 1 ; int destructuringLen = 0 ; Node lvalue ; int type = lhs . getType ( ) ; if ( type == Token . VAR || type == Token . LET ) { Node kid = lhs . getLastChild ( ) ; int ki...
Generate IR for a for .. in loop .
31,895
private static int isAlwaysDefinedBoolean ( Node node ) { switch ( node . getType ( ) ) { case Token . FALSE : case Token . NULL : return ALWAYS_FALSE_BOOLEAN ; case Token . TRUE : return ALWAYS_TRUE_BOOLEAN ; case Token . NUMBER : { double num = node . getDouble ( ) ; if ( num == num && num != 0.0 ) { return ALWAYS_TR...
Check if Node always mean true or false in boolean context
31,896
static InterpretedFunction createScript ( InterpreterData idata , Object staticSecurityDomain ) { InterpretedFunction f ; f = new InterpretedFunction ( idata , staticSecurityDomain ) ; return f ; }
Create script from compiled bytecode .
31,897
static InterpretedFunction createFunction ( Context cx , Scriptable scope , InterpretedFunction parent , int index ) { InterpretedFunction f = new InterpretedFunction ( parent , index ) ; f . initScriptFunction ( cx , scope ) ; return f ; }
Create function embedded in script or another function .
31,898
public Object call ( Context cx , Scriptable scope , Scriptable thisObj , Object [ ] args ) { if ( ! ScriptRuntime . hasTopCall ( cx ) ) { return ScriptRuntime . doTopCall ( this , cx , scope , thisObj , args , idata . isStrict ) ; } return Interpreter . interpret ( this , cx , scope , thisObj , args ) ; }
Calls the function .
31,899
public void setElements ( List < ObjectProperty > elements ) { if ( elements == null ) { this . elements = null ; } else { if ( this . elements != null ) this . elements . clear ( ) ; for ( ObjectProperty o : elements ) addElement ( o ) ; } }
Sets the element list and updates the parent of each element . Replaces any existing elements .