id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
21,300
mozilla/rhino
src/org/mozilla/javascript/BaseFunction.java
BaseFunction.setImmunePrototypeProperty
public void setImmunePrototypeProperty(Object value) { if ((prototypePropertyAttributes & READONLY) != 0) { throw new IllegalStateException(); } prototypeProperty = (value != null) ? value : UniqueTag.NULL_VALUE; prototypePropertyAttributes = DONTENUM | PERMANENT | READONLY; }
java
public void setImmunePrototypeProperty(Object value) { if ((prototypePropertyAttributes & READONLY) != 0) { throw new IllegalStateException(); } prototypeProperty = (value != null) ? value : UniqueTag.NULL_VALUE; prototypePropertyAttributes = DONTENUM | PERMANENT | READONLY; }
[ "public", "void", "setImmunePrototypeProperty", "(", "Object", "value", ")", "{", "if", "(", "(", "prototypePropertyAttributes", "&", "READONLY", ")", "!=", "0", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "prototypeProperty", "=", "(", "value", "!=", "null", ")", "?", "value", ":", "UniqueTag", ".", "NULL_VALUE", ";", "prototypePropertyAttributes", "=", "DONTENUM", "|", "PERMANENT", "|", "READONLY", ";", "}" ]
Make value as DontEnum, DontDelete, ReadOnly prototype property of this Function object
[ "Make", "value", "as", "DontEnum", "DontDelete", "ReadOnly", "prototype", "property", "of", "this", "Function", "object" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/BaseFunction.java#L328-L335
21,301
mozilla/rhino
src/org/mozilla/javascript/BaseFunction.java
BaseFunction.call
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { return Undefined.instance; }
java
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { return Undefined.instance; }
[ "@", "Override", "public", "Object", "call", "(", "Context", "cx", ",", "Scriptable", "scope", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ")", "{", "return", "Undefined", ".", "instance", ";", "}" ]
Should be overridden.
[ "Should", "be", "overridden", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/BaseFunction.java#L349-L354
21,302
mozilla/rhino
src/org/mozilla/javascript/EqualObjectGraphs.java
EqualObjectGraphs.getSortedIds
private static Object[] getSortedIds(final Scriptable s) { final Object[] ids = getIds(s); Arrays.sort(ids, (a, b) -> { if (a instanceof Integer) { if (b instanceof Integer) { return ((Integer)a).compareTo((Integer)b); } else if (b instanceof String || b instanceof Symbol) { return -1; // ints before strings or symbols } } else if (a instanceof String) { if (b instanceof String) { return ((String)a).compareTo((String)b); } else if (b instanceof Integer) { return 1; // strings after ints } else if (b instanceof Symbol) { return -1; // strings before symbols } } else if (a instanceof Symbol) { if (b instanceof Symbol) { // As long as people bother to reasonably name their symbols, // this will work. If there's clashes in symbol names (e.g. // lots of unnamed symbols) it can lead to false inequalities. return getSymbolName((Symbol)a).compareTo(getSymbolName((Symbol)b)); } else if (b instanceof Integer || b instanceof String) { return 1; // symbols after ints and strings } } // We can only compare Rhino key types: Integer, String, Symbol throw new ClassCastException(); }); return ids; }
java
private static Object[] getSortedIds(final Scriptable s) { final Object[] ids = getIds(s); Arrays.sort(ids, (a, b) -> { if (a instanceof Integer) { if (b instanceof Integer) { return ((Integer)a).compareTo((Integer)b); } else if (b instanceof String || b instanceof Symbol) { return -1; // ints before strings or symbols } } else if (a instanceof String) { if (b instanceof String) { return ((String)a).compareTo((String)b); } else if (b instanceof Integer) { return 1; // strings after ints } else if (b instanceof Symbol) { return -1; // strings before symbols } } else if (a instanceof Symbol) { if (b instanceof Symbol) { // As long as people bother to reasonably name their symbols, // this will work. If there's clashes in symbol names (e.g. // lots of unnamed symbols) it can lead to false inequalities. return getSymbolName((Symbol)a).compareTo(getSymbolName((Symbol)b)); } else if (b instanceof Integer || b instanceof String) { return 1; // symbols after ints and strings } } // We can only compare Rhino key types: Integer, String, Symbol throw new ClassCastException(); }); return ids; }
[ "private", "static", "Object", "[", "]", "getSortedIds", "(", "final", "Scriptable", "s", ")", "{", "final", "Object", "[", "]", "ids", "=", "getIds", "(", "s", ")", ";", "Arrays", ".", "sort", "(", "ids", ",", "(", "a", ",", "b", ")", "->", "{", "if", "(", "a", "instanceof", "Integer", ")", "{", "if", "(", "b", "instanceof", "Integer", ")", "{", "return", "(", "(", "Integer", ")", "a", ")", ".", "compareTo", "(", "(", "Integer", ")", "b", ")", ";", "}", "else", "if", "(", "b", "instanceof", "String", "||", "b", "instanceof", "Symbol", ")", "{", "return", "-", "1", ";", "// ints before strings or symbols", "}", "}", "else", "if", "(", "a", "instanceof", "String", ")", "{", "if", "(", "b", "instanceof", "String", ")", "{", "return", "(", "(", "String", ")", "a", ")", ".", "compareTo", "(", "(", "String", ")", "b", ")", ";", "}", "else", "if", "(", "b", "instanceof", "Integer", ")", "{", "return", "1", ";", "// strings after ints", "}", "else", "if", "(", "b", "instanceof", "Symbol", ")", "{", "return", "-", "1", ";", "// strings before symbols", "}", "}", "else", "if", "(", "a", "instanceof", "Symbol", ")", "{", "if", "(", "b", "instanceof", "Symbol", ")", "{", "// As long as people bother to reasonably name their symbols,", "// this will work. If there's clashes in symbol names (e.g.", "// lots of unnamed symbols) it can lead to false inequalities.", "return", "getSymbolName", "(", "(", "Symbol", ")", "a", ")", ".", "compareTo", "(", "getSymbolName", "(", "(", "Symbol", ")", "b", ")", ")", ";", "}", "else", "if", "(", "b", "instanceof", "Integer", "||", "b", "instanceof", "String", ")", "{", "return", "1", ";", "// symbols after ints and strings", "}", "}", "// We can only compare Rhino key types: Integer, String, Symbol", "throw", "new", "ClassCastException", "(", ")", ";", "}", ")", ";", "return", "ids", ";", "}" ]
Sort IDs deterministically
[ "Sort", "IDs", "deterministically" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/EqualObjectGraphs.java#L255-L286
21,303
mozilla/rhino
src/org/mozilla/javascript/ObjToIntMap.java
ObjToIntMap.intern
public Object intern(Object keyArg) { boolean nullKey = false; if (keyArg == null) { nullKey = true; keyArg = UniqueTag.NULL_VALUE; } int index = ensureIndex(keyArg); values[index] = 0; return (nullKey) ? null : keys[index]; }
java
public Object intern(Object keyArg) { boolean nullKey = false; if (keyArg == null) { nullKey = true; keyArg = UniqueTag.NULL_VALUE; } int index = ensureIndex(keyArg); values[index] = 0; return (nullKey) ? null : keys[index]; }
[ "public", "Object", "intern", "(", "Object", "keyArg", ")", "{", "boolean", "nullKey", "=", "false", ";", "if", "(", "keyArg", "==", "null", ")", "{", "nullKey", "=", "true", ";", "keyArg", "=", "UniqueTag", ".", "NULL_VALUE", ";", "}", "int", "index", "=", "ensureIndex", "(", "keyArg", ")", ";", "values", "[", "index", "]", "=", "0", ";", "return", "(", "nullKey", ")", "?", "null", ":", "keys", "[", "index", "]", ";", "}" ]
If table already contains a key that equals to keyArg, return that key while setting its value to zero, otherwise add keyArg with 0 value to the table and return it.
[ "If", "table", "already", "contains", "a", "key", "that", "equals", "to", "keyArg", "return", "that", "key", "while", "setting", "its", "value", "to", "zero", "otherwise", "add", "keyArg", "with", "0", "value", "to", "the", "table", "and", "return", "it", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ObjToIntMap.java#L159-L168
21,304
mozilla/rhino
src/org/mozilla/javascript/ast/IfStatement.java
IfStatement.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { condition.visit(v); thenPart.visit(v); if (elsePart != null) { elsePart.visit(v); } } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { condition.visit(v); thenPart.visit(v); if (elsePart != null) { elsePart.visit(v); } } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "condition", ".", "visit", "(", "v", ")", ";", "thenPart", ".", "visit", "(", "v", ")", ";", "if", "(", "elsePart", "!=", "null", ")", "{", "elsePart", ".", "visit", "(", "v", ")", ";", "}", "}", "}" ]
Visits this node, the condition, the then-part, and if supplied, the else-part.
[ "Visits", "this", "node", "the", "condition", "the", "then", "-", "part", "and", "if", "supplied", "the", "else", "-", "part", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/IfStatement.java#L189-L198
21,305
mozilla/rhino
src/org/mozilla/javascript/WrapFactory.java
WrapFactory.wrapNewObject
public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
java
public Scriptable wrapNewObject(Context cx, Scriptable scope, Object obj) { if (obj instanceof Scriptable) { return (Scriptable)obj; } Class<?> cls = obj.getClass(); if (cls.isArray()) { return NativeJavaArray.wrap(scope, obj); } return wrapAsJavaObject(cx, scope, obj, null); }
[ "public", "Scriptable", "wrapNewObject", "(", "Context", "cx", ",", "Scriptable", "scope", ",", "Object", "obj", ")", "{", "if", "(", "obj", "instanceof", "Scriptable", ")", "{", "return", "(", "Scriptable", ")", "obj", ";", "}", "Class", "<", "?", ">", "cls", "=", "obj", ".", "getClass", "(", ")", ";", "if", "(", "cls", ".", "isArray", "(", ")", ")", "{", "return", "NativeJavaArray", ".", "wrap", "(", "scope", ",", "obj", ")", ";", "}", "return", "wrapAsJavaObject", "(", "cx", ",", "scope", ",", "obj", ",", "null", ")", ";", "}" ]
Wrap an object newly created by a constructor call. @param cx the current Context for this thread @param scope the scope of the executing script @param obj the object to be wrapped @return the wrapped value.
[ "Wrap", "an", "object", "newly", "created", "by", "a", "constructor", "call", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/WrapFactory.java#L87-L97
21,306
mozilla/rhino
src/org/mozilla/javascript/ast/Loop.java
Loop.setBody
public void setBody(AstNode body) { this.body = body; int end = body.getPosition() + body.getLength(); this.setLength(end - this.getPosition()); body.setParent(this); }
java
public void setBody(AstNode body) { this.body = body; int end = body.getPosition() + body.getLength(); this.setLength(end - this.getPosition()); body.setParent(this); }
[ "public", "void", "setBody", "(", "AstNode", "body", ")", "{", "this", ".", "body", "=", "body", ";", "int", "end", "=", "body", ".", "getPosition", "(", ")", "+", "body", ".", "getLength", "(", ")", ";", "this", ".", "setLength", "(", "end", "-", "this", ".", "getPosition", "(", ")", ")", ";", "body", ".", "setParent", "(", "this", ")", ";", "}" ]
Sets loop body. Sets the parent of the body to this loop node, and updates its offset to be relative. Extends the length of this node to include the body.
[ "Sets", "loop", "body", ".", "Sets", "the", "parent", "of", "the", "body", "to", "this", "loop", "node", "and", "updates", "its", "offset", "to", "be", "relative", ".", "Extends", "the", "length", "of", "this", "node", "to", "include", "the", "body", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/Loop.java#L41-L46
21,307
mozilla/rhino
src/org/mozilla/javascript/NativeContinuation.java
NativeContinuation.equalImplementations
public static boolean equalImplementations(NativeContinuation c1, NativeContinuation c2) { return Objects.equals(c1.implementation, c2.implementation); }
java
public static boolean equalImplementations(NativeContinuation c1, NativeContinuation c2) { return Objects.equals(c1.implementation, c2.implementation); }
[ "public", "static", "boolean", "equalImplementations", "(", "NativeContinuation", "c1", ",", "NativeContinuation", "c2", ")", "{", "return", "Objects", ".", "equals", "(", "c1", ".", "implementation", ",", "c2", ".", "implementation", ")", ";", "}" ]
Returns true if both continuations have equal implementations. @param c1 one continuation @param c2 another continuation @return true if the implementations of both continuations are equal, or they are both null. @throws NullPointerException if either continuation is null
[ "Returns", "true", "if", "both", "continuations", "have", "equal", "implementations", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeContinuation.java#L70-L72
21,308
mozilla/rhino
src/org/mozilla/javascript/NativeJavaPackage.java
NativeJavaPackage.forcePackage
NativeJavaPackage forcePackage(String name, Scriptable scope) { Object cached = super.get(name, this); if (cached != null && cached instanceof NativeJavaPackage) { return (NativeJavaPackage) cached; } String newPackage = packageName.length() == 0 ? name : packageName + "." + name; NativeJavaPackage pkg = new NativeJavaPackage(true, newPackage, classLoader); ScriptRuntime.setObjectProtoAndParent(pkg, scope); super.put(name, this, pkg); return pkg; }
java
NativeJavaPackage forcePackage(String name, Scriptable scope) { Object cached = super.get(name, this); if (cached != null && cached instanceof NativeJavaPackage) { return (NativeJavaPackage) cached; } String newPackage = packageName.length() == 0 ? name : packageName + "." + name; NativeJavaPackage pkg = new NativeJavaPackage(true, newPackage, classLoader); ScriptRuntime.setObjectProtoAndParent(pkg, scope); super.put(name, this, pkg); return pkg; }
[ "NativeJavaPackage", "forcePackage", "(", "String", "name", ",", "Scriptable", "scope", ")", "{", "Object", "cached", "=", "super", ".", "get", "(", "name", ",", "this", ")", ";", "if", "(", "cached", "!=", "null", "&&", "cached", "instanceof", "NativeJavaPackage", ")", "{", "return", "(", "NativeJavaPackage", ")", "cached", ";", "}", "String", "newPackage", "=", "packageName", ".", "length", "(", ")", "==", "0", "?", "name", ":", "packageName", "+", "\".\"", "+", "name", ";", "NativeJavaPackage", "pkg", "=", "new", "NativeJavaPackage", "(", "true", ",", "newPackage", ",", "classLoader", ")", ";", "ScriptRuntime", ".", "setObjectProtoAndParent", "(", "pkg", ",", "scope", ")", ";", "super", ".", "put", "(", "name", ",", "this", ",", "pkg", ")", ";", "return", "pkg", ";", "}" ]
need to look for a class by that name
[ "need", "to", "look", "for", "a", "class", "by", "that", "name" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeJavaPackage.java#L94-L107
21,309
mozilla/rhino
examples/Matrix.java
Matrix.hasInstance
@Override public boolean hasInstance(Scriptable value) { Scriptable proto = value.getPrototype(); while (proto != null) { if (proto.equals(this)) return true; proto = proto.getPrototype(); } return false; }
java
@Override public boolean hasInstance(Scriptable value) { Scriptable proto = value.getPrototype(); while (proto != null) { if (proto.equals(this)) return true; proto = proto.getPrototype(); } return false; }
[ "@", "Override", "public", "boolean", "hasInstance", "(", "Scriptable", "value", ")", "{", "Scriptable", "proto", "=", "value", ".", "getPrototype", "(", ")", ";", "while", "(", "proto", "!=", "null", ")", "{", "if", "(", "proto", ".", "equals", "(", "this", ")", ")", "return", "true", ";", "proto", "=", "proto", ".", "getPrototype", "(", ")", ";", "}", "return", "false", ";", "}" ]
instanceof operator. We mimick the normal JavaScript instanceof semantics, returning true if <code>this</code> appears in <code>value</code>'s prototype chain.
[ "instanceof", "operator", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/examples/Matrix.java#L261-L271
21,310
mozilla/rhino
xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLName.java
XMLName.accept
static boolean accept(Object nameObj) { String name; try { name = ScriptRuntime.toString(nameObj); } catch (EcmaError ee) { if ("TypeError".equals(ee.getName())) { return false; } throw ee; } // See http://w3.org/TR/xml-names11/#NT-NCName int length = name.length(); if (length != 0) { if (isNCNameStartChar(name.charAt(0))) { for (int i = 1; i != length; ++i) { if (!isNCNameChar(name.charAt(i))) { return false; } } return true; } } return false; }
java
static boolean accept(Object nameObj) { String name; try { name = ScriptRuntime.toString(nameObj); } catch (EcmaError ee) { if ("TypeError".equals(ee.getName())) { return false; } throw ee; } // See http://w3.org/TR/xml-names11/#NT-NCName int length = name.length(); if (length != 0) { if (isNCNameStartChar(name.charAt(0))) { for (int i = 1; i != length; ++i) { if (!isNCNameChar(name.charAt(i))) { return false; } } return true; } } return false; }
[ "static", "boolean", "accept", "(", "Object", "nameObj", ")", "{", "String", "name", ";", "try", "{", "name", "=", "ScriptRuntime", ".", "toString", "(", "nameObj", ")", ";", "}", "catch", "(", "EcmaError", "ee", ")", "{", "if", "(", "\"TypeError\"", ".", "equals", "(", "ee", ".", "getName", "(", ")", ")", ")", "{", "return", "false", ";", "}", "throw", "ee", ";", "}", "// See http://w3.org/TR/xml-names11/#NT-NCName", "int", "length", "=", "name", ".", "length", "(", ")", ";", "if", "(", "length", "!=", "0", ")", "{", "if", "(", "isNCNameStartChar", "(", "name", ".", "charAt", "(", "0", ")", ")", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "!=", "length", ";", "++", "i", ")", "{", "if", "(", "!", "isNCNameChar", "(", "name", ".", "charAt", "(", "i", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
See ECMA357 13.1.2.1
[ "See", "ECMA357", "13", ".", "1", ".", "2", ".", "1" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLName.java#L70-L95
21,311
mozilla/rhino
src/org/mozilla/javascript/NativeSet.java
NativeSet.loadFromIterable
static void loadFromIterable(Context cx, Scriptable scope, ScriptableObject set, Object arg1) { if ((arg1 == null) || Undefined.instance.equals(arg1)) { return; } // Call the "[Symbol.iterator]" property as a function. Object ito = ScriptRuntime.callIterator(arg1, cx, scope); if (Undefined.instance.equals(ito)) { // Per spec, ignore if the iterator returns undefined return; } // Find the "add" function of our own prototype, since it might have // been replaced. Since we're not fully constructed yet, create a dummy instance // so that we can get our own prototype. ScriptableObject dummy = ensureScriptableObject(cx.newObject(scope, set.getClassName())); final Callable add = ScriptRuntime.getPropFunctionAndThis(dummy.getPrototype(), "add", cx, scope); // Clean up the value left around by the previous function ScriptRuntime.lastStoredScriptable(cx); // Finally, run through all the iterated values and add them! try (IteratorLikeIterable it = new IteratorLikeIterable(cx, scope, ito)) { for (Object val : it) { final Object finalVal = val == Scriptable.NOT_FOUND ? Undefined.instance : val; add.call(cx, scope, set, new Object[]{finalVal}); } } }
java
static void loadFromIterable(Context cx, Scriptable scope, ScriptableObject set, Object arg1) { if ((arg1 == null) || Undefined.instance.equals(arg1)) { return; } // Call the "[Symbol.iterator]" property as a function. Object ito = ScriptRuntime.callIterator(arg1, cx, scope); if (Undefined.instance.equals(ito)) { // Per spec, ignore if the iterator returns undefined return; } // Find the "add" function of our own prototype, since it might have // been replaced. Since we're not fully constructed yet, create a dummy instance // so that we can get our own prototype. ScriptableObject dummy = ensureScriptableObject(cx.newObject(scope, set.getClassName())); final Callable add = ScriptRuntime.getPropFunctionAndThis(dummy.getPrototype(), "add", cx, scope); // Clean up the value left around by the previous function ScriptRuntime.lastStoredScriptable(cx); // Finally, run through all the iterated values and add them! try (IteratorLikeIterable it = new IteratorLikeIterable(cx, scope, ito)) { for (Object val : it) { final Object finalVal = val == Scriptable.NOT_FOUND ? Undefined.instance : val; add.call(cx, scope, set, new Object[]{finalVal}); } } }
[ "static", "void", "loadFromIterable", "(", "Context", "cx", ",", "Scriptable", "scope", ",", "ScriptableObject", "set", ",", "Object", "arg1", ")", "{", "if", "(", "(", "arg1", "==", "null", ")", "||", "Undefined", ".", "instance", ".", "equals", "(", "arg1", ")", ")", "{", "return", ";", "}", "// Call the \"[Symbol.iterator]\" property as a function.", "Object", "ito", "=", "ScriptRuntime", ".", "callIterator", "(", "arg1", ",", "cx", ",", "scope", ")", ";", "if", "(", "Undefined", ".", "instance", ".", "equals", "(", "ito", ")", ")", "{", "// Per spec, ignore if the iterator returns undefined", "return", ";", "}", "// Find the \"add\" function of our own prototype, since it might have", "// been replaced. Since we're not fully constructed yet, create a dummy instance", "// so that we can get our own prototype.", "ScriptableObject", "dummy", "=", "ensureScriptableObject", "(", "cx", ".", "newObject", "(", "scope", ",", "set", ".", "getClassName", "(", ")", ")", ")", ";", "final", "Callable", "add", "=", "ScriptRuntime", ".", "getPropFunctionAndThis", "(", "dummy", ".", "getPrototype", "(", ")", ",", "\"add\"", ",", "cx", ",", "scope", ")", ";", "// Clean up the value left around by the previous function", "ScriptRuntime", ".", "lastStoredScriptable", "(", "cx", ")", ";", "// Finally, run through all the iterated values and add them!", "try", "(", "IteratorLikeIterable", "it", "=", "new", "IteratorLikeIterable", "(", "cx", ",", "scope", ",", "ito", ")", ")", "{", "for", "(", "Object", "val", ":", "it", ")", "{", "final", "Object", "finalVal", "=", "val", "==", "Scriptable", ".", "NOT_FOUND", "?", "Undefined", ".", "instance", ":", "val", ";", "add", ".", "call", "(", "cx", ",", "scope", ",", "set", ",", "new", "Object", "[", "]", "{", "finalVal", "}", ")", ";", "}", "}", "}" ]
If an "iterable" object was passed to the constructor, there are many many things to do. This is common code with NativeWeakSet.
[ "If", "an", "iterable", "object", "was", "passed", "to", "the", "constructor", "there", "are", "many", "many", "things", "to", "do", ".", "This", "is", "common", "code", "with", "NativeWeakSet", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeSet.java#L155-L184
21,312
mozilla/rhino
src/org/mozilla/javascript/ast/KeywordLiteral.java
KeywordLiteral.setType
@Override public KeywordLiteral setType(int nodeType) { if (!(nodeType == Token.THIS || nodeType == Token.NULL || nodeType == Token.TRUE || nodeType == Token.FALSE || nodeType == Token.DEBUGGER)) throw new IllegalArgumentException("Invalid node type: " + nodeType); type = nodeType; return this; }
java
@Override public KeywordLiteral setType(int nodeType) { if (!(nodeType == Token.THIS || nodeType == Token.NULL || nodeType == Token.TRUE || nodeType == Token.FALSE || nodeType == Token.DEBUGGER)) throw new IllegalArgumentException("Invalid node type: " + nodeType); type = nodeType; return this; }
[ "@", "Override", "public", "KeywordLiteral", "setType", "(", "int", "nodeType", ")", "{", "if", "(", "!", "(", "nodeType", "==", "Token", ".", "THIS", "||", "nodeType", "==", "Token", ".", "NULL", "||", "nodeType", "==", "Token", ".", "TRUE", "||", "nodeType", "==", "Token", ".", "FALSE", "||", "nodeType", "==", "Token", ".", "DEBUGGER", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Invalid node type: \"", "+", "nodeType", ")", ";", "type", "=", "nodeType", ";", "return", "this", ";", "}" ]
Sets node token type @throws IllegalArgumentException if {@code nodeType} is unsupported
[ "Sets", "node", "token", "type" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/KeywordLiteral.java#L47-L58
21,313
mozilla/rhino
src/org/mozilla/javascript/Kit.java
Kit.classOrNull
public static Class<?> classOrNull(ClassLoader loader, String className) { try { return loader.loadClass(className); } catch (ClassNotFoundException ex) { } catch (SecurityException ex) { } catch (LinkageError ex) { } catch (IllegalArgumentException e) { // Can be thrown if name has characters that a class name // can not contain } return null; }
java
public static Class<?> classOrNull(ClassLoader loader, String className) { try { return loader.loadClass(className); } catch (ClassNotFoundException ex) { } catch (SecurityException ex) { } catch (LinkageError ex) { } catch (IllegalArgumentException e) { // Can be thrown if name has characters that a class name // can not contain } return null; }
[ "public", "static", "Class", "<", "?", ">", "classOrNull", "(", "ClassLoader", "loader", ",", "String", "className", ")", "{", "try", "{", "return", "loader", ".", "loadClass", "(", "className", ")", ";", "}", "catch", "(", "ClassNotFoundException", "ex", ")", "{", "}", "catch", "(", "SecurityException", "ex", ")", "{", "}", "catch", "(", "LinkageError", "ex", ")", "{", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "// Can be thrown if name has characters that a class name", "// can not contain", "}", "return", "null", ";", "}" ]
Attempt to load the class of the given name. Note that the type parameter isn't checked.
[ "Attempt", "to", "load", "the", "class", "of", "the", "given", "name", ".", "Note", "that", "the", "type", "parameter", "isn", "t", "checked", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Kit.java#L57-L69
21,314
mozilla/rhino
xmlimplsrc/org/mozilla/javascript/xmlimpl/XML.java
XML.getExtraMethodSource
@Override public Scriptable getExtraMethodSource(Context cx) { if (hasSimpleContent()) { String src = toString(); return ScriptRuntime.toObjectOrNull(cx, src); } return null; }
java
@Override public Scriptable getExtraMethodSource(Context cx) { if (hasSimpleContent()) { String src = toString(); return ScriptRuntime.toObjectOrNull(cx, src); } return null; }
[ "@", "Override", "public", "Scriptable", "getExtraMethodSource", "(", "Context", "cx", ")", "{", "if", "(", "hasSimpleContent", "(", ")", ")", "{", "String", "src", "=", "toString", "(", ")", ";", "return", "ScriptRuntime", ".", "toObjectOrNull", "(", "cx", ",", "src", ")", ";", "}", "return", "null", ";", "}" ]
See ECMA 357, 11_2_2_1, Semantics, 3_f.
[ "See", "ECMA", "357", "11_2_2_1", "Semantics", "3_f", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/xmlimplsrc/org/mozilla/javascript/xmlimpl/XML.java#L198-L205
21,315
mozilla/rhino
src/org/mozilla/javascript/v8dtoa/DoubleHelper.java
DoubleHelper.normalizedBoundaries
static void normalizedBoundaries(long d64, DiyFp m_minus, DiyFp m_plus) { DiyFp v = asDiyFp(d64); boolean significand_is_zero = (v.f() == kHiddenBit); m_plus.setF((v.f() << 1) + 1); m_plus.setE(v.e() - 1); m_plus.normalize(); if (significand_is_zero && v.e() != kDenormalExponent) { // The boundary is closer. Think of v = 1000e10 and v- = 9999e9. // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but // at a distance of 1e8. // The only exception is for the smallest normal: the largest denormal is // at the same distance as its successor. // Note: denormals have the same exponent as the smallest normals. m_minus.setF((v.f() << 2) - 1); m_minus.setE(v.e() - 2); } else { m_minus.setF((v.f() << 1) - 1); m_minus.setE(v.e() - 1); } m_minus.setF(m_minus.f() << (m_minus.e() - m_plus.e())); m_minus.setE(m_plus.e()); }
java
static void normalizedBoundaries(long d64, DiyFp m_minus, DiyFp m_plus) { DiyFp v = asDiyFp(d64); boolean significand_is_zero = (v.f() == kHiddenBit); m_plus.setF((v.f() << 1) + 1); m_plus.setE(v.e() - 1); m_plus.normalize(); if (significand_is_zero && v.e() != kDenormalExponent) { // The boundary is closer. Think of v = 1000e10 and v- = 9999e9. // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but // at a distance of 1e8. // The only exception is for the smallest normal: the largest denormal is // at the same distance as its successor. // Note: denormals have the same exponent as the smallest normals. m_minus.setF((v.f() << 2) - 1); m_minus.setE(v.e() - 2); } else { m_minus.setF((v.f() << 1) - 1); m_minus.setE(v.e() - 1); } m_minus.setF(m_minus.f() << (m_minus.e() - m_plus.e())); m_minus.setE(m_plus.e()); }
[ "static", "void", "normalizedBoundaries", "(", "long", "d64", ",", "DiyFp", "m_minus", ",", "DiyFp", "m_plus", ")", "{", "DiyFp", "v", "=", "asDiyFp", "(", "d64", ")", ";", "boolean", "significand_is_zero", "=", "(", "v", ".", "f", "(", ")", "==", "kHiddenBit", ")", ";", "m_plus", ".", "setF", "(", "(", "v", ".", "f", "(", ")", "<<", "1", ")", "+", "1", ")", ";", "m_plus", ".", "setE", "(", "v", ".", "e", "(", ")", "-", "1", ")", ";", "m_plus", ".", "normalize", "(", ")", ";", "if", "(", "significand_is_zero", "&&", "v", ".", "e", "(", ")", "!=", "kDenormalExponent", ")", "{", "// The boundary is closer. Think of v = 1000e10 and v- = 9999e9.", "// Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but", "// at a distance of 1e8.", "// The only exception is for the smallest normal: the largest denormal is", "// at the same distance as its successor.", "// Note: denormals have the same exponent as the smallest normals.", "m_minus", ".", "setF", "(", "(", "v", ".", "f", "(", ")", "<<", "2", ")", "-", "1", ")", ";", "m_minus", ".", "setE", "(", "v", ".", "e", "(", ")", "-", "2", ")", ";", "}", "else", "{", "m_minus", ".", "setF", "(", "(", "v", ".", "f", "(", ")", "<<", "1", ")", "-", "1", ")", ";", "m_minus", ".", "setE", "(", "v", ".", "e", "(", ")", "-", "1", ")", ";", "}", "m_minus", ".", "setF", "(", "m_minus", ".", "f", "(", ")", "<<", "(", "m_minus", ".", "e", "(", ")", "-", "m_plus", ".", "e", "(", ")", ")", ")", ";", "m_minus", ".", "setE", "(", "m_plus", ".", "e", "(", ")", ")", ";", "}" ]
exponent as m_plus.
[ "exponent", "as", "m_plus", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/v8dtoa/DoubleHelper.java#L110-L131
21,316
mozilla/rhino
src/org/mozilla/javascript/ContextFactory.java
ContextFactory.initGlobal
public synchronized static void initGlobal(ContextFactory factory) { if (factory == null) { throw new IllegalArgumentException(); } if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; global = factory; }
java
public synchronized static void initGlobal(ContextFactory factory) { if (factory == null) { throw new IllegalArgumentException(); } if (hasCustomGlobal) { throw new IllegalStateException(); } hasCustomGlobal = true; global = factory; }
[ "public", "synchronized", "static", "void", "initGlobal", "(", "ContextFactory", "factory", ")", "{", "if", "(", "factory", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "if", "(", "hasCustomGlobal", ")", "{", "throw", "new", "IllegalStateException", "(", ")", ";", "}", "hasCustomGlobal", "=", "true", ";", "global", "=", "factory", ";", "}" ]
Set global ContextFactory. The method can only be called once. @see #getGlobal() @see #hasExplicitGlobal()
[ "Set", "global", "ContextFactory", ".", "The", "method", "can", "only", "be", "called", "once", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ContextFactory.java#L170-L180
21,317
mozilla/rhino
src/org/mozilla/javascript/ContextFactory.java
ContextFactory.initApplicationClassLoader
public final void initApplicationClassLoader(ClassLoader loader) { if (loader == null) throw new IllegalArgumentException("loader is null"); if (!Kit.testIfCanLoadRhinoClasses(loader)) throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); if (this.applicationClassLoader != null) throw new IllegalStateException( "applicationClassLoader can only be set once"); checkNotSealed(); this.applicationClassLoader = loader; }
java
public final void initApplicationClassLoader(ClassLoader loader) { if (loader == null) throw new IllegalArgumentException("loader is null"); if (!Kit.testIfCanLoadRhinoClasses(loader)) throw new IllegalArgumentException( "Loader can not resolve Rhino classes"); if (this.applicationClassLoader != null) throw new IllegalStateException( "applicationClassLoader can only be set once"); checkNotSealed(); this.applicationClassLoader = loader; }
[ "public", "final", "void", "initApplicationClassLoader", "(", "ClassLoader", "loader", ")", "{", "if", "(", "loader", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"loader is null\"", ")", ";", "if", "(", "!", "Kit", ".", "testIfCanLoadRhinoClasses", "(", "loader", ")", ")", "throw", "new", "IllegalArgumentException", "(", "\"Loader can not resolve Rhino classes\"", ")", ";", "if", "(", "this", ".", "applicationClassLoader", "!=", "null", ")", "throw", "new", "IllegalStateException", "(", "\"applicationClassLoader can only be set once\"", ")", ";", "checkNotSealed", "(", ")", ";", "this", ".", "applicationClassLoader", "=", "loader", ";", "}" ]
Set explicit class loader to use when searching for Java classes. @see #getApplicationClassLoader()
[ "Set", "explicit", "class", "loader", "to", "use", "when", "searching", "for", "Java", "classes", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ContextFactory.java#L382-L396
21,318
mozilla/rhino
src/org/mozilla/javascript/ContextFactory.java
ContextFactory.doTopCall
protected Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { Object result = callable.call(cx, scope, thisObj, args); return result instanceof ConsString ? result.toString() : result; }
java
protected Object doTopCall(Callable callable, Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { Object result = callable.call(cx, scope, thisObj, args); return result instanceof ConsString ? result.toString() : result; }
[ "protected", "Object", "doTopCall", "(", "Callable", "callable", ",", "Context", "cx", ",", "Scriptable", "scope", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ")", "{", "Object", "result", "=", "callable", ".", "call", "(", "cx", ",", "scope", ",", "thisObj", ",", "args", ")", ";", "return", "result", "instanceof", "ConsString", "?", "result", ".", "toString", "(", ")", ":", "result", ";", "}" ]
Execute top call to script or function. When the runtime is about to execute a script or function that will create the first stack frame with scriptable code, it calls this method to perform the real call. In this way execution of any script happens inside this function.
[ "Execute", "top", "call", "to", "script", "or", "function", ".", "When", "the", "runtime", "is", "about", "to", "execute", "a", "script", "or", "function", "that", "will", "create", "the", "first", "stack", "frame", "with", "scriptable", "code", "it", "calls", "this", "method", "to", "perform", "the", "real", "call", ".", "In", "this", "way", "execution", "of", "any", "script", "happens", "inside", "this", "function", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ContextFactory.java#L405-L411
21,319
mozilla/rhino
src/org/mozilla/javascript/EmbeddedSlotMap.java
EmbeddedSlotMap.query
@Override public ScriptableObject.Slot query(Object key, int index) { if (slots == null) { return null; } final int indexOrHash = (key != null ? key.hashCode() : index); final int slotIndex = getSlotIndex(slots.length, indexOrHash); for (ScriptableObject.Slot slot = slots[slotIndex]; slot != null; slot = slot.next) { Object skey = slot.name; if (indexOrHash == slot.indexOrHash && (skey == key || (key != null && key.equals(skey)))) { return slot; } } return null; }
java
@Override public ScriptableObject.Slot query(Object key, int index) { if (slots == null) { return null; } final int indexOrHash = (key != null ? key.hashCode() : index); final int slotIndex = getSlotIndex(slots.length, indexOrHash); for (ScriptableObject.Slot slot = slots[slotIndex]; slot != null; slot = slot.next) { Object skey = slot.name; if (indexOrHash == slot.indexOrHash && (skey == key || (key != null && key.equals(skey)))) { return slot; } } return null; }
[ "@", "Override", "public", "ScriptableObject", ".", "Slot", "query", "(", "Object", "key", ",", "int", "index", ")", "{", "if", "(", "slots", "==", "null", ")", "{", "return", "null", ";", "}", "final", "int", "indexOrHash", "=", "(", "key", "!=", "null", "?", "key", ".", "hashCode", "(", ")", ":", "index", ")", ";", "final", "int", "slotIndex", "=", "getSlotIndex", "(", "slots", ".", "length", ",", "indexOrHash", ")", ";", "for", "(", "ScriptableObject", ".", "Slot", "slot", "=", "slots", "[", "slotIndex", "]", ";", "slot", "!=", "null", ";", "slot", "=", "slot", ".", "next", ")", "{", "Object", "skey", "=", "slot", ".", "name", ";", "if", "(", "indexOrHash", "==", "slot", ".", "indexOrHash", "&&", "(", "skey", "==", "key", "||", "(", "key", "!=", "null", "&&", "key", ".", "equals", "(", "skey", ")", ")", ")", ")", "{", "return", "slot", ";", "}", "}", "return", "null", ";", "}" ]
Locate the slot with the given name or index.
[ "Locate", "the", "slot", "with", "the", "given", "name", "or", "index", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/EmbeddedSlotMap.java#L78-L98
21,320
mozilla/rhino
src/org/mozilla/javascript/EmbeddedSlotMap.java
EmbeddedSlotMap.get
@Override public ScriptableObject.Slot get(Object key, int index, ScriptableObject.SlotAccess accessType) { if (slots == null && accessType == SlotAccess.QUERY) { return null; } final int indexOrHash = (key != null ? key.hashCode() : index); ScriptableObject.Slot slot = null; if (slots != null) { final int slotIndex = getSlotIndex(slots.length, indexOrHash); for (slot = slots[slotIndex]; slot != null; slot = slot.next) { Object skey = slot.name; if (indexOrHash == slot.indexOrHash && (skey == key || (key != null && key.equals(skey)))) { break; } } switch (accessType) { case QUERY: return slot; case MODIFY: case MODIFY_CONST: if (slot != null) { return slot; } break; case MODIFY_GETTER_SETTER: if (slot instanceof ScriptableObject.GetterSlot) { return slot; } break; case CONVERT_ACCESSOR_TO_DATA: if ( !(slot instanceof ScriptableObject.GetterSlot) ) { return slot; } break; } } // A new slot has to be inserted or the old has to be replaced // by GetterSlot. Time to synchronize. return createSlot(key, indexOrHash, accessType, slot); }
java
@Override public ScriptableObject.Slot get(Object key, int index, ScriptableObject.SlotAccess accessType) { if (slots == null && accessType == SlotAccess.QUERY) { return null; } final int indexOrHash = (key != null ? key.hashCode() : index); ScriptableObject.Slot slot = null; if (slots != null) { final int slotIndex = getSlotIndex(slots.length, indexOrHash); for (slot = slots[slotIndex]; slot != null; slot = slot.next) { Object skey = slot.name; if (indexOrHash == slot.indexOrHash && (skey == key || (key != null && key.equals(skey)))) { break; } } switch (accessType) { case QUERY: return slot; case MODIFY: case MODIFY_CONST: if (slot != null) { return slot; } break; case MODIFY_GETTER_SETTER: if (slot instanceof ScriptableObject.GetterSlot) { return slot; } break; case CONVERT_ACCESSOR_TO_DATA: if ( !(slot instanceof ScriptableObject.GetterSlot) ) { return slot; } break; } } // A new slot has to be inserted or the old has to be replaced // by GetterSlot. Time to synchronize. return createSlot(key, indexOrHash, accessType, slot); }
[ "@", "Override", "public", "ScriptableObject", ".", "Slot", "get", "(", "Object", "key", ",", "int", "index", ",", "ScriptableObject", ".", "SlotAccess", "accessType", ")", "{", "if", "(", "slots", "==", "null", "&&", "accessType", "==", "SlotAccess", ".", "QUERY", ")", "{", "return", "null", ";", "}", "final", "int", "indexOrHash", "=", "(", "key", "!=", "null", "?", "key", ".", "hashCode", "(", ")", ":", "index", ")", ";", "ScriptableObject", ".", "Slot", "slot", "=", "null", ";", "if", "(", "slots", "!=", "null", ")", "{", "final", "int", "slotIndex", "=", "getSlotIndex", "(", "slots", ".", "length", ",", "indexOrHash", ")", ";", "for", "(", "slot", "=", "slots", "[", "slotIndex", "]", ";", "slot", "!=", "null", ";", "slot", "=", "slot", ".", "next", ")", "{", "Object", "skey", "=", "slot", ".", "name", ";", "if", "(", "indexOrHash", "==", "slot", ".", "indexOrHash", "&&", "(", "skey", "==", "key", "||", "(", "key", "!=", "null", "&&", "key", ".", "equals", "(", "skey", ")", ")", ")", ")", "{", "break", ";", "}", "}", "switch", "(", "accessType", ")", "{", "case", "QUERY", ":", "return", "slot", ";", "case", "MODIFY", ":", "case", "MODIFY_CONST", ":", "if", "(", "slot", "!=", "null", ")", "{", "return", "slot", ";", "}", "break", ";", "case", "MODIFY_GETTER_SETTER", ":", "if", "(", "slot", "instanceof", "ScriptableObject", ".", "GetterSlot", ")", "{", "return", "slot", ";", "}", "break", ";", "case", "CONVERT_ACCESSOR_TO_DATA", ":", "if", "(", "!", "(", "slot", "instanceof", "ScriptableObject", ".", "GetterSlot", ")", ")", "{", "return", "slot", ";", "}", "break", ";", "}", "}", "// A new slot has to be inserted or the old has to be replaced", "// by GetterSlot. Time to synchronize.", "return", "createSlot", "(", "key", ",", "indexOrHash", ",", "accessType", ",", "slot", ")", ";", "}" ]
Locate the slot with given name or index. Depending on the accessType parameter and the current slot status, a new slot may be allocated. @param key either a String or a Symbol object that identifies the property @param index index or 0 if slot holds property name.
[ "Locate", "the", "slot", "with", "given", "name", "or", "index", ".", "Depending", "on", "the", "accessType", "parameter", "and", "the", "current", "slot", "status", "a", "new", "slot", "may", "be", "allocated", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/EmbeddedSlotMap.java#L107-L154
21,321
mozilla/rhino
src/org/mozilla/javascript/EmbeddedSlotMap.java
EmbeddedSlotMap.addKnownAbsentSlot
private void addKnownAbsentSlot(ScriptableObject.Slot[] addSlots, ScriptableObject.Slot slot) { final int insertPos = getSlotIndex(addSlots.length, slot.indexOrHash); ScriptableObject.Slot old = addSlots[insertPos]; addSlots[insertPos] = slot; slot.next = old; }
java
private void addKnownAbsentSlot(ScriptableObject.Slot[] addSlots, ScriptableObject.Slot slot) { final int insertPos = getSlotIndex(addSlots.length, slot.indexOrHash); ScriptableObject.Slot old = addSlots[insertPos]; addSlots[insertPos] = slot; slot.next = old; }
[ "private", "void", "addKnownAbsentSlot", "(", "ScriptableObject", ".", "Slot", "[", "]", "addSlots", ",", "ScriptableObject", ".", "Slot", "slot", ")", "{", "final", "int", "insertPos", "=", "getSlotIndex", "(", "addSlots", ".", "length", ",", "slot", ".", "indexOrHash", ")", ";", "ScriptableObject", ".", "Slot", "old", "=", "addSlots", "[", "insertPos", "]", ";", "addSlots", "[", "insertPos", "]", "=", "slot", ";", "slot", ".", "next", "=", "old", ";", "}" ]
Add slot with keys that are known to absent from the table. This is an optimization to use when inserting into empty table, after table growth or during deserialization.
[ "Add", "slot", "with", "keys", "that", "are", "known", "to", "absent", "from", "the", "table", ".", "This", "is", "an", "optimization", "to", "use", "when", "inserting", "into", "empty", "table", "after", "table", "growth", "or", "during", "deserialization", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/EmbeddedSlotMap.java#L343-L349
21,322
mozilla/rhino
src/org/mozilla/classfile/SuperBlock.java
SuperBlock.getTrimmedLocals
int[] getTrimmedLocals() { int last = locals.length - 1; // Exclude all of the trailing TOPs not bound to a DOUBLE/LONG while (last >= 0 && locals[last] == TypeInfo.TOP && !TypeInfo.isTwoWords(locals[last - 1])) { last--; } last++; // Exclude trailing TOPs following a DOUBLE/LONG int size = last; for (int i = 0; i < last; i++) { if (TypeInfo.isTwoWords(locals[i])) { size--; } } int[] copy = new int[size]; for (int i = 0, j = 0; i < size; i++, j++) { copy[i] = locals[j]; if (TypeInfo.isTwoWords(locals[j])) { j++; } } return copy; }
java
int[] getTrimmedLocals() { int last = locals.length - 1; // Exclude all of the trailing TOPs not bound to a DOUBLE/LONG while (last >= 0 && locals[last] == TypeInfo.TOP && !TypeInfo.isTwoWords(locals[last - 1])) { last--; } last++; // Exclude trailing TOPs following a DOUBLE/LONG int size = last; for (int i = 0; i < last; i++) { if (TypeInfo.isTwoWords(locals[i])) { size--; } } int[] copy = new int[size]; for (int i = 0, j = 0; i < size; i++, j++) { copy[i] = locals[j]; if (TypeInfo.isTwoWords(locals[j])) { j++; } } return copy; }
[ "int", "[", "]", "getTrimmedLocals", "(", ")", "{", "int", "last", "=", "locals", ".", "length", "-", "1", ";", "// Exclude all of the trailing TOPs not bound to a DOUBLE/LONG", "while", "(", "last", ">=", "0", "&&", "locals", "[", "last", "]", "==", "TypeInfo", ".", "TOP", "&&", "!", "TypeInfo", ".", "isTwoWords", "(", "locals", "[", "last", "-", "1", "]", ")", ")", "{", "last", "--", ";", "}", "last", "++", ";", "// Exclude trailing TOPs following a DOUBLE/LONG", "int", "size", "=", "last", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "last", ";", "i", "++", ")", "{", "if", "(", "TypeInfo", ".", "isTwoWords", "(", "locals", "[", "i", "]", ")", ")", "{", "size", "--", ";", "}", "}", "int", "[", "]", "copy", "=", "new", "int", "[", "size", "]", ";", "for", "(", "int", "i", "=", "0", ",", "j", "=", "0", ";", "i", "<", "size", ";", "i", "++", ",", "j", "++", ")", "{", "copy", "[", "i", "]", "=", "locals", "[", "j", "]", ";", "if", "(", "TypeInfo", ".", "isTwoWords", "(", "locals", "[", "j", "]", ")", ")", "{", "j", "++", ";", "}", "}", "return", "copy", ";", "}" ]
Get a copy of the super block's locals without any trailing TOP types. This is useful for actual writing stack maps; during the computation of stack map types, all local arrays have the same size; the max locals for the method. In addition, DOUBLE and LONG types have trailing TOP types because they occupy two words. For writing purposes, these are not useful.
[ "Get", "a", "copy", "of", "the", "super", "block", "s", "locals", "without", "any", "trailing", "TOP", "types", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/classfile/SuperBlock.java#L47-L70
21,323
mozilla/rhino
src/org/mozilla/classfile/SuperBlock.java
SuperBlock.mergeState
private boolean mergeState(int[] current, int[] incoming, int size, ConstantPool pool) { boolean changed = false; for (int i = 0; i < size; i++) { int currentType = current[i]; current[i] = TypeInfo.merge(current[i], incoming[i], pool); if (currentType != current[i]) { changed = true; } } return changed; }
java
private boolean mergeState(int[] current, int[] incoming, int size, ConstantPool pool) { boolean changed = false; for (int i = 0; i < size; i++) { int currentType = current[i]; current[i] = TypeInfo.merge(current[i], incoming[i], pool); if (currentType != current[i]) { changed = true; } } return changed; }
[ "private", "boolean", "mergeState", "(", "int", "[", "]", "current", ",", "int", "[", "]", "incoming", ",", "int", "size", ",", "ConstantPool", "pool", ")", "{", "boolean", "changed", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "int", "currentType", "=", "current", "[", "i", "]", ";", "current", "[", "i", "]", "=", "TypeInfo", ".", "merge", "(", "current", "[", "i", "]", ",", "incoming", "[", "i", "]", ",", "pool", ")", ";", "if", "(", "currentType", "!=", "current", "[", "i", "]", ")", "{", "changed", "=", "true", ";", "}", "}", "return", "changed", ";", "}" ]
Merge an operand stack or local variable array with incoming state. They are treated the same way; by this point, it should already be ensured that the array sizes are the same, which is the only additional constraint that is imposed on merging operand stacks (the local variable array is always the same size).
[ "Merge", "an", "operand", "stack", "or", "local", "variable", "array", "with", "incoming", "state", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/classfile/SuperBlock.java#L113-L125
21,324
mozilla/rhino
xmlimplsrc/org/mozilla/javascript/xmlimpl/XmlProcessor.java
XmlProcessor.getDocumentBuilderFromPool
private DocumentBuilder getDocumentBuilderFromPool() throws ParserConfigurationException { DocumentBuilder builder = documentBuilderPool.pollFirst(); if (builder == null){ builder = getDomFactory().newDocumentBuilder(); } builder.setErrorHandler(errorHandler); return builder; }
java
private DocumentBuilder getDocumentBuilderFromPool() throws ParserConfigurationException { DocumentBuilder builder = documentBuilderPool.pollFirst(); if (builder == null){ builder = getDomFactory().newDocumentBuilder(); } builder.setErrorHandler(errorHandler); return builder; }
[ "private", "DocumentBuilder", "getDocumentBuilderFromPool", "(", ")", "throws", "ParserConfigurationException", "{", "DocumentBuilder", "builder", "=", "documentBuilderPool", ".", "pollFirst", "(", ")", ";", "if", "(", "builder", "==", "null", ")", "{", "builder", "=", "getDomFactory", "(", ")", ".", "newDocumentBuilder", "(", ")", ";", "}", "builder", ".", "setErrorHandler", "(", "errorHandler", ")", ";", "return", "builder", ";", "}" ]
Get from pool, or create one without locking, if needed.
[ "Get", "from", "pool", "or", "create", "one", "without", "locking", "if", "needed", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/xmlimplsrc/org/mozilla/javascript/xmlimpl/XmlProcessor.java#L158-L166
21,325
mozilla/rhino
src/org/mozilla/javascript/ast/GeneratorExpressionLoop.java
GeneratorExpressionLoop.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { iterator.visit(v); iteratedObject.visit(v); } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { iterator.visit(v); iteratedObject.visit(v); } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "iterator", ".", "visit", "(", "v", ")", ";", "iteratedObject", ".", "visit", "(", "v", ")", ";", "}", "}" ]
Visits the iterator expression and the iterated object expression. There is no body-expression for this loop type.
[ "Visits", "the", "iterator", "expression", "and", "the", "iterated", "object", "expression", ".", "There", "is", "no", "body", "-", "expression", "for", "this", "loop", "type", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/GeneratorExpressionLoop.java#L56-L62
21,326
mozilla/rhino
src/org/mozilla/javascript/DToA.java
DToA.pow5mult
static BigInteger pow5mult(BigInteger b, int k) { return b.multiply(BigInteger.valueOf(5).pow(k)); }
java
static BigInteger pow5mult(BigInteger b, int k) { return b.multiply(BigInteger.valueOf(5).pow(k)); }
[ "static", "BigInteger", "pow5mult", "(", "BigInteger", "b", ",", "int", "k", ")", "{", "return", "b", ".", "multiply", "(", "BigInteger", ".", "valueOf", "(", "5", ")", ".", "pow", "(", "k", ")", ")", ";", "}" ]
XXXX the C version built a cache of these
[ "XXXX", "the", "C", "version", "built", "a", "cache", "of", "these" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/DToA.java#L413-L416
21,327
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.has
@Override public boolean has(Symbol key, Scriptable start) { return null != slotMap.query(key, 0); }
java
@Override public boolean has(Symbol key, Scriptable start) { return null != slotMap.query(key, 0); }
[ "@", "Override", "public", "boolean", "has", "(", "Symbol", "key", ",", "Scriptable", "start", ")", "{", "return", "null", "!=", "slotMap", ".", "query", "(", "key", ",", "0", ")", ";", "}" ]
A version of "has" that supports symbols.
[ "A", "version", "of", "has", "that", "supports", "symbols", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L440-L444
21,328
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.get
@Override public Object get(Symbol key, Scriptable start) { Slot slot = slotMap.query(key, 0); if (slot == null) { return Scriptable.NOT_FOUND; } return slot.getValue(start); }
java
@Override public Object get(Symbol key, Scriptable start) { Slot slot = slotMap.query(key, 0); if (slot == null) { return Scriptable.NOT_FOUND; } return slot.getValue(start); }
[ "@", "Override", "public", "Object", "get", "(", "Symbol", "key", ",", "Scriptable", "start", ")", "{", "Slot", "slot", "=", "slotMap", ".", "query", "(", "key", ",", "0", ")", ";", "if", "(", "slot", "==", "null", ")", "{", "return", "Scriptable", ".", "NOT_FOUND", ";", "}", "return", "slot", ".", "getValue", "(", "start", ")", ";", "}" ]
Another version of Get that supports Symbol keyed properties.
[ "Another", "version", "of", "Get", "that", "supports", "Symbol", "keyed", "properties", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L493-L501
21,329
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.put
@Override public void put(Symbol key, Scriptable start, Object value) { if (putImpl(key, 0, start, value)) return; if (start == this) throw Kit.codeBug(); ensureSymbolScriptable(start).put(key, start, value); }
java
@Override public void put(Symbol key, Scriptable start, Object value) { if (putImpl(key, 0, start, value)) return; if (start == this) throw Kit.codeBug(); ensureSymbolScriptable(start).put(key, start, value); }
[ "@", "Override", "public", "void", "put", "(", "Symbol", "key", ",", "Scriptable", "start", ",", "Object", "value", ")", "{", "if", "(", "putImpl", "(", "key", ",", "0", ",", "start", ",", "value", ")", ")", "return", ";", "if", "(", "start", "==", "this", ")", "throw", "Kit", ".", "codeBug", "(", ")", ";", "ensureSymbolScriptable", "(", "start", ")", ".", "put", "(", "key", ",", "start", ",", "value", ")", ";", "}" ]
Implementation of put required by SymbolScriptable objects.
[ "Implementation", "of", "put", "required", "by", "SymbolScriptable", "objects", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L561-L569
21,330
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.delete
@Override public void delete(int index) { checkNotSealed(null, index); slotMap.remove(null, index); }
java
@Override public void delete(int index) { checkNotSealed(null, index); slotMap.remove(null, index); }
[ "@", "Override", "public", "void", "delete", "(", "int", "index", ")", "{", "checkNotSealed", "(", "null", ",", "index", ")", ";", "slotMap", ".", "remove", "(", "null", ",", "index", ")", ";", "}" ]
Removes the indexed property from the object. If the property is not found, or it has the PERMANENT attribute, no action is taken. @param index the numeric index for the property
[ "Removes", "the", "indexed", "property", "from", "the", "object", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L594-L599
21,331
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.putConst
@Override public void putConst(String name, Scriptable start, Object value) { if (putConstImpl(name, 0, start, value, READONLY)) return; if (start == this) throw Kit.codeBug(); if (start instanceof ConstProperties) ((ConstProperties)start).putConst(name, start, value); else start.put(name, start, value); }
java
@Override public void putConst(String name, Scriptable start, Object value) { if (putConstImpl(name, 0, start, value, READONLY)) return; if (start == this) throw Kit.codeBug(); if (start instanceof ConstProperties) ((ConstProperties)start).putConst(name, start, value); else start.put(name, start, value); }
[ "@", "Override", "public", "void", "putConst", "(", "String", "name", ",", "Scriptable", "start", ",", "Object", "value", ")", "{", "if", "(", "putConstImpl", "(", "name", ",", "0", ",", "start", ",", "value", ",", "READONLY", ")", ")", "return", ";", "if", "(", "start", "==", "this", ")", "throw", "Kit", ".", "codeBug", "(", ")", ";", "if", "(", "start", "instanceof", "ConstProperties", ")", "(", "(", "ConstProperties", ")", "start", ")", ".", "putConst", "(", "name", ",", "start", ",", "value", ")", ";", "else", "start", ".", "put", "(", "name", ",", "start", ",", "value", ")", ";", "}" ]
Sets the value of the named const property, creating it if need be. If the property was created using defineProperty, the appropriate setter method is called. <p> If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object. @param name the name of the property @param start the object whose property is being set @param value value to set the property to
[ "Sets", "the", "value", "of", "the", "named", "const", "property", "creating", "it", "if", "need", "be", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L626-L637
21,332
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.isConst
@Override public boolean isConst(String name) { Slot slot = slotMap.query(name, 0); if (slot == null) { return false; } return (slot.getAttributes() & (PERMANENT|READONLY)) == (PERMANENT|READONLY); }
java
@Override public boolean isConst(String name) { Slot slot = slotMap.query(name, 0); if (slot == null) { return false; } return (slot.getAttributes() & (PERMANENT|READONLY)) == (PERMANENT|READONLY); }
[ "@", "Override", "public", "boolean", "isConst", "(", "String", "name", ")", "{", "Slot", "slot", "=", "slotMap", ".", "query", "(", "name", ",", "0", ")", ";", "if", "(", "slot", "==", "null", ")", "{", "return", "false", ";", "}", "return", "(", "slot", ".", "getAttributes", "(", ")", "&", "(", "PERMANENT", "|", "READONLY", ")", ")", "==", "(", "PERMANENT", "|", "READONLY", ")", ";", "}" ]
Returns true if the named property is defined as a const on this object. @param name @return true if the named property is defined as a const, false otherwise.
[ "Returns", "true", "if", "the", "named", "property", "is", "defined", "as", "a", "const", "on", "this", "object", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L656-L666
21,333
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.setAttributes
public void setAttributes(String name, int attributes) { checkNotSealed(name, 0); findAttributeSlot(name, 0, SlotAccess.MODIFY).setAttributes(attributes); }
java
public void setAttributes(String name, int attributes) { checkNotSealed(name, 0); findAttributeSlot(name, 0, SlotAccess.MODIFY).setAttributes(attributes); }
[ "public", "void", "setAttributes", "(", "String", "name", ",", "int", "attributes", ")", "{", "checkNotSealed", "(", "name", ",", "0", ")", ";", "findAttributeSlot", "(", "name", ",", "0", ",", "SlotAccess", ".", "MODIFY", ")", ".", "setAttributes", "(", "attributes", ")", ";", "}" ]
Set the attributes of a named property. The property is specified by <code>name</code> as defined for <code>has</code>.<p> The possible attributes are READONLY, DONTENUM, and PERMANENT. Combinations of attributes are expressed by the bitwise OR of attributes. EMPTY is the state of no attributes set. Any unused bits are reserved for future use. @param name the name of the property @param attributes the bitset of attributes @exception EvaluatorException if the named property is not found @see org.mozilla.javascript.Scriptable#has(String, Scriptable) @see org.mozilla.javascript.ScriptableObject#READONLY @see org.mozilla.javascript.ScriptableObject#DONTENUM @see org.mozilla.javascript.ScriptableObject#PERMANENT @see org.mozilla.javascript.ScriptableObject#EMPTY
[ "Set", "the", "attributes", "of", "a", "named", "property", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L775-L779
21,334
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.setAttributes
public void setAttributes(int index, int attributes) { checkNotSealed(null, index); findAttributeSlot(null, index, SlotAccess.MODIFY).setAttributes(attributes); }
java
public void setAttributes(int index, int attributes) { checkNotSealed(null, index); findAttributeSlot(null, index, SlotAccess.MODIFY).setAttributes(attributes); }
[ "public", "void", "setAttributes", "(", "int", "index", ",", "int", "attributes", ")", "{", "checkNotSealed", "(", "null", ",", "index", ")", ";", "findAttributeSlot", "(", "null", ",", "index", ",", "SlotAccess", ".", "MODIFY", ")", ".", "setAttributes", "(", "attributes", ")", ";", "}" ]
Set the attributes of an indexed property. @param index the numeric index for the property @param attributes the bitset of attributes @exception EvaluatorException if the named property is not found @see org.mozilla.javascript.Scriptable#has(String, Scriptable) @see org.mozilla.javascript.ScriptableObject#READONLY @see org.mozilla.javascript.ScriptableObject#DONTENUM @see org.mozilla.javascript.ScriptableObject#PERMANENT @see org.mozilla.javascript.ScriptableObject#EMPTY
[ "Set", "the", "attributes", "of", "an", "indexed", "property", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L793-L797
21,335
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.setAttributes
public void setAttributes(Symbol key, int attributes) { checkNotSealed(key, 0); findAttributeSlot(key, SlotAccess.MODIFY).setAttributes(attributes); }
java
public void setAttributes(Symbol key, int attributes) { checkNotSealed(key, 0); findAttributeSlot(key, SlotAccess.MODIFY).setAttributes(attributes); }
[ "public", "void", "setAttributes", "(", "Symbol", "key", ",", "int", "attributes", ")", "{", "checkNotSealed", "(", "key", ",", "0", ")", ";", "findAttributeSlot", "(", "key", ",", "SlotAccess", ".", "MODIFY", ")", ".", "setAttributes", "(", "attributes", ")", ";", "}" ]
Set attributes of a Symbol-keyed property.
[ "Set", "attributes", "of", "a", "Symbol", "-", "keyed", "property", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L802-L806
21,336
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.isGetterOrSetter
protected boolean isGetterOrSetter(String name, int index, boolean setter) { Slot slot = slotMap.query(name, index); if (slot instanceof GetterSlot) { if (setter && ((GetterSlot)slot).setter != null) return true; if (!setter && ((GetterSlot)slot).getter != null) return true; } return false; }
java
protected boolean isGetterOrSetter(String name, int index, boolean setter) { Slot slot = slotMap.query(name, index); if (slot instanceof GetterSlot) { if (setter && ((GetterSlot)slot).setter != null) return true; if (!setter && ((GetterSlot)slot).getter != null) return true; } return false; }
[ "protected", "boolean", "isGetterOrSetter", "(", "String", "name", ",", "int", "index", ",", "boolean", "setter", ")", "{", "Slot", "slot", "=", "slotMap", ".", "query", "(", "name", ",", "index", ")", ";", "if", "(", "slot", "instanceof", "GetterSlot", ")", "{", "if", "(", "setter", "&&", "(", "(", "GetterSlot", ")", "slot", ")", ".", "setter", "!=", "null", ")", "return", "true", ";", "if", "(", "!", "setter", "&&", "(", "(", "GetterSlot", ")", "slot", ")", ".", "getter", "!=", "null", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns whether a property is a getter or a setter @param name property name @param index property index @param setter true to check for a setter, false for a getter @return whether the property is a getter or a setter
[ "Returns", "whether", "a", "property", "is", "a", "getter", "or", "a", "setter" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L886-L893
21,337
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.defineClass
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, false, false); }
java
public static <T extends Scriptable> void defineClass( Scriptable scope, Class<T> clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException { defineClass(scope, clazz, false, false); }
[ "public", "static", "<", "T", "extends", "Scriptable", ">", "void", "defineClass", "(", "Scriptable", "scope", ",", "Class", "<", "T", ">", "clazz", ")", "throws", "IllegalAccessException", ",", "InstantiationException", ",", "InvocationTargetException", "{", "defineClass", "(", "scope", ",", "clazz", ",", "false", ",", "false", ")", ";", "}" ]
Defines JavaScript objects from a Java class that implements Scriptable. If the given class has a method <pre> static void init(Context cx, Scriptable scope, boolean sealed);</pre> or its compatibility form <pre> static void init(Scriptable scope);</pre> then it is invoked and no further initialization is done.<p> However, if no such a method is found, then the class's constructors and methods are used to initialize a class in the following manner.<p> First, the zero-parameter constructor of the class is called to create the prototype. If no such constructor exists, a {@link EvaluatorException} is thrown. <p> Next, all methods are scanned for special prefixes that indicate that they have special meaning for defining JavaScript objects. These special prefixes are <ul> <li><code>jsFunction_</code> for a JavaScript function <li><code>jsStaticFunction_</code> for a JavaScript function that is a property of the constructor <li><code>jsGet_</code> for a getter of a JavaScript property <li><code>jsSet_</code> for a setter of a JavaScript property <li><code>jsConstructor</code> for a JavaScript function that is the constructor </ul><p> If the method's name begins with "jsFunction_", a JavaScript function is created with a name formed from the rest of the Java method name following "jsFunction_". So a Java method named "jsFunction_foo" will define a JavaScript method "foo". Calling this JavaScript function will cause the Java method to be called. The parameters of the method must be of number and types as defined by the FunctionObject class. The JavaScript function is then added as a property of the prototype. <p> If the method's name begins with "jsStaticFunction_", it is handled similarly except that the resulting JavaScript function is added as a property of the constructor object. The Java method must be static. If the method's name begins with "jsGet_" or "jsSet_", the method is considered to define a property. Accesses to the defined property will result in calls to these getter and setter methods. If no setter is defined, the property is defined as READONLY.<p> If the method's name is "jsConstructor", the method is considered to define the body of the constructor. Only one method of this name may be defined. You may use the varargs forms for constructors documented in {@link FunctionObject#FunctionObject(String, Member, Scriptable)} If no method is found that can serve as constructor, a Java constructor will be selected to serve as the JavaScript constructor in the following manner. If the class has only one Java constructor, that constructor is used to define the JavaScript constructor. If the the class has two constructors, one must be the zero-argument constructor (otherwise an {@link EvaluatorException} would have already been thrown when the prototype was to be created). In this case the Java constructor with one or more parameters will be used to define the JavaScript constructor. If the class has three or more constructors, an {@link EvaluatorException} will be thrown.<p> Finally, if there is a method <pre> static void finishInit(Scriptable scope, FunctionObject constructor, Scriptable prototype)</pre> it will be called to finish any initialization. The <code>scope</code> argument will be passed, along with the newly created constructor and the newly created prototype.<p> @param scope The scope in which to define the constructor. @param clazz The Java class to use to define the JavaScript objects and properties. @exception IllegalAccessException if access is not available to a reflected class member @exception InstantiationException if unable to instantiate the named class @exception InvocationTargetException if an exception is thrown during execution of methods of the named class @see org.mozilla.javascript.Function @see org.mozilla.javascript.FunctionObject @see org.mozilla.javascript.ScriptableObject#READONLY @see org.mozilla.javascript.ScriptableObject #defineProperty(String, Class, int)
[ "Defines", "JavaScript", "objects", "from", "a", "Java", "class", "that", "implements", "Scriptable", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L1232-L1238
21,338
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.defineClass
public static <T extends Scriptable> String defineClass( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { BaseFunction ctor = buildClassCtor(scope, clazz, sealed, mapInheritance); if (ctor == null) return null; String name = ctor.getClassPrototype().getClassName(); defineProperty(scope, name, ctor, ScriptableObject.DONTENUM); return name; }
java
public static <T extends Scriptable> String defineClass( Scriptable scope, Class<T> clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException { BaseFunction ctor = buildClassCtor(scope, clazz, sealed, mapInheritance); if (ctor == null) return null; String name = ctor.getClassPrototype().getClassName(); defineProperty(scope, name, ctor, ScriptableObject.DONTENUM); return name; }
[ "public", "static", "<", "T", "extends", "Scriptable", ">", "String", "defineClass", "(", "Scriptable", "scope", ",", "Class", "<", "T", ">", "clazz", ",", "boolean", "sealed", ",", "boolean", "mapInheritance", ")", "throws", "IllegalAccessException", ",", "InstantiationException", ",", "InvocationTargetException", "{", "BaseFunction", "ctor", "=", "buildClassCtor", "(", "scope", ",", "clazz", ",", "sealed", ",", "mapInheritance", ")", ";", "if", "(", "ctor", "==", "null", ")", "return", "null", ";", "String", "name", "=", "ctor", ".", "getClassPrototype", "(", ")", ".", "getClassName", "(", ")", ";", "defineProperty", "(", "scope", ",", "name", ",", "ctor", ",", "ScriptableObject", ".", "DONTENUM", ")", ";", "return", "name", ";", "}" ]
Defines JavaScript objects from a Java class, optionally allowing sealing and mapping of Java inheritance to JavaScript prototype-based inheritance. Similar to <code>defineClass(Scriptable scope, Class clazz)</code> except that sealing and inheritance mapping are allowed. An object that is sealed cannot have properties added or removed. Note that sealing is not allowed in the current ECMA/ISO language specification, but is likely for the next version. @param scope The scope in which to define the constructor. @param clazz The Java class to use to define the JavaScript objects and properties. The class must implement Scriptable. @param sealed Whether or not to create sealed standard objects that cannot be modified. @param mapInheritance Whether or not to map Java inheritance to JavaScript prototype-based inheritance. @return the class name for the prototype of the specified class @exception IllegalAccessException if access is not available to a reflected class member @exception InstantiationException if unable to instantiate the named class @exception InvocationTargetException if an exception is thrown during execution of methods of the named class @since 1.6R2
[ "Defines", "JavaScript", "objects", "from", "a", "Java", "class", "optionally", "allowing", "sealing", "and", "mapping", "of", "Java", "inheritance", "to", "JavaScript", "prototype", "-", "based", "inheritance", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L1298-L1311
21,339
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.defineProperty
public void defineProperty(Symbol key, Object value, int attributes) { checkNotSealed(key, 0); put(key, this, value); setAttributes(key, attributes); }
java
public void defineProperty(Symbol key, Object value, int attributes) { checkNotSealed(key, 0); put(key, this, value); setAttributes(key, attributes); }
[ "public", "void", "defineProperty", "(", "Symbol", "key", ",", "Object", "value", ",", "int", "attributes", ")", "{", "checkNotSealed", "(", "key", ",", "0", ")", ";", "put", "(", "key", ",", "this", ",", "value", ")", ";", "setAttributes", "(", "key", ",", "attributes", ")", ";", "}" ]
A version of defineProperty that uses a Symbol key. @param key symbol of the property to define. @param value the initial value of the property @param attributes the attributes of the JavaScript property
[ "A", "version", "of", "defineProperty", "that", "uses", "a", "Symbol", "key", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L1648-L1654
21,340
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.defineProperty
public void defineProperty(String propertyName, Class<?> clazz, int attributes) { int length = propertyName.length(); if (length == 0) throw new IllegalArgumentException(); char[] buf = new char[3 + length]; propertyName.getChars(0, length, buf, 3); buf[3] = Character.toUpperCase(buf[3]); buf[0] = 'g'; buf[1] = 'e'; buf[2] = 't'; String getterName = new String(buf); buf[0] = 's'; String setterName = new String(buf); Method[] methods = FunctionObject.getMethodList(clazz); Method getter = FunctionObject.findSingleMethod(methods, getterName); Method setter = FunctionObject.findSingleMethod(methods, setterName); if (setter == null) attributes |= ScriptableObject.READONLY; defineProperty(propertyName, null, getter, setter == null ? null : setter, attributes); }
java
public void defineProperty(String propertyName, Class<?> clazz, int attributes) { int length = propertyName.length(); if (length == 0) throw new IllegalArgumentException(); char[] buf = new char[3 + length]; propertyName.getChars(0, length, buf, 3); buf[3] = Character.toUpperCase(buf[3]); buf[0] = 'g'; buf[1] = 'e'; buf[2] = 't'; String getterName = new String(buf); buf[0] = 's'; String setterName = new String(buf); Method[] methods = FunctionObject.getMethodList(clazz); Method getter = FunctionObject.findSingleMethod(methods, getterName); Method setter = FunctionObject.findSingleMethod(methods, setterName); if (setter == null) attributes |= ScriptableObject.READONLY; defineProperty(propertyName, null, getter, setter == null ? null : setter, attributes); }
[ "public", "void", "defineProperty", "(", "String", "propertyName", ",", "Class", "<", "?", ">", "clazz", ",", "int", "attributes", ")", "{", "int", "length", "=", "propertyName", ".", "length", "(", ")", ";", "if", "(", "length", "==", "0", ")", "throw", "new", "IllegalArgumentException", "(", ")", ";", "char", "[", "]", "buf", "=", "new", "char", "[", "3", "+", "length", "]", ";", "propertyName", ".", "getChars", "(", "0", ",", "length", ",", "buf", ",", "3", ")", ";", "buf", "[", "3", "]", "=", "Character", ".", "toUpperCase", "(", "buf", "[", "3", "]", ")", ";", "buf", "[", "0", "]", "=", "'", "'", ";", "buf", "[", "1", "]", "=", "'", "'", ";", "buf", "[", "2", "]", "=", "'", "'", ";", "String", "getterName", "=", "new", "String", "(", "buf", ")", ";", "buf", "[", "0", "]", "=", "'", "'", ";", "String", "setterName", "=", "new", "String", "(", "buf", ")", ";", "Method", "[", "]", "methods", "=", "FunctionObject", ".", "getMethodList", "(", "clazz", ")", ";", "Method", "getter", "=", "FunctionObject", ".", "findSingleMethod", "(", "methods", ",", "getterName", ")", ";", "Method", "setter", "=", "FunctionObject", ".", "findSingleMethod", "(", "methods", ",", "setterName", ")", ";", "if", "(", "setter", "==", "null", ")", "attributes", "|=", "ScriptableObject", ".", "READONLY", ";", "defineProperty", "(", "propertyName", ",", "null", ",", "getter", ",", "setter", "==", "null", "?", "null", ":", "setter", ",", "attributes", ")", ";", "}" ]
Define a JavaScript property with getter and setter side effects. If the setter is not found, the attribute READONLY is added to the given attributes. <p> The getter must be a method with zero parameters, and the setter, if found, must be a method with one parameter.<p> @param propertyName the name of the property to define. This name also affects the name of the setter and getter to search for. If the propertyId is "foo", then <code>clazz</code> will be searched for "getFoo" and "setFoo" methods. @param clazz the Java class to search for the getter and setter @param attributes the attributes of the JavaScript property @see org.mozilla.javascript.Scriptable#put(String, Scriptable, Object)
[ "Define", "a", "JavaScript", "property", "with", "getter", "and", "setter", "side", "effects", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L1714-L1736
21,341
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.defineOwnProperties
public void defineOwnProperties(Context cx, ScriptableObject props) { Object[] ids = props.getIds(false, true); ScriptableObject[] descs = new ScriptableObject[ids.length]; for (int i = 0, len = ids.length; i < len; ++i) { Object descObj = ScriptRuntime.getObjectElem(props, ids[i], cx); ScriptableObject desc = ensureScriptableObject(descObj); checkPropertyDefinition(desc); descs[i] = desc; } for (int i = 0, len = ids.length; i < len; ++i) { defineOwnProperty(cx, ids[i], descs[i]); } }
java
public void defineOwnProperties(Context cx, ScriptableObject props) { Object[] ids = props.getIds(false, true); ScriptableObject[] descs = new ScriptableObject[ids.length]; for (int i = 0, len = ids.length; i < len; ++i) { Object descObj = ScriptRuntime.getObjectElem(props, ids[i], cx); ScriptableObject desc = ensureScriptableObject(descObj); checkPropertyDefinition(desc); descs[i] = desc; } for (int i = 0, len = ids.length; i < len; ++i) { defineOwnProperty(cx, ids[i], descs[i]); } }
[ "public", "void", "defineOwnProperties", "(", "Context", "cx", ",", "ScriptableObject", "props", ")", "{", "Object", "[", "]", "ids", "=", "props", ".", "getIds", "(", "false", ",", "true", ")", ";", "ScriptableObject", "[", "]", "descs", "=", "new", "ScriptableObject", "[", "ids", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ",", "len", "=", "ids", ".", "length", ";", "i", "<", "len", ";", "++", "i", ")", "{", "Object", "descObj", "=", "ScriptRuntime", ".", "getObjectElem", "(", "props", ",", "ids", "[", "i", "]", ",", "cx", ")", ";", "ScriptableObject", "desc", "=", "ensureScriptableObject", "(", "descObj", ")", ";", "checkPropertyDefinition", "(", "desc", ")", ";", "descs", "[", "i", "]", "=", "desc", ";", "}", "for", "(", "int", "i", "=", "0", ",", "len", "=", "ids", ".", "length", ";", "i", "<", "len", ";", "++", "i", ")", "{", "defineOwnProperty", "(", "cx", ",", "ids", "[", "i", "]", ",", "descs", "[", "i", "]", ")", ";", "}", "}" ]
Defines one or more properties on this object. @param cx the current Context @param props a map of property ids to property descriptors
[ "Defines", "one", "or", "more", "properties", "on", "this", "object", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L1877-L1889
21,342
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.sameValue
protected boolean sameValue(Object newValue, Object currentValue) { if (newValue == NOT_FOUND) { return true; } if (currentValue == NOT_FOUND) { currentValue = Undefined.instance; } // Special rules for numbers: NaN is considered the same value, // while zeroes with different signs are considered different. if (currentValue instanceof Number && newValue instanceof Number) { double d1 = ((Number)currentValue).doubleValue(); double d2 = ((Number)newValue).doubleValue(); if (Double.isNaN(d1) && Double.isNaN(d2)) { return true; } if (d1 == 0.0 && Double.doubleToLongBits(d1) != Double.doubleToLongBits(d2)) { return false; } } return ScriptRuntime.shallowEq(currentValue, newValue); }
java
protected boolean sameValue(Object newValue, Object currentValue) { if (newValue == NOT_FOUND) { return true; } if (currentValue == NOT_FOUND) { currentValue = Undefined.instance; } // Special rules for numbers: NaN is considered the same value, // while zeroes with different signs are considered different. if (currentValue instanceof Number && newValue instanceof Number) { double d1 = ((Number)currentValue).doubleValue(); double d2 = ((Number)newValue).doubleValue(); if (Double.isNaN(d1) && Double.isNaN(d2)) { return true; } if (d1 == 0.0 && Double.doubleToLongBits(d1) != Double.doubleToLongBits(d2)) { return false; } } return ScriptRuntime.shallowEq(currentValue, newValue); }
[ "protected", "boolean", "sameValue", "(", "Object", "newValue", ",", "Object", "currentValue", ")", "{", "if", "(", "newValue", "==", "NOT_FOUND", ")", "{", "return", "true", ";", "}", "if", "(", "currentValue", "==", "NOT_FOUND", ")", "{", "currentValue", "=", "Undefined", ".", "instance", ";", "}", "// Special rules for numbers: NaN is considered the same value,", "// while zeroes with different signs are considered different.", "if", "(", "currentValue", "instanceof", "Number", "&&", "newValue", "instanceof", "Number", ")", "{", "double", "d1", "=", "(", "(", "Number", ")", "currentValue", ")", ".", "doubleValue", "(", ")", ";", "double", "d2", "=", "(", "(", "Number", ")", "newValue", ")", ".", "doubleValue", "(", ")", ";", "if", "(", "Double", ".", "isNaN", "(", "d1", ")", "&&", "Double", ".", "isNaN", "(", "d2", ")", ")", "{", "return", "true", ";", "}", "if", "(", "d1", "==", "0.0", "&&", "Double", ".", "doubleToLongBits", "(", "d1", ")", "!=", "Double", ".", "doubleToLongBits", "(", "d2", ")", ")", "{", "return", "false", ";", "}", "}", "return", "ScriptRuntime", ".", "shallowEq", "(", "currentValue", ",", "newValue", ")", ";", "}" ]
Implements SameValue as described in ES5 9.12, additionally checking if new value is defined. @param newValue the new value @param currentValue the current value @return true if values are the same as defined by ES5 9.12
[ "Implements", "SameValue", "as", "described", "in", "ES5", "9", ".", "12", "additionally", "checking", "if", "new", "value", "is", "defined", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2044-L2064
21,343
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.defineFunctionProperties
public void defineFunctionProperties(String[] names, Class<?> clazz, int attributes) { Method[] methods = FunctionObject.getMethodList(clazz); for (int i=0; i < names.length; i++) { String name = names[i]; Method m = FunctionObject.findSingleMethod(methods, name); if (m == null) { throw Context.reportRuntimeError2( "msg.method.not.found", name, clazz.getName()); } FunctionObject f = new FunctionObject(name, m, this); defineProperty(name, f, attributes); } }
java
public void defineFunctionProperties(String[] names, Class<?> clazz, int attributes) { Method[] methods = FunctionObject.getMethodList(clazz); for (int i=0; i < names.length; i++) { String name = names[i]; Method m = FunctionObject.findSingleMethod(methods, name); if (m == null) { throw Context.reportRuntimeError2( "msg.method.not.found", name, clazz.getName()); } FunctionObject f = new FunctionObject(name, m, this); defineProperty(name, f, attributes); } }
[ "public", "void", "defineFunctionProperties", "(", "String", "[", "]", "names", ",", "Class", "<", "?", ">", "clazz", ",", "int", "attributes", ")", "{", "Method", "[", "]", "methods", "=", "FunctionObject", ".", "getMethodList", "(", "clazz", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "names", ".", "length", ";", "i", "++", ")", "{", "String", "name", "=", "names", "[", "i", "]", ";", "Method", "m", "=", "FunctionObject", ".", "findSingleMethod", "(", "methods", ",", "name", ")", ";", "if", "(", "m", "==", "null", ")", "{", "throw", "Context", ".", "reportRuntimeError2", "(", "\"msg.method.not.found\"", ",", "name", ",", "clazz", ".", "getName", "(", ")", ")", ";", "}", "FunctionObject", "f", "=", "new", "FunctionObject", "(", "name", ",", "m", ",", "this", ")", ";", "defineProperty", "(", "name", ",", "f", ",", "attributes", ")", ";", "}", "}" ]
Search for names in a class, adding the resulting methods as properties. <p> Uses reflection to find the methods of the given names. Then FunctionObjects are constructed from the methods found, and are added to this object as properties with the given names. @param names the names of the Methods to add as function properties @param clazz the class to search for the Methods @param attributes the attributes of the new properties @see org.mozilla.javascript.FunctionObject
[ "Search", "for", "names", "in", "a", "class", "adding", "the", "resulting", "methods", "as", "properties", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2148-L2162
21,344
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.getObjectPrototype
public static Scriptable getObjectPrototype(Scriptable scope) { return TopLevel.getBuiltinPrototype(getTopLevelScope(scope), TopLevel.Builtins.Object); }
java
public static Scriptable getObjectPrototype(Scriptable scope) { return TopLevel.getBuiltinPrototype(getTopLevelScope(scope), TopLevel.Builtins.Object); }
[ "public", "static", "Scriptable", "getObjectPrototype", "(", "Scriptable", "scope", ")", "{", "return", "TopLevel", ".", "getBuiltinPrototype", "(", "getTopLevelScope", "(", "scope", ")", ",", "TopLevel", ".", "Builtins", ".", "Object", ")", ";", "}" ]
Get the Object.prototype property. See ECMA 15.2.4. @param scope an object in the scope chain
[ "Get", "the", "Object", ".", "prototype", "property", ".", "See", "ECMA", "15", ".", "2", ".", "4", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2169-L2172
21,345
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.getFunctionPrototype
public static Scriptable getFunctionPrototype(Scriptable scope) { return TopLevel.getBuiltinPrototype(getTopLevelScope(scope), TopLevel.Builtins.Function); }
java
public static Scriptable getFunctionPrototype(Scriptable scope) { return TopLevel.getBuiltinPrototype(getTopLevelScope(scope), TopLevel.Builtins.Function); }
[ "public", "static", "Scriptable", "getFunctionPrototype", "(", "Scriptable", "scope", ")", "{", "return", "TopLevel", ".", "getBuiltinPrototype", "(", "getTopLevelScope", "(", "scope", ")", ",", "TopLevel", ".", "Builtins", ".", "Function", ")", ";", "}" ]
Get the Function.prototype property. See ECMA 15.3.4. @param scope an object in the scope chain
[ "Get", "the", "Function", ".", "prototype", "property", ".", "See", "ECMA", "15", ".", "3", ".", "4", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2179-L2182
21,346
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.getClassPrototype
public static Scriptable getClassPrototype(Scriptable scope, String className) { scope = getTopLevelScope(scope); Object ctor = getProperty(scope, className); Object proto; if (ctor instanceof BaseFunction) { proto = ((BaseFunction)ctor).getPrototypeProperty(); } else if (ctor instanceof Scriptable) { Scriptable ctorObj = (Scriptable)ctor; proto = ctorObj.get("prototype", ctorObj); } else { return null; } if (proto instanceof Scriptable) { return (Scriptable)proto; } return null; }
java
public static Scriptable getClassPrototype(Scriptable scope, String className) { scope = getTopLevelScope(scope); Object ctor = getProperty(scope, className); Object proto; if (ctor instanceof BaseFunction) { proto = ((BaseFunction)ctor).getPrototypeProperty(); } else if (ctor instanceof Scriptable) { Scriptable ctorObj = (Scriptable)ctor; proto = ctorObj.get("prototype", ctorObj); } else { return null; } if (proto instanceof Scriptable) { return (Scriptable)proto; } return null; }
[ "public", "static", "Scriptable", "getClassPrototype", "(", "Scriptable", "scope", ",", "String", "className", ")", "{", "scope", "=", "getTopLevelScope", "(", "scope", ")", ";", "Object", "ctor", "=", "getProperty", "(", "scope", ",", "className", ")", ";", "Object", "proto", ";", "if", "(", "ctor", "instanceof", "BaseFunction", ")", "{", "proto", "=", "(", "(", "BaseFunction", ")", "ctor", ")", ".", "getPrototypeProperty", "(", ")", ";", "}", "else", "if", "(", "ctor", "instanceof", "Scriptable", ")", "{", "Scriptable", "ctorObj", "=", "(", "Scriptable", ")", "ctor", ";", "proto", "=", "ctorObj", ".", "get", "(", "\"prototype\"", ",", "ctorObj", ")", ";", "}", "else", "{", "return", "null", ";", "}", "if", "(", "proto", "instanceof", "Scriptable", ")", "{", "return", "(", "Scriptable", ")", "proto", ";", "}", "return", "null", ";", "}" ]
Get the prototype for the named class. For example, <code>getClassPrototype(s, "Date")</code> will first walk up the parent chain to find the outermost scope, then will search that scope for the Date constructor, and then will return Date.prototype. If any of the lookups fail, or the prototype is not a JavaScript object, then null will be returned. @param scope an object in the scope chain @param className the name of the constructor @return the prototype for the named class, or null if it cannot be found.
[ "Get", "the", "prototype", "for", "the", "named", "class", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2204-L2222
21,347
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.getTopLevelScope
public static Scriptable getTopLevelScope(Scriptable obj) { for (;;) { Scriptable parent = obj.getParentScope(); if (parent == null) { return obj; } obj = parent; } }
java
public static Scriptable getTopLevelScope(Scriptable obj) { for (;;) { Scriptable parent = obj.getParentScope(); if (parent == null) { return obj; } obj = parent; } }
[ "public", "static", "Scriptable", "getTopLevelScope", "(", "Scriptable", "obj", ")", "{", "for", "(", ";", ";", ")", "{", "Scriptable", "parent", "=", "obj", ".", "getParentScope", "(", ")", ";", "if", "(", "parent", "==", "null", ")", "{", "return", "obj", ";", "}", "obj", "=", "parent", ";", "}", "}" ]
Get the global scope. <p>Walks the parent scope chain to find an object with a null parent scope (the global object). @param obj a JavaScript object @return the corresponding global scope
[ "Get", "the", "global", "scope", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2233-L2242
21,348
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.sealObject
public void sealObject() { if (!isSealed) { final long stamp = slotMap.readLock(); try { for (Slot slot : slotMap) { Object value = slot.value; if (value instanceof LazilyLoadedCtor) { LazilyLoadedCtor initializer = (LazilyLoadedCtor) value; try { initializer.init(); } finally { slot.value = initializer.getValue(); } } } isSealed = true; } finally { slotMap.unlockRead(stamp); } } }
java
public void sealObject() { if (!isSealed) { final long stamp = slotMap.readLock(); try { for (Slot slot : slotMap) { Object value = slot.value; if (value instanceof LazilyLoadedCtor) { LazilyLoadedCtor initializer = (LazilyLoadedCtor) value; try { initializer.init(); } finally { slot.value = initializer.getValue(); } } } isSealed = true; } finally { slotMap.unlockRead(stamp); } } }
[ "public", "void", "sealObject", "(", ")", "{", "if", "(", "!", "isSealed", ")", "{", "final", "long", "stamp", "=", "slotMap", ".", "readLock", "(", ")", ";", "try", "{", "for", "(", "Slot", "slot", ":", "slotMap", ")", "{", "Object", "value", "=", "slot", ".", "value", ";", "if", "(", "value", "instanceof", "LazilyLoadedCtor", ")", "{", "LazilyLoadedCtor", "initializer", "=", "(", "LazilyLoadedCtor", ")", "value", ";", "try", "{", "initializer", ".", "init", "(", ")", ";", "}", "finally", "{", "slot", ".", "value", "=", "initializer", ".", "getValue", "(", ")", ";", "}", "}", "}", "isSealed", "=", "true", ";", "}", "finally", "{", "slotMap", ".", "unlockRead", "(", "stamp", ")", ";", "}", "}", "}" ]
Seal this object. It is an error to add properties to or delete properties from a sealed object. It is possible to change the value of an existing property. Once an object is sealed it may not be unsealed. @since 1.4R3
[ "Seal", "this", "object", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2261-L2281
21,349
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.getProperty
public static Object getProperty(Scriptable obj, Symbol key) { Scriptable start = obj; Object result; do { result = ensureSymbolScriptable(obj).get(key, start); if (result != Scriptable.NOT_FOUND) break; obj = obj.getPrototype(); } while (obj != null); return result; }
java
public static Object getProperty(Scriptable obj, Symbol key) { Scriptable start = obj; Object result; do { result = ensureSymbolScriptable(obj).get(key, start); if (result != Scriptable.NOT_FOUND) break; obj = obj.getPrototype(); } while (obj != null); return result; }
[ "public", "static", "Object", "getProperty", "(", "Scriptable", "obj", ",", "Symbol", "key", ")", "{", "Scriptable", "start", "=", "obj", ";", "Object", "result", ";", "do", "{", "result", "=", "ensureSymbolScriptable", "(", "obj", ")", ".", "get", "(", "key", ",", "start", ")", ";", "if", "(", "result", "!=", "Scriptable", ".", "NOT_FOUND", ")", "break", ";", "obj", "=", "obj", ".", "getPrototype", "(", ")", ";", "}", "while", "(", "obj", "!=", "null", ")", ";", "return", "result", ";", "}" ]
This is a version of getProperty that works with Symbols.
[ "This", "is", "a", "version", "of", "getProperty", "that", "works", "with", "Symbols", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2331-L2342
21,350
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.putProperty
public static void putProperty(Scriptable obj, Symbol key, Object value) { Scriptable base = getBase(obj, key); if (base == null) base = obj; ensureSymbolScriptable(base).put(key, obj, value); }
java
public static void putProperty(Scriptable obj, Symbol key, Object value) { Scriptable base = getBase(obj, key); if (base == null) base = obj; ensureSymbolScriptable(base).put(key, obj, value); }
[ "public", "static", "void", "putProperty", "(", "Scriptable", "obj", ",", "Symbol", "key", ",", "Object", "value", ")", "{", "Scriptable", "base", "=", "getBase", "(", "obj", ",", "key", ")", ";", "if", "(", "base", "==", "null", ")", "base", "=", "obj", ";", "ensureSymbolScriptable", "(", "base", ")", ".", "put", "(", "key", ",", "obj", ",", "value", ")", ";", "}" ]
This is a version of putProperty for Symbol keys.
[ "This", "is", "a", "version", "of", "putProperty", "for", "Symbol", "keys", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2513-L2519
21,351
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.callMethod
public static Object callMethod(Context cx, Scriptable obj, String methodName, Object[] args) { Object funObj = getProperty(obj, methodName); if (!(funObj instanceof Function)) { throw ScriptRuntime.notFunctionError(obj, methodName); } Function fun = (Function)funObj; // XXX: What should be the scope when calling funObj? // The following favor scope stored in the object on the assumption // that is more useful especially under dynamic scope setup. // An alternative is to check for dynamic scope flag // and use ScriptableObject.getTopLevelScope(fun) if the flag is not // set. But that require access to Context and messy code // so for now it is not checked. Scriptable scope = ScriptableObject.getTopLevelScope(obj); if (cx != null) { return fun.call(cx, scope, obj, args); } return Context.call(null, fun, scope, obj, args); }
java
public static Object callMethod(Context cx, Scriptable obj, String methodName, Object[] args) { Object funObj = getProperty(obj, methodName); if (!(funObj instanceof Function)) { throw ScriptRuntime.notFunctionError(obj, methodName); } Function fun = (Function)funObj; // XXX: What should be the scope when calling funObj? // The following favor scope stored in the object on the assumption // that is more useful especially under dynamic scope setup. // An alternative is to check for dynamic scope flag // and use ScriptableObject.getTopLevelScope(fun) if the flag is not // set. But that require access to Context and messy code // so for now it is not checked. Scriptable scope = ScriptableObject.getTopLevelScope(obj); if (cx != null) { return fun.call(cx, scope, obj, args); } return Context.call(null, fun, scope, obj, args); }
[ "public", "static", "Object", "callMethod", "(", "Context", "cx", ",", "Scriptable", "obj", ",", "String", "methodName", ",", "Object", "[", "]", "args", ")", "{", "Object", "funObj", "=", "getProperty", "(", "obj", ",", "methodName", ")", ";", "if", "(", "!", "(", "funObj", "instanceof", "Function", ")", ")", "{", "throw", "ScriptRuntime", ".", "notFunctionError", "(", "obj", ",", "methodName", ")", ";", "}", "Function", "fun", "=", "(", "Function", ")", "funObj", ";", "// XXX: What should be the scope when calling funObj?", "// The following favor scope stored in the object on the assumption", "// that is more useful especially under dynamic scope setup.", "// An alternative is to check for dynamic scope flag", "// and use ScriptableObject.getTopLevelScope(fun) if the flag is not", "// set. But that require access to Context and messy code", "// so for now it is not checked.", "Scriptable", "scope", "=", "ScriptableObject", ".", "getTopLevelScope", "(", "obj", ")", ";", "if", "(", "cx", "!=", "null", ")", "{", "return", "fun", ".", "call", "(", "cx", ",", "scope", ",", "obj", ",", "args", ")", ";", "}", "return", "Context", ".", "call", "(", "null", ",", "fun", ",", "scope", ",", "obj", ",", "args", ")", ";", "}" ]
Call a method of an object. @param cx the Context object associated with the current thread. @param obj the JavaScript object @param methodName the name of the function property @param args the arguments for the call
[ "Call", "a", "method", "of", "an", "object", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2675-L2696
21,352
mozilla/rhino
src/org/mozilla/javascript/ScriptableObject.java
ScriptableObject.getAssociatedValue
public final Object getAssociatedValue(Object key) { Map<Object,Object> h = associatedValues; if (h == null) return null; return h.get(key); }
java
public final Object getAssociatedValue(Object key) { Map<Object,Object> h = associatedValues; if (h == null) return null; return h.get(key); }
[ "public", "final", "Object", "getAssociatedValue", "(", "Object", "key", ")", "{", "Map", "<", "Object", ",", "Object", ">", "h", "=", "associatedValues", ";", "if", "(", "h", "==", "null", ")", "return", "null", ";", "return", "h", ".", "get", "(", "key", ")", ";", "}" ]
Get arbitrary application-specific value associated with this object. @param key key object to select particular value. @see #associateValue(Object key, Object value)
[ "Get", "arbitrary", "application", "-", "specific", "value", "associated", "with", "this", "object", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ScriptableObject.java#L2733-L2739
21,353
mozilla/rhino
src/org/mozilla/javascript/optimizer/Codegen.java
Codegen.generateResumeGenerator
private void generateResumeGenerator(ClassFileWriter cfw) { boolean hasGenerators = false; for (int i=0; i < scriptOrFnNodes.length; i++) { if (isGenerator(scriptOrFnNodes[i])) hasGenerators = true; } // if there are no generators defined, we don't implement a // resumeGenerator(). The base class provides a default implementation. if (!hasGenerators) return; cfw.startMethod("resumeGenerator", "(Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "ILjava/lang/Object;" + "Ljava/lang/Object;)Ljava/lang/Object;", (short)(ACC_PUBLIC | ACC_FINAL)); // load arguments for dispatch to the corresponding *_gen method cfw.addALoad(0); cfw.addALoad(1); cfw.addALoad(2); cfw.addALoad(4); cfw.addALoad(5); cfw.addILoad(3); cfw.addLoadThis(); cfw.add(ByteCode.GETFIELD, cfw.getClassName(), ID_FIELD_NAME, "I"); int startSwitch = cfw.addTableSwitch(0, scriptOrFnNodes.length - 1); cfw.markTableSwitchDefault(startSwitch); int endlabel = cfw.acquireLabel(); for (int i = 0; i < scriptOrFnNodes.length; i++) { ScriptNode n = scriptOrFnNodes[i]; cfw.markTableSwitchCase(startSwitch, i, (short)6); if (isGenerator(n)) { String type = "(" + mainClassSignature + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "Ljava/lang/Object;" + "Ljava/lang/Object;I)Ljava/lang/Object;"; cfw.addInvoke(ByteCode.INVOKESTATIC, mainClassName, getBodyMethodName(n) + "_gen", type); cfw.add(ByteCode.ARETURN); } else { cfw.add(ByteCode.GOTO, endlabel); } } cfw.markLabel(endlabel); pushUndefined(cfw); cfw.add(ByteCode.ARETURN); // this method uses as many locals as there are arguments (hence 6) cfw.stopMethod((short)6); }
java
private void generateResumeGenerator(ClassFileWriter cfw) { boolean hasGenerators = false; for (int i=0; i < scriptOrFnNodes.length; i++) { if (isGenerator(scriptOrFnNodes[i])) hasGenerators = true; } // if there are no generators defined, we don't implement a // resumeGenerator(). The base class provides a default implementation. if (!hasGenerators) return; cfw.startMethod("resumeGenerator", "(Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "ILjava/lang/Object;" + "Ljava/lang/Object;)Ljava/lang/Object;", (short)(ACC_PUBLIC | ACC_FINAL)); // load arguments for dispatch to the corresponding *_gen method cfw.addALoad(0); cfw.addALoad(1); cfw.addALoad(2); cfw.addALoad(4); cfw.addALoad(5); cfw.addILoad(3); cfw.addLoadThis(); cfw.add(ByteCode.GETFIELD, cfw.getClassName(), ID_FIELD_NAME, "I"); int startSwitch = cfw.addTableSwitch(0, scriptOrFnNodes.length - 1); cfw.markTableSwitchDefault(startSwitch); int endlabel = cfw.acquireLabel(); for (int i = 0; i < scriptOrFnNodes.length; i++) { ScriptNode n = scriptOrFnNodes[i]; cfw.markTableSwitchCase(startSwitch, i, (short)6); if (isGenerator(n)) { String type = "(" + mainClassSignature + "Lorg/mozilla/javascript/Context;" + "Lorg/mozilla/javascript/Scriptable;" + "Ljava/lang/Object;" + "Ljava/lang/Object;I)Ljava/lang/Object;"; cfw.addInvoke(ByteCode.INVOKESTATIC, mainClassName, getBodyMethodName(n) + "_gen", type); cfw.add(ByteCode.ARETURN); } else { cfw.add(ByteCode.GOTO, endlabel); } } cfw.markLabel(endlabel); pushUndefined(cfw); cfw.add(ByteCode.ARETURN); // this method uses as many locals as there are arguments (hence 6) cfw.stopMethod((short)6); }
[ "private", "void", "generateResumeGenerator", "(", "ClassFileWriter", "cfw", ")", "{", "boolean", "hasGenerators", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "scriptOrFnNodes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "isGenerator", "(", "scriptOrFnNodes", "[", "i", "]", ")", ")", "hasGenerators", "=", "true", ";", "}", "// if there are no generators defined, we don't implement a", "// resumeGenerator(). The base class provides a default implementation.", "if", "(", "!", "hasGenerators", ")", "return", ";", "cfw", ".", "startMethod", "(", "\"resumeGenerator\"", ",", "\"(Lorg/mozilla/javascript/Context;\"", "+", "\"Lorg/mozilla/javascript/Scriptable;\"", "+", "\"ILjava/lang/Object;\"", "+", "\"Ljava/lang/Object;)Ljava/lang/Object;\"", ",", "(", "short", ")", "(", "ACC_PUBLIC", "|", "ACC_FINAL", ")", ")", ";", "// load arguments for dispatch to the corresponding *_gen method", "cfw", ".", "addALoad", "(", "0", ")", ";", "cfw", ".", "addALoad", "(", "1", ")", ";", "cfw", ".", "addALoad", "(", "2", ")", ";", "cfw", ".", "addALoad", "(", "4", ")", ";", "cfw", ".", "addALoad", "(", "5", ")", ";", "cfw", ".", "addILoad", "(", "3", ")", ";", "cfw", ".", "addLoadThis", "(", ")", ";", "cfw", ".", "add", "(", "ByteCode", ".", "GETFIELD", ",", "cfw", ".", "getClassName", "(", ")", ",", "ID_FIELD_NAME", ",", "\"I\"", ")", ";", "int", "startSwitch", "=", "cfw", ".", "addTableSwitch", "(", "0", ",", "scriptOrFnNodes", ".", "length", "-", "1", ")", ";", "cfw", ".", "markTableSwitchDefault", "(", "startSwitch", ")", ";", "int", "endlabel", "=", "cfw", ".", "acquireLabel", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "scriptOrFnNodes", ".", "length", ";", "i", "++", ")", "{", "ScriptNode", "n", "=", "scriptOrFnNodes", "[", "i", "]", ";", "cfw", ".", "markTableSwitchCase", "(", "startSwitch", ",", "i", ",", "(", "short", ")", "6", ")", ";", "if", "(", "isGenerator", "(", "n", ")", ")", "{", "String", "type", "=", "\"(\"", "+", "mainClassSignature", "+", "\"Lorg/mozilla/javascript/Context;\"", "+", "\"Lorg/mozilla/javascript/Scriptable;\"", "+", "\"Ljava/lang/Object;\"", "+", "\"Ljava/lang/Object;I)Ljava/lang/Object;\"", ";", "cfw", ".", "addInvoke", "(", "ByteCode", ".", "INVOKESTATIC", ",", "mainClassName", ",", "getBodyMethodName", "(", "n", ")", "+", "\"_gen\"", ",", "type", ")", ";", "cfw", ".", "add", "(", "ByteCode", ".", "ARETURN", ")", ";", "}", "else", "{", "cfw", ".", "add", "(", "ByteCode", ".", "GOTO", ",", "endlabel", ")", ";", "}", "}", "cfw", ".", "markLabel", "(", "endlabel", ")", ";", "pushUndefined", "(", "cfw", ")", ";", "cfw", ".", "add", "(", "ByteCode", ".", "ARETURN", ")", ";", "// this method uses as many locals as there are arguments (hence 6)", "cfw", ".", "stopMethod", "(", "(", "short", ")", "6", ")", ";", "}" ]
appended by "_gen".
[ "appended", "by", "_gen", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/optimizer/Codegen.java#L414-L476
21,354
mozilla/rhino
src/org/mozilla/javascript/optimizer/Codegen.java
Codegen.cleanName
String cleanName(final ScriptNode n) { String result = ""; if (n instanceof FunctionNode) { Name name = ((FunctionNode) n).getFunctionName(); if (name == null) { result = "anonymous"; } else { result = name.getIdentifier(); } } else { result = "script"; } return result; }
java
String cleanName(final ScriptNode n) { String result = ""; if (n instanceof FunctionNode) { Name name = ((FunctionNode) n).getFunctionName(); if (name == null) { result = "anonymous"; } else { result = name.getIdentifier(); } } else { result = "script"; } return result; }
[ "String", "cleanName", "(", "final", "ScriptNode", "n", ")", "{", "String", "result", "=", "\"\"", ";", "if", "(", "n", "instanceof", "FunctionNode", ")", "{", "Name", "name", "=", "(", "(", "FunctionNode", ")", "n", ")", ".", "getFunctionName", "(", ")", ";", "if", "(", "name", "==", "null", ")", "{", "result", "=", "\"anonymous\"", ";", "}", "else", "{", "result", "=", "name", ".", "getIdentifier", "(", ")", ";", "}", "}", "else", "{", "result", "=", "\"script\"", ";", "}", "return", "result", ";", "}" ]
Gets a Java-compatible "informative" name for the the ScriptOrFnNode
[ "Gets", "a", "Java", "-", "compatible", "informative", "name", "for", "the", "the", "ScriptOrFnNode" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/optimizer/Codegen.java#L1168-L1182
21,355
mozilla/rhino
src/org/mozilla/javascript/optimizer/Codegen.java
BodyCodegen.addLoadPropertyIds
private void addLoadPropertyIds(Object[] properties, int count) { addNewObjectArray(count); for (int i = 0; i != count; ++i) { cfw.add(ByteCode.DUP); cfw.addPush(i); Object id = properties[i]; if (id instanceof String) { cfw.addPush((String)id); } else { cfw.addPush(((Integer)id).intValue()); addScriptRuntimeInvoke("wrapInt", "(I)Ljava/lang/Integer;"); } cfw.add(ByteCode.AASTORE); } }
java
private void addLoadPropertyIds(Object[] properties, int count) { addNewObjectArray(count); for (int i = 0; i != count; ++i) { cfw.add(ByteCode.DUP); cfw.addPush(i); Object id = properties[i]; if (id instanceof String) { cfw.addPush((String)id); } else { cfw.addPush(((Integer)id).intValue()); addScriptRuntimeInvoke("wrapInt", "(I)Ljava/lang/Integer;"); } cfw.add(ByteCode.AASTORE); } }
[ "private", "void", "addLoadPropertyIds", "(", "Object", "[", "]", "properties", ",", "int", "count", ")", "{", "addNewObjectArray", "(", "count", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "count", ";", "++", "i", ")", "{", "cfw", ".", "add", "(", "ByteCode", ".", "DUP", ")", ";", "cfw", ".", "addPush", "(", "i", ")", ";", "Object", "id", "=", "properties", "[", "i", "]", ";", "if", "(", "id", "instanceof", "String", ")", "{", "cfw", ".", "addPush", "(", "(", "String", ")", "id", ")", ";", "}", "else", "{", "cfw", ".", "addPush", "(", "(", "(", "Integer", ")", "id", ")", ".", "intValue", "(", ")", ")", ";", "addScriptRuntimeInvoke", "(", "\"wrapInt\"", ",", "\"(I)Ljava/lang/Integer;\"", ")", ";", "}", "cfw", ".", "add", "(", "ByteCode", ".", "AASTORE", ")", ";", "}", "}" ]
load array with property ids
[ "load", "array", "with", "property", "ids" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/optimizer/Codegen.java#L3169-L3183
21,356
mozilla/rhino
src/org/mozilla/javascript/optimizer/Codegen.java
BodyCodegen.addLoadPropertyValues
private void addLoadPropertyValues(Node node, Node child, int count) { if (isGenerator) { // see bug 757410 for an explanation why we need to split this for (int i = 0; i != count; ++i) { int childType = child.getType(); if (childType == Token.GET || childType == Token.SET || childType == Token.METHOD) { generateExpression(child.getFirstChild(), node); } else { generateExpression(child, node); } child = child.getNext(); } addNewObjectArray(count); for (int i = 0; i != count; ++i) { cfw.add(ByteCode.DUP_X1); cfw.add(ByteCode.SWAP); cfw.addPush(count - i - 1); cfw.add(ByteCode.SWAP); cfw.add(ByteCode.AASTORE); } } else { addNewObjectArray(count); Node child2 = child; for (int i = 0; i != count; ++i) { cfw.add(ByteCode.DUP); cfw.addPush(i); int childType = child2.getType(); if (childType == Token.GET || childType == Token.SET || childType == Token.METHOD) { generateExpression(child2.getFirstChild(), node); } else { generateExpression(child2, node); } cfw.add(ByteCode.AASTORE); child2 = child2.getNext(); } } }
java
private void addLoadPropertyValues(Node node, Node child, int count) { if (isGenerator) { // see bug 757410 for an explanation why we need to split this for (int i = 0; i != count; ++i) { int childType = child.getType(); if (childType == Token.GET || childType == Token.SET || childType == Token.METHOD) { generateExpression(child.getFirstChild(), node); } else { generateExpression(child, node); } child = child.getNext(); } addNewObjectArray(count); for (int i = 0; i != count; ++i) { cfw.add(ByteCode.DUP_X1); cfw.add(ByteCode.SWAP); cfw.addPush(count - i - 1); cfw.add(ByteCode.SWAP); cfw.add(ByteCode.AASTORE); } } else { addNewObjectArray(count); Node child2 = child; for (int i = 0; i != count; ++i) { cfw.add(ByteCode.DUP); cfw.addPush(i); int childType = child2.getType(); if (childType == Token.GET || childType == Token.SET || childType == Token.METHOD) { generateExpression(child2.getFirstChild(), node); } else { generateExpression(child2, node); } cfw.add(ByteCode.AASTORE); child2 = child2.getNext(); } } }
[ "private", "void", "addLoadPropertyValues", "(", "Node", "node", ",", "Node", "child", ",", "int", "count", ")", "{", "if", "(", "isGenerator", ")", "{", "// see bug 757410 for an explanation why we need to split this", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "count", ";", "++", "i", ")", "{", "int", "childType", "=", "child", ".", "getType", "(", ")", ";", "if", "(", "childType", "==", "Token", ".", "GET", "||", "childType", "==", "Token", ".", "SET", "||", "childType", "==", "Token", ".", "METHOD", ")", "{", "generateExpression", "(", "child", ".", "getFirstChild", "(", ")", ",", "node", ")", ";", "}", "else", "{", "generateExpression", "(", "child", ",", "node", ")", ";", "}", "child", "=", "child", ".", "getNext", "(", ")", ";", "}", "addNewObjectArray", "(", "count", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "count", ";", "++", "i", ")", "{", "cfw", ".", "add", "(", "ByteCode", ".", "DUP_X1", ")", ";", "cfw", ".", "add", "(", "ByteCode", ".", "SWAP", ")", ";", "cfw", ".", "addPush", "(", "count", "-", "i", "-", "1", ")", ";", "cfw", ".", "add", "(", "ByteCode", ".", "SWAP", ")", ";", "cfw", ".", "add", "(", "ByteCode", ".", "AASTORE", ")", ";", "}", "}", "else", "{", "addNewObjectArray", "(", "count", ")", ";", "Node", "child2", "=", "child", ";", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "count", ";", "++", "i", ")", "{", "cfw", ".", "add", "(", "ByteCode", ".", "DUP", ")", ";", "cfw", ".", "addPush", "(", "i", ")", ";", "int", "childType", "=", "child2", ".", "getType", "(", ")", ";", "if", "(", "childType", "==", "Token", ".", "GET", "||", "childType", "==", "Token", ".", "SET", "||", "childType", "==", "Token", ".", "METHOD", ")", "{", "generateExpression", "(", "child2", ".", "getFirstChild", "(", ")", ",", "node", ")", ";", "}", "else", "{", "generateExpression", "(", "child2", ",", "node", ")", ";", "}", "cfw", ".", "add", "(", "ByteCode", ".", "AASTORE", ")", ";", "child2", "=", "child2", ".", "getNext", "(", ")", ";", "}", "}", "}" ]
load array with property values
[ "load", "array", "with", "property", "values" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/optimizer/Codegen.java#L3186-L3222
21,357
mozilla/rhino
src/org/mozilla/javascript/optimizer/Codegen.java
BodyCodegen.inlineFinally
private void inlineFinally(Node finallyTarget, int finallyStart, int finallyEnd) { Node fBlock = getFinallyAtTarget(finallyTarget); fBlock.resetTargets(); Node child = fBlock.getFirstChild(); exceptionManager.markInlineFinallyStart(fBlock, finallyStart); while (child != null) { generateStatement(child); child = child.getNext(); } exceptionManager.markInlineFinallyEnd(fBlock, finallyEnd); }
java
private void inlineFinally(Node finallyTarget, int finallyStart, int finallyEnd) { Node fBlock = getFinallyAtTarget(finallyTarget); fBlock.resetTargets(); Node child = fBlock.getFirstChild(); exceptionManager.markInlineFinallyStart(fBlock, finallyStart); while (child != null) { generateStatement(child); child = child.getNext(); } exceptionManager.markInlineFinallyEnd(fBlock, finallyEnd); }
[ "private", "void", "inlineFinally", "(", "Node", "finallyTarget", ",", "int", "finallyStart", ",", "int", "finallyEnd", ")", "{", "Node", "fBlock", "=", "getFinallyAtTarget", "(", "finallyTarget", ")", ";", "fBlock", ".", "resetTargets", "(", ")", ";", "Node", "child", "=", "fBlock", ".", "getFirstChild", "(", ")", ";", "exceptionManager", ".", "markInlineFinallyStart", "(", "fBlock", ",", "finallyStart", ")", ";", "while", "(", "child", "!=", "null", ")", "{", "generateStatement", "(", "child", ")", ";", "child", "=", "child", ".", "getNext", "(", ")", ";", "}", "exceptionManager", ".", "markInlineFinallyEnd", "(", "fBlock", ",", "finallyEnd", ")", ";", "}" ]
Inline a FINALLY node into the method bytecode. This method takes a label that points to the real start of the finally block as implemented in the bytecode. This is because in some cases, the finally block really starts before any of the code in the Node. For example, the catch-all-rethrow finally block has a few instructions prior to the finally block made by the user. In addition, an end label that should be unmarked is given as a method parameter. It is the responsibility of any callers of this method to mark the label. The start and end labels of the finally block are used to exclude the inlined block from the proper exception handler. For example, an inlined finally block should not be handled by a catch-all-rethrow. @param finallyTarget a TARGET node directly preceding a FINALLY node or a FINALLY node itself @param finallyStart a pre-marked label that indicates the actual start of the finally block in the bytecode. @param finallyEnd an unmarked label that will indicate the actual end of the finally block in the bytecode.
[ "Inline", "a", "FINALLY", "node", "into", "the", "method", "bytecode", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/optimizer/Codegen.java#L4211-L4222
21,358
mozilla/rhino
src/org/mozilla/javascript/optimizer/Codegen.java
BodyCodegen.getFinallyAtTarget
private Node getFinallyAtTarget(Node node) { if (node == null) { return null; } if (node.getType() == Token.FINALLY) { return node; } if (node.getType() == Token.TARGET) { Node fBlock = node.getNext(); if (fBlock != null && fBlock.getType() == Token.FINALLY) { return fBlock; } } throw Kit.codeBug("bad finally target"); }
java
private Node getFinallyAtTarget(Node node) { if (node == null) { return null; } if (node.getType() == Token.FINALLY) { return node; } if (node.getType() == Token.TARGET) { Node fBlock = node.getNext(); if (fBlock != null && fBlock.getType() == Token.FINALLY) { return fBlock; } } throw Kit.codeBug("bad finally target"); }
[ "private", "Node", "getFinallyAtTarget", "(", "Node", "node", ")", "{", "if", "(", "node", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "node", ".", "getType", "(", ")", "==", "Token", ".", "FINALLY", ")", "{", "return", "node", ";", "}", "if", "(", "node", ".", "getType", "(", ")", "==", "Token", ".", "TARGET", ")", "{", "Node", "fBlock", "=", "node", ".", "getNext", "(", ")", ";", "if", "(", "fBlock", "!=", "null", "&&", "fBlock", ".", "getType", "(", ")", "==", "Token", ".", "FINALLY", ")", "{", "return", "fBlock", ";", "}", "}", "throw", "Kit", ".", "codeBug", "(", "\"bad finally target\"", ")", ";", "}" ]
Get a FINALLY node at a point in the IR. This is strongly dependent on the generated IR. If the node is a TARGET, it only check the next node to see if it is a FINALLY node.
[ "Get", "a", "FINALLY", "node", "at", "a", "point", "in", "the", "IR", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/optimizer/Codegen.java#L4238-L4252
21,359
mozilla/rhino
xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLLibImpl.java
XMLLibImpl.toDomNode
public static org.w3c.dom.Node toDomNode(Object xmlObject) { // Could return DocumentFragment for XMLList // Probably a single node for XMLList with one element if (xmlObject instanceof XML) { return ((XML)xmlObject).toDomNode(); } else { throw new IllegalArgumentException( "xmlObject is not an XML object in JavaScript."); } }
java
public static org.w3c.dom.Node toDomNode(Object xmlObject) { // Could return DocumentFragment for XMLList // Probably a single node for XMLList with one element if (xmlObject instanceof XML) { return ((XML)xmlObject).toDomNode(); } else { throw new IllegalArgumentException( "xmlObject is not an XML object in JavaScript."); } }
[ "public", "static", "org", ".", "w3c", ".", "dom", ".", "Node", "toDomNode", "(", "Object", "xmlObject", ")", "{", "// Could return DocumentFragment for XMLList", "// Probably a single node for XMLList with one element", "if", "(", "xmlObject", "instanceof", "XML", ")", "{", "return", "(", "(", "XML", ")", "xmlObject", ")", ".", "toDomNode", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"xmlObject is not an XML object in JavaScript.\"", ")", ";", "}", "}" ]
This experimental interface is undocumented.
[ "This", "experimental", "interface", "is", "undocumented", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLLibImpl.java#L33-L42
21,360
mozilla/rhino
src/org/mozilla/javascript/ast/WithStatement.java
WithStatement.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { expression.visit(v); statement.visit(v); } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { expression.visit(v); statement.visit(v); } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "expression", ".", "visit", "(", "v", ")", ";", "statement", ".", "visit", "(", "v", ")", ";", "}", "}" ]
Visits this node, then the with-object, then the body statement.
[ "Visits", "this", "node", "then", "the", "with", "-", "object", "then", "the", "body", "statement", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/WithStatement.java#L134-L140
21,361
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/shell/Global.java
Global.write
public static Object write(Context cx, Scriptable thisObj, Object[] args, Function funObj) { return doPrint(args, funObj, false); }
java
public static Object write(Context cx, Scriptable thisObj, Object[] args, Function funObj) { return doPrint(args, funObj, false); }
[ "public", "static", "Object", "write", "(", "Context", "cx", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ",", "Function", "funObj", ")", "{", "return", "doPrint", "(", "args", ",", "funObj", ",", "false", ")", ";", "}" ]
Print just as in "print," but without the trailing newline.
[ "Print", "just", "as", "in", "print", "but", "without", "the", "trailing", "newline", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/shell/Global.java#L226-L230
21,362
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/shell/Global.java
Global.quit
public static void quit(Context cx, Scriptable thisObj, Object[] args, Function funObj) { Global global = getInstance(funObj); if (global.quitAction != null) { int exitCode = (args.length == 0 ? 0 : ScriptRuntime.toInt32(args[0])); global.quitAction.quit(cx, exitCode); } }
java
public static void quit(Context cx, Scriptable thisObj, Object[] args, Function funObj) { Global global = getInstance(funObj); if (global.quitAction != null) { int exitCode = (args.length == 0 ? 0 : ScriptRuntime.toInt32(args[0])); global.quitAction.quit(cx, exitCode); } }
[ "public", "static", "void", "quit", "(", "Context", "cx", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ",", "Function", "funObj", ")", "{", "Global", "global", "=", "getInstance", "(", "funObj", ")", ";", "if", "(", "global", ".", "quitAction", "!=", "null", ")", "{", "int", "exitCode", "=", "(", "args", ".", "length", "==", "0", "?", "0", ":", "ScriptRuntime", ".", "toInt32", "(", "args", "[", "0", "]", ")", ")", ";", "global", ".", "quitAction", ".", "quit", "(", "cx", ",", "exitCode", ")", ";", "}", "}" ]
Call embedding-specific quit action passing its argument as int32 exit code. This method is defined as a JavaScript function.
[ "Call", "embedding", "-", "specific", "quit", "action", "passing", "its", "argument", "as", "int32", "exit", "code", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/shell/Global.java#L256-L265
21,363
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/shell/Global.java
Global.spawn
public static Object spawn(Context cx, Scriptable thisObj, Object[] args, Function funObj) { Scriptable scope = funObj.getParentScope(); Runner runner; if (args.length != 0 && args[0] instanceof Function) { Object[] newArgs = null; if (args.length > 1 && args[1] instanceof Scriptable) { newArgs = cx.getElements((Scriptable) args[1]); } if (newArgs == null) { newArgs = ScriptRuntime.emptyArgs; } runner = new Runner(scope, (Function) args[0], newArgs); } else if (args.length != 0 && args[0] instanceof Script) { runner = new Runner(scope, (Script) args[0]); } else { throw reportRuntimeError("msg.spawn.args"); } runner.factory = cx.getFactory(); Thread thread = new Thread(runner); thread.start(); return thread; }
java
public static Object spawn(Context cx, Scriptable thisObj, Object[] args, Function funObj) { Scriptable scope = funObj.getParentScope(); Runner runner; if (args.length != 0 && args[0] instanceof Function) { Object[] newArgs = null; if (args.length > 1 && args[1] instanceof Scriptable) { newArgs = cx.getElements((Scriptable) args[1]); } if (newArgs == null) { newArgs = ScriptRuntime.emptyArgs; } runner = new Runner(scope, (Function) args[0], newArgs); } else if (args.length != 0 && args[0] instanceof Script) { runner = new Runner(scope, (Script) args[0]); } else { throw reportRuntimeError("msg.spawn.args"); } runner.factory = cx.getFactory(); Thread thread = new Thread(runner); thread.start(); return thread; }
[ "public", "static", "Object", "spawn", "(", "Context", "cx", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ",", "Function", "funObj", ")", "{", "Scriptable", "scope", "=", "funObj", ".", "getParentScope", "(", ")", ";", "Runner", "runner", ";", "if", "(", "args", ".", "length", "!=", "0", "&&", "args", "[", "0", "]", "instanceof", "Function", ")", "{", "Object", "[", "]", "newArgs", "=", "null", ";", "if", "(", "args", ".", "length", ">", "1", "&&", "args", "[", "1", "]", "instanceof", "Scriptable", ")", "{", "newArgs", "=", "cx", ".", "getElements", "(", "(", "Scriptable", ")", "args", "[", "1", "]", ")", ";", "}", "if", "(", "newArgs", "==", "null", ")", "{", "newArgs", "=", "ScriptRuntime", ".", "emptyArgs", ";", "}", "runner", "=", "new", "Runner", "(", "scope", ",", "(", "Function", ")", "args", "[", "0", "]", ",", "newArgs", ")", ";", "}", "else", "if", "(", "args", ".", "length", "!=", "0", "&&", "args", "[", "0", "]", "instanceof", "Script", ")", "{", "runner", "=", "new", "Runner", "(", "scope", ",", "(", "Script", ")", "args", "[", "0", "]", ")", ";", "}", "else", "{", "throw", "reportRuntimeError", "(", "\"msg.spawn.args\"", ")", ";", "}", "runner", ".", "factory", "=", "cx", ".", "getFactory", "(", ")", ";", "Thread", "thread", "=", "new", "Thread", "(", "runner", ")", ";", "thread", ".", "start", "(", ")", ";", "return", "thread", ";", "}" ]
The spawn function runs a given function or script in a different thread. js&gt; function g() { a = 7; } js&gt; a = 3; 3 js&gt; spawn(g) Thread[Thread-1,5,main] js&gt; a 3
[ "The", "spawn", "function", "runs", "a", "given", "function", "or", "script", "in", "a", "different", "thread", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/shell/Global.java#L590-L611
21,364
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/shell/Global.java
Global.seal
public static void seal(Context cx, Scriptable thisObj, Object[] args, Function funObj) { for (int i = 0; i != args.length; ++i) { Object arg = args[i]; if (!(arg instanceof ScriptableObject) || arg == Undefined.instance) { if (!(arg instanceof Scriptable) || arg == Undefined.instance) { throw reportRuntimeError("msg.shell.seal.not.object"); } else { throw reportRuntimeError("msg.shell.seal.not.scriptable"); } } } for (int i = 0; i != args.length; ++i) { Object arg = args[i]; ((ScriptableObject)arg).sealObject(); } }
java
public static void seal(Context cx, Scriptable thisObj, Object[] args, Function funObj) { for (int i = 0; i != args.length; ++i) { Object arg = args[i]; if (!(arg instanceof ScriptableObject) || arg == Undefined.instance) { if (!(arg instanceof Scriptable) || arg == Undefined.instance) { throw reportRuntimeError("msg.shell.seal.not.object"); } else { throw reportRuntimeError("msg.shell.seal.not.scriptable"); } } } for (int i = 0; i != args.length; ++i) { Object arg = args[i]; ((ScriptableObject)arg).sealObject(); } }
[ "public", "static", "void", "seal", "(", "Context", "cx", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ",", "Function", "funObj", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "args", ".", "length", ";", "++", "i", ")", "{", "Object", "arg", "=", "args", "[", "i", "]", ";", "if", "(", "!", "(", "arg", "instanceof", "ScriptableObject", ")", "||", "arg", "==", "Undefined", ".", "instance", ")", "{", "if", "(", "!", "(", "arg", "instanceof", "Scriptable", ")", "||", "arg", "==", "Undefined", ".", "instance", ")", "{", "throw", "reportRuntimeError", "(", "\"msg.shell.seal.not.object\"", ")", ";", "}", "else", "{", "throw", "reportRuntimeError", "(", "\"msg.shell.seal.not.scriptable\"", ")", ";", "}", "}", "}", "for", "(", "int", "i", "=", "0", ";", "i", "!=", "args", ".", "length", ";", "++", "i", ")", "{", "Object", "arg", "=", "args", "[", "i", "]", ";", "(", "(", "ScriptableObject", ")", "arg", ")", ".", "sealObject", "(", ")", ";", "}", "}" ]
The seal function seals all supplied arguments.
[ "The", "seal", "function", "seals", "all", "supplied", "arguments", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/shell/Global.java#L803-L823
21,365
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/shell/Global.java
Global.toint32
public static Object toint32(Context cx, Scriptable thisObj, Object[] args, Function funObj) { Object arg = (args.length != 0 ? args[0] : Undefined.instance); if (arg instanceof Integer) return arg; return ScriptRuntime.wrapInt(ScriptRuntime.toInt32(arg)); }
java
public static Object toint32(Context cx, Scriptable thisObj, Object[] args, Function funObj) { Object arg = (args.length != 0 ? args[0] : Undefined.instance); if (arg instanceof Integer) return arg; return ScriptRuntime.wrapInt(ScriptRuntime.toInt32(arg)); }
[ "public", "static", "Object", "toint32", "(", "Context", "cx", ",", "Scriptable", "thisObj", ",", "Object", "[", "]", "args", ",", "Function", "funObj", ")", "{", "Object", "arg", "=", "(", "args", ".", "length", "!=", "0", "?", "args", "[", "0", "]", ":", "Undefined", ".", "instance", ")", ";", "if", "(", "arg", "instanceof", "Integer", ")", "return", "arg", ";", "return", "ScriptRuntime", ".", "wrapInt", "(", "ScriptRuntime", ".", "toInt32", "(", "arg", ")", ")", ";", "}" ]
Convert the argument to int32 number.
[ "Convert", "the", "argument", "to", "int32", "number", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/shell/Global.java#L887-L894
21,366
mozilla/rhino
src/org/mozilla/javascript/Node.java
Node.getJsDoc
public String getJsDoc() { Comment comment = getJsDocNode(); if (comment != null) { return comment.getValue(); } return null; }
java
public String getJsDoc() { Comment comment = getJsDocNode(); if (comment != null) { return comment.getValue(); } return null; }
[ "public", "String", "getJsDoc", "(", ")", "{", "Comment", "comment", "=", "getJsDocNode", "(", ")", ";", "if", "(", "comment", "!=", "null", ")", "{", "return", "comment", ".", "getValue", "(", ")", ";", "}", "return", "null", ";", "}" ]
Gets the JsDoc comment string attached to this node. @return the comment string or {@code null} if no JsDoc is attached to this node
[ "Gets", "the", "JsDoc", "comment", "string", "attached", "to", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Node.java#L179-L185
21,367
mozilla/rhino
src/org/mozilla/javascript/Node.java
Node.addChildAfter
public void addChildAfter(Node newChild, Node node) { if (newChild.next != null) throw new RuntimeException( "newChild had siblings in addChildAfter"); newChild.next = node.next; node.next = newChild; if (last == node) last = newChild; }
java
public void addChildAfter(Node newChild, Node node) { if (newChild.next != null) throw new RuntimeException( "newChild had siblings in addChildAfter"); newChild.next = node.next; node.next = newChild; if (last == node) last = newChild; }
[ "public", "void", "addChildAfter", "(", "Node", "newChild", ",", "Node", "node", ")", "{", "if", "(", "newChild", ".", "next", "!=", "null", ")", "throw", "new", "RuntimeException", "(", "\"newChild had siblings in addChildAfter\"", ")", ";", "newChild", ".", "next", "=", "node", ".", "next", ";", "node", ".", "next", "=", "newChild", ";", "if", "(", "last", "==", "node", ")", "last", "=", "newChild", ";", "}" ]
Add 'child' after 'node'.
[ "Add", "child", "after", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Node.java#L295-L303
21,368
mozilla/rhino
src/org/mozilla/javascript/Node.java
Node.endCheckIf
private int endCheckIf() { Node th, el; int rv = END_UNREACHED; th = next; el = ((Jump)this).target; rv = th.endCheck(); if (el != null) rv |= el.endCheck(); else rv |= END_DROPS_OFF; return rv; }
java
private int endCheckIf() { Node th, el; int rv = END_UNREACHED; th = next; el = ((Jump)this).target; rv = th.endCheck(); if (el != null) rv |= el.endCheck(); else rv |= END_DROPS_OFF; return rv; }
[ "private", "int", "endCheckIf", "(", ")", "{", "Node", "th", ",", "el", ";", "int", "rv", "=", "END_UNREACHED", ";", "th", "=", "next", ";", "el", "=", "(", "(", "Jump", ")", "this", ")", ".", "target", ";", "rv", "=", "th", ".", "endCheck", "(", ")", ";", "if", "(", "el", "!=", "null", ")", "rv", "|=", "el", ".", "endCheck", "(", ")", ";", "else", "rv", "|=", "END_DROPS_OFF", ";", "return", "rv", ";", "}" ]
Returns in the then and else blocks must be consistent with each other. If there is no else block, then the return statement can fall through. @return logical OR of END_* flags
[ "Returns", "in", "the", "then", "and", "else", "blocks", "must", "be", "consistent", "with", "each", "other", ".", "If", "there", "is", "no", "else", "block", "then", "the", "return", "statement", "can", "fall", "through", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Node.java#L658-L674
21,369
mozilla/rhino
src/org/mozilla/javascript/Node.java
Node.endCheckLabel
private int endCheckLabel() { int rv = END_UNREACHED; rv = next.endCheck(); rv |= getIntProp(CONTROL_BLOCK_PROP, END_UNREACHED); return rv; }
java
private int endCheckLabel() { int rv = END_UNREACHED; rv = next.endCheck(); rv |= getIntProp(CONTROL_BLOCK_PROP, END_UNREACHED); return rv; }
[ "private", "int", "endCheckLabel", "(", ")", "{", "int", "rv", "=", "END_UNREACHED", ";", "rv", "=", "next", ".", "endCheck", "(", ")", ";", "rv", "|=", "getIntProp", "(", "CONTROL_BLOCK_PROP", ",", "END_UNREACHED", ")", ";", "return", "rv", ";", "}" ]
A labelled statement implies that there maybe a break to the label. The function processes the labelled statement and then checks the CONTROL_BLOCK_PROP property to see if there is ever a break to the particular label. @return logical OR of END_* flags
[ "A", "labelled", "statement", "implies", "that", "there", "maybe", "a", "break", "to", "the", "label", ".", "The", "function", "processes", "the", "labelled", "statement", "and", "then", "checks", "the", "CONTROL_BLOCK_PROP", "property", "to", "see", "if", "there", "is", "ever", "a", "break", "to", "the", "particular", "label", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Node.java#L829-L837
21,370
mozilla/rhino
src/org/mozilla/javascript/Node.java
Node.endCheckBreak
private int endCheckBreak() { Node n = ((Jump) this).getJumpStatement(); n.putIntProp(CONTROL_BLOCK_PROP, END_DROPS_OFF); return END_UNREACHED; }
java
private int endCheckBreak() { Node n = ((Jump) this).getJumpStatement(); n.putIntProp(CONTROL_BLOCK_PROP, END_DROPS_OFF); return END_UNREACHED; }
[ "private", "int", "endCheckBreak", "(", ")", "{", "Node", "n", "=", "(", "(", "Jump", ")", "this", ")", ".", "getJumpStatement", "(", ")", ";", "n", ".", "putIntProp", "(", "CONTROL_BLOCK_PROP", ",", "END_DROPS_OFF", ")", ";", "return", "END_UNREACHED", ";", "}" ]
When a break is encountered annotate the statement being broken out of by setting its CONTROL_BLOCK_PROP property. @return logical OR of END_* flags
[ "When", "a", "break", "is", "encountered", "annotate", "the", "statement", "being", "broken", "out", "of", "by", "setting", "its", "CONTROL_BLOCK_PROP", "property", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/Node.java#L844-L849
21,371
mozilla/rhino
src/org/mozilla/javascript/ast/ReturnStatement.java
ReturnStatement.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this) && returnValue != null) { returnValue.visit(v); } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this) && returnValue != null) { returnValue.visit(v); } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", "&&", "returnValue", "!=", "null", ")", "{", "returnValue", ".", "visit", "(", "v", ")", ";", "}", "}" ]
Visits this node, then the return value if specified.
[ "Visits", "this", "node", "then", "the", "return", "value", "if", "specified", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/ReturnStatement.java#L74-L79
21,372
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/debugger/Main.java
Main.setBreakOnExceptions
public void setBreakOnExceptions(boolean value) { dim.setBreakOnExceptions(value); debugGui.getMenubar().getBreakOnExceptions().setSelected(value); }
java
public void setBreakOnExceptions(boolean value) { dim.setBreakOnExceptions(value); debugGui.getMenubar().getBreakOnExceptions().setSelected(value); }
[ "public", "void", "setBreakOnExceptions", "(", "boolean", "value", ")", "{", "dim", ".", "setBreakOnExceptions", "(", "value", ")", ";", "debugGui", ".", "getMenubar", "(", ")", ".", "getBreakOnExceptions", "(", ")", ".", "setSelected", "(", "value", ")", ";", "}" ]
Sets whether execution should break when a script exception is thrown.
[ "Sets", "whether", "execution", "should", "break", "when", "a", "script", "exception", "is", "thrown", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/debugger/Main.java#L61-L64
21,373
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/debugger/Main.java
Main.setBreakOnEnter
public void setBreakOnEnter(boolean value) { dim.setBreakOnEnter(value); debugGui.getMenubar().getBreakOnEnter().setSelected(value); }
java
public void setBreakOnEnter(boolean value) { dim.setBreakOnEnter(value); debugGui.getMenubar().getBreakOnEnter().setSelected(value); }
[ "public", "void", "setBreakOnEnter", "(", "boolean", "value", ")", "{", "dim", ".", "setBreakOnEnter", "(", "value", ")", ";", "debugGui", ".", "getMenubar", "(", ")", ".", "getBreakOnEnter", "(", ")", ".", "setSelected", "(", "value", ")", ";", "}" ]
Sets whether execution should break when a function is entered.
[ "Sets", "whether", "execution", "should", "break", "when", "a", "function", "is", "entered", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/debugger/Main.java#L69-L72
21,374
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/debugger/Main.java
Main.setBreakOnReturn
public void setBreakOnReturn(boolean value) { dim.setBreakOnReturn(value); debugGui.getMenubar().getBreakOnReturn().setSelected(value); }
java
public void setBreakOnReturn(boolean value) { dim.setBreakOnReturn(value); debugGui.getMenubar().getBreakOnReturn().setSelected(value); }
[ "public", "void", "setBreakOnReturn", "(", "boolean", "value", ")", "{", "dim", ".", "setBreakOnReturn", "(", "value", ")", ";", "debugGui", ".", "getMenubar", "(", ")", ".", "getBreakOnReturn", "(", ")", ".", "setSelected", "(", "value", ")", ";", "}" ]
Sets whether execution should break when a function is left.
[ "Sets", "whether", "execution", "should", "break", "when", "a", "function", "is", "left", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/debugger/Main.java#L77-L80
21,375
mozilla/rhino
src/org/mozilla/javascript/UintMap.java
UintMap.getObject
public Object getObject(int key) { if (key < 0) Kit.codeBug(); if (values != null) { int index = findIndex(key); if (0 <= index) { return values[index]; } } return null; }
java
public Object getObject(int key) { if (key < 0) Kit.codeBug(); if (values != null) { int index = findIndex(key); if (0 <= index) { return values[index]; } } return null; }
[ "public", "Object", "getObject", "(", "int", "key", ")", "{", "if", "(", "key", "<", "0", ")", "Kit", ".", "codeBug", "(", ")", ";", "if", "(", "values", "!=", "null", ")", "{", "int", "index", "=", "findIndex", "(", "key", ")", ";", "if", "(", "0", "<=", "index", ")", "{", "return", "values", "[", "index", "]", ";", "}", "}", "return", "null", ";", "}" ]
Get object value assigned with key. @return key object value or null if key is absent
[ "Get", "object", "value", "assigned", "with", "key", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/UintMap.java#L62-L71
21,376
mozilla/rhino
src/org/mozilla/javascript/UintMap.java
UintMap.put
public void put(int key, Object value) { if (key < 0) Kit.codeBug(); int index = ensureIndex(key, false); if (values == null) { values = new Object[1 << power]; } values[index] = value; }
java
public void put(int key, Object value) { if (key < 0) Kit.codeBug(); int index = ensureIndex(key, false); if (values == null) { values = new Object[1 << power]; } values[index] = value; }
[ "public", "void", "put", "(", "int", "key", ",", "Object", "value", ")", "{", "if", "(", "key", "<", "0", ")", "Kit", ".", "codeBug", "(", ")", ";", "int", "index", "=", "ensureIndex", "(", "key", ",", "false", ")", ";", "if", "(", "values", "==", "null", ")", "{", "values", "=", "new", "Object", "[", "1", "<<", "power", "]", ";", "}", "values", "[", "index", "]", "=", "value", ";", "}" ]
Set object value of the key. If key does not exist, also set its int value to 0.
[ "Set", "object", "value", "of", "the", "key", ".", "If", "key", "does", "not", "exist", "also", "set", "its", "int", "value", "to", "0", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/UintMap.java#L113-L120
21,377
mozilla/rhino
src/org/mozilla/javascript/UintMap.java
UintMap.put
public void put(int key, int value) { if (key < 0) Kit.codeBug(); int index = ensureIndex(key, true); if (ivaluesShift == 0) { int N = 1 << power; // keys.length can be N * 2 after clear which set ivaluesShift to 0 if (keys.length != N * 2) { int[] tmp = new int[N * 2]; System.arraycopy(keys, 0, tmp, 0, N); keys = tmp; } ivaluesShift = N; } keys[ivaluesShift + index] = value; }
java
public void put(int key, int value) { if (key < 0) Kit.codeBug(); int index = ensureIndex(key, true); if (ivaluesShift == 0) { int N = 1 << power; // keys.length can be N * 2 after clear which set ivaluesShift to 0 if (keys.length != N * 2) { int[] tmp = new int[N * 2]; System.arraycopy(keys, 0, tmp, 0, N); keys = tmp; } ivaluesShift = N; } keys[ivaluesShift + index] = value; }
[ "public", "void", "put", "(", "int", "key", ",", "int", "value", ")", "{", "if", "(", "key", "<", "0", ")", "Kit", ".", "codeBug", "(", ")", ";", "int", "index", "=", "ensureIndex", "(", "key", ",", "true", ")", ";", "if", "(", "ivaluesShift", "==", "0", ")", "{", "int", "N", "=", "1", "<<", "power", ";", "// keys.length can be N * 2 after clear which set ivaluesShift to 0", "if", "(", "keys", ".", "length", "!=", "N", "*", "2", ")", "{", "int", "[", "]", "tmp", "=", "new", "int", "[", "N", "*", "2", "]", ";", "System", ".", "arraycopy", "(", "keys", ",", "0", ",", "tmp", ",", "0", ",", "N", ")", ";", "keys", "=", "tmp", ";", "}", "ivaluesShift", "=", "N", ";", "}", "keys", "[", "ivaluesShift", "+", "index", "]", "=", "value", ";", "}" ]
Set int value of the key. If key does not exist, also set its object value to null.
[ "Set", "int", "value", "of", "the", "key", ".", "If", "key", "does", "not", "exist", "also", "set", "its", "object", "value", "to", "null", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/UintMap.java#L126-L140
21,378
mozilla/rhino
src/org/mozilla/javascript/UintMap.java
UintMap.getKeys
public int[] getKeys() { int[] keys = this.keys; int n = keyCount; int[] result = new int[n]; for (int i = 0; n != 0; ++i) { int entry = keys[i]; if (entry != EMPTY && entry != DELETED) { result[--n] = entry; } } return result; }
java
public int[] getKeys() { int[] keys = this.keys; int n = keyCount; int[] result = new int[n]; for (int i = 0; n != 0; ++i) { int entry = keys[i]; if (entry != EMPTY && entry != DELETED) { result[--n] = entry; } } return result; }
[ "public", "int", "[", "]", "getKeys", "(", ")", "{", "int", "[", "]", "keys", "=", "this", ".", "keys", ";", "int", "n", "=", "keyCount", ";", "int", "[", "]", "result", "=", "new", "int", "[", "n", "]", ";", "for", "(", "int", "i", "=", "0", ";", "n", "!=", "0", ";", "++", "i", ")", "{", "int", "entry", "=", "keys", "[", "i", "]", ";", "if", "(", "entry", "!=", "EMPTY", "&&", "entry", "!=", "DELETED", ")", "{", "result", "[", "--", "n", "]", "=", "entry", ";", "}", "}", "return", "result", ";", "}" ]
Return array of present keys
[ "Return", "array", "of", "present", "keys" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/UintMap.java#L173-L184
21,379
mozilla/rhino
src/org/mozilla/javascript/NativeSymbol.java
NativeSymbol.construct
public static NativeSymbol construct(Context cx, Scriptable scope, Object[] args) { cx.putThreadLocal(CONSTRUCTOR_SLOT, Boolean.TRUE); try { return (NativeSymbol)cx.newObject(scope, CLASS_NAME, args); } finally { cx.removeThreadLocal(CONSTRUCTOR_SLOT); } }
java
public static NativeSymbol construct(Context cx, Scriptable scope, Object[] args) { cx.putThreadLocal(CONSTRUCTOR_SLOT, Boolean.TRUE); try { return (NativeSymbol)cx.newObject(scope, CLASS_NAME, args); } finally { cx.removeThreadLocal(CONSTRUCTOR_SLOT); } }
[ "public", "static", "NativeSymbol", "construct", "(", "Context", "cx", ",", "Scriptable", "scope", ",", "Object", "[", "]", "args", ")", "{", "cx", ".", "putThreadLocal", "(", "CONSTRUCTOR_SLOT", ",", "Boolean", ".", "TRUE", ")", ";", "try", "{", "return", "(", "NativeSymbol", ")", "cx", ".", "newObject", "(", "scope", ",", "CLASS_NAME", ",", "args", ")", ";", "}", "finally", "{", "cx", ".", "removeThreadLocal", "(", "CONSTRUCTOR_SLOT", ")", ";", "}", "}" ]
Use this when we need to create symbols internally because of the convoluted way we have to construct them.
[ "Use", "this", "when", "we", "need", "to", "create", "symbols", "internally", "because", "of", "the", "convoluted", "way", "we", "have", "to", "construct", "them", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeSymbol.java#L86-L94
21,380
mozilla/rhino
src/org/mozilla/javascript/NativeSymbol.java
NativeSymbol.put
@Override public void put(String name, Scriptable start, Object value) { if (!isSymbol()) { super.put(name, start, value); } else if (Context.getCurrentContext().isStrictMode()) { throw ScriptRuntime.typeError0("msg.no.assign.symbol.strict"); } }
java
@Override public void put(String name, Scriptable start, Object value) { if (!isSymbol()) { super.put(name, start, value); } else if (Context.getCurrentContext().isStrictMode()) { throw ScriptRuntime.typeError0("msg.no.assign.symbol.strict"); } }
[ "@", "Override", "public", "void", "put", "(", "String", "name", ",", "Scriptable", "start", ",", "Object", "value", ")", "{", "if", "(", "!", "isSymbol", "(", ")", ")", "{", "super", ".", "put", "(", "name", ",", "start", ",", "value", ")", ";", "}", "else", "if", "(", "Context", ".", "getCurrentContext", "(", ")", ".", "isStrictMode", "(", ")", ")", "{", "throw", "ScriptRuntime", ".", "typeError0", "(", "\"msg.no.assign.symbol.strict\"", ")", ";", "}", "}" ]
Symbol objects have a special property that one cannot add properties.
[ "Symbol", "objects", "have", "a", "special", "property", "that", "one", "cannot", "add", "properties", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/NativeSymbol.java#L283-L291
21,381
mozilla/rhino
toolsrc/org/mozilla/javascript/tools/shell/Main.java
Main.exec
public static int exec(String origArgs[]) { errorReporter = new ToolErrorReporter(false, global.getErr()); shellContextFactory.setErrorReporter(errorReporter); String[] args = processOptions(origArgs); if (exitCode > 0) { return exitCode; } if (processStdin) { fileList.add(null); } if (!global.initialized) { global.init(shellContextFactory); } IProxy iproxy = new IProxy(IProxy.PROCESS_FILES); iproxy.args = args; shellContextFactory.call(iproxy); return exitCode; }
java
public static int exec(String origArgs[]) { errorReporter = new ToolErrorReporter(false, global.getErr()); shellContextFactory.setErrorReporter(errorReporter); String[] args = processOptions(origArgs); if (exitCode > 0) { return exitCode; } if (processStdin) { fileList.add(null); } if (!global.initialized) { global.init(shellContextFactory); } IProxy iproxy = new IProxy(IProxy.PROCESS_FILES); iproxy.args = args; shellContextFactory.call(iproxy); return exitCode; }
[ "public", "static", "int", "exec", "(", "String", "origArgs", "[", "]", ")", "{", "errorReporter", "=", "new", "ToolErrorReporter", "(", "false", ",", "global", ".", "getErr", "(", ")", ")", ";", "shellContextFactory", ".", "setErrorReporter", "(", "errorReporter", ")", ";", "String", "[", "]", "args", "=", "processOptions", "(", "origArgs", ")", ";", "if", "(", "exitCode", ">", "0", ")", "{", "return", "exitCode", ";", "}", "if", "(", "processStdin", ")", "{", "fileList", ".", "add", "(", "null", ")", ";", "}", "if", "(", "!", "global", ".", "initialized", ")", "{", "global", ".", "init", "(", "shellContextFactory", ")", ";", "}", "IProxy", "iproxy", "=", "new", "IProxy", "(", "IProxy", ".", "PROCESS_FILES", ")", ";", "iproxy", ".", "args", "=", "args", ";", "shellContextFactory", ".", "call", "(", "iproxy", ")", ";", "return", "exitCode", ";", "}" ]
Execute the given arguments, but don't System.exit at the end.
[ "Execute", "the", "given", "arguments", "but", "don", "t", "System", ".", "exit", "at", "the", "end", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/toolsrc/org/mozilla/javascript/tools/shell/Main.java#L145-L164
21,382
mozilla/rhino
src/org/mozilla/javascript/ast/AstRoot.java
AstRoot.setComments
public void setComments(SortedSet<Comment> comments) { if (comments == null) { this.comments = null; } else { if (this.comments != null) this.comments.clear(); for (Comment c : comments) addComment(c); } }
java
public void setComments(SortedSet<Comment> comments) { if (comments == null) { this.comments = null; } else { if (this.comments != null) this.comments.clear(); for (Comment c : comments) addComment(c); } }
[ "public", "void", "setComments", "(", "SortedSet", "<", "Comment", ">", "comments", ")", "{", "if", "(", "comments", "==", "null", ")", "{", "this", ".", "comments", "=", "null", ";", "}", "else", "{", "if", "(", "this", ".", "comments", "!=", "null", ")", "this", ".", "comments", ".", "clear", "(", ")", ";", "for", "(", "Comment", "c", ":", "comments", ")", "addComment", "(", ")", ";", "}", "}" ]
Sets comment list, and updates the parent of each entry to point to this node. Replaces any existing comments. @param comments comment list. can be {@code null}.
[ "Sets", "comment", "list", "and", "updates", "the", "parent", "of", "each", "entry", "to", "point", "to", "this", "node", ".", "Replaces", "any", "existing", "comments", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstRoot.java#L53-L62
21,383
mozilla/rhino
src/org/mozilla/javascript/ast/AstRoot.java
AstRoot.addComment
public void addComment(Comment comment) { assertNotNull(comment); if (comments == null) { comments = new TreeSet<Comment>(new AstNode.PositionComparator()); } comments.add(comment); comment.setParent(this); }
java
public void addComment(Comment comment) { assertNotNull(comment); if (comments == null) { comments = new TreeSet<Comment>(new AstNode.PositionComparator()); } comments.add(comment); comment.setParent(this); }
[ "public", "void", "addComment", "(", "Comment", "comment", ")", "{", "assertNotNull", "(", "comment", ")", ";", "if", "(", "comments", "==", "null", ")", "{", "comments", "=", "new", "TreeSet", "<", "Comment", ">", "(", "new", "AstNode", ".", "PositionComparator", "(", ")", ")", ";", "}", "comments", ".", "add", "(", "comment", ")", ";", "comment", ".", "setParent", "(", "this", ")", ";", "}" ]
Add a comment to the comment set. @param comment the comment node. @throws IllegalArgumentException if comment is {@code null}
[ "Add", "a", "comment", "to", "the", "comment", "set", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstRoot.java#L69-L76
21,384
mozilla/rhino
src/org/mozilla/javascript/ast/AstRoot.java
AstRoot.checkParentLinks
public void checkParentLinks() { this.visit(new NodeVisitor() { @Override public boolean visit(AstNode node) { int type = node.getType(); if (type == Token.SCRIPT) return true; if (node.getParent() == null) throw new IllegalStateException ("No parent for node: " + node + "\n" + node.toSource(0)); return true; } }); }
java
public void checkParentLinks() { this.visit(new NodeVisitor() { @Override public boolean visit(AstNode node) { int type = node.getType(); if (type == Token.SCRIPT) return true; if (node.getParent() == null) throw new IllegalStateException ("No parent for node: " + node + "\n" + node.toSource(0)); return true; } }); }
[ "public", "void", "checkParentLinks", "(", ")", "{", "this", ".", "visit", "(", "new", "NodeVisitor", "(", ")", "{", "@", "Override", "public", "boolean", "visit", "(", "AstNode", "node", ")", "{", "int", "type", "=", "node", ".", "getType", "(", ")", ";", "if", "(", "type", "==", "Token", ".", "SCRIPT", ")", "return", "true", ";", "if", "(", "node", ".", "getParent", "(", ")", "==", "null", ")", "throw", "new", "IllegalStateException", "(", "\"No parent for node: \"", "+", "node", "+", "\"\\n\"", "+", "node", ".", "toSource", "(", "0", ")", ")", ";", "return", "true", ";", "}", "}", ")", ";", "}" ]
Debugging function to check that the parser has set the parent link for every node in the tree. @throws IllegalStateException if a parent link is missing
[ "Debugging", "function", "to", "check", "that", "the", "parser", "has", "set", "the", "parent", "link", "for", "every", "node", "in", "the", "tree", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstRoot.java#L132-L146
21,385
mozilla/rhino
src/org/mozilla/javascript/ast/FunctionCall.java
FunctionCall.setArguments
public void setArguments(List<AstNode> arguments) { if (arguments == null) { this.arguments = null; } else { if (this.arguments != null) this.arguments.clear(); for (AstNode arg : arguments) { addArgument(arg); } } }
java
public void setArguments(List<AstNode> arguments) { if (arguments == null) { this.arguments = null; } else { if (this.arguments != null) this.arguments.clear(); for (AstNode arg : arguments) { addArgument(arg); } } }
[ "public", "void", "setArguments", "(", "List", "<", "AstNode", ">", "arguments", ")", "{", "if", "(", "arguments", "==", "null", ")", "{", "this", ".", "arguments", "=", "null", ";", "}", "else", "{", "if", "(", "this", ".", "arguments", "!=", "null", ")", "this", ".", "arguments", ".", "clear", "(", ")", ";", "for", "(", "AstNode", "arg", ":", "arguments", ")", "{", "addArgument", "(", "arg", ")", ";", "}", "}", "}" ]
Sets function argument list @param arguments function argument list. Can be {@code null}, in which case any existing args are removed.
[ "Sets", "function", "argument", "list" ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/FunctionCall.java#L76-L86
21,386
mozilla/rhino
src/org/mozilla/javascript/ast/FunctionCall.java
FunctionCall.addArgument
public void addArgument(AstNode arg) { assertNotNull(arg); if (arguments == null) { arguments = new ArrayList<AstNode>(); } arguments.add(arg); arg.setParent(this); }
java
public void addArgument(AstNode arg) { assertNotNull(arg); if (arguments == null) { arguments = new ArrayList<AstNode>(); } arguments.add(arg); arg.setParent(this); }
[ "public", "void", "addArgument", "(", "AstNode", "arg", ")", "{", "assertNotNull", "(", "arg", ")", ";", "if", "(", "arguments", "==", "null", ")", "{", "arguments", "=", "new", "ArrayList", "<", "AstNode", ">", "(", ")", ";", "}", "arguments", ".", "add", "(", "arg", ")", ";", "arg", ".", "setParent", "(", "this", ")", ";", "}" ]
Adds an argument to the list, and sets its parent to this node. @param arg the argument node to add to the list @throws IllegalArgumentException} if arg is {@code null}
[ "Adds", "an", "argument", "to", "the", "list", "and", "sets", "its", "parent", "to", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/FunctionCall.java#L93-L100
21,387
mozilla/rhino
src/org/mozilla/javascript/ast/ScriptNode.java
ScriptNode.addRegExp
public void addRegExp(RegExpLiteral re) { if (re == null) codeBug(); if (regexps == null) regexps = new ArrayList<RegExpLiteral>(); regexps.add(re); re.putIntProp(REGEXP_PROP, regexps.size() - 1); }
java
public void addRegExp(RegExpLiteral re) { if (re == null) codeBug(); if (regexps == null) regexps = new ArrayList<RegExpLiteral>(); regexps.add(re); re.putIntProp(REGEXP_PROP, regexps.size() - 1); }
[ "public", "void", "addRegExp", "(", "RegExpLiteral", "re", ")", "{", "if", "(", "re", "==", "null", ")", "codeBug", "(", ")", ";", "if", "(", "regexps", "==", "null", ")", "regexps", "=", "new", "ArrayList", "<", "RegExpLiteral", ">", "(", ")", ";", "regexps", ".", "add", "(", "re", ")", ";", "re", ".", "putIntProp", "(", "REGEXP_PROP", ",", "regexps", ".", "size", "(", ")", "-", "1", ")", ";", "}" ]
Called by IRFactory to add a RegExp to the regexp table.
[ "Called", "by", "IRFactory", "to", "add", "a", "RegExp", "to", "the", "regexp", "table", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/ScriptNode.java#L202-L208
21,388
mozilla/rhino
src/org/mozilla/javascript/ast/ScriptNode.java
ScriptNode.flattenSymbolTable
public void flattenSymbolTable(boolean flattenAllTables) { if (!flattenAllTables) { List<Symbol> newSymbols = new ArrayList<Symbol>(); if (this.symbolTable != null) { // Just replace "symbols" with the symbols in this object's // symbol table. Can't just work from symbolTable map since // we need to retain duplicate parameters. for (int i = 0; i < symbols.size(); i++) { Symbol symbol = symbols.get(i); if (symbol.getContainingTable() == this) { newSymbols.add(symbol); } } } symbols = newSymbols; } variableNames = new String[symbols.size()]; isConsts = new boolean[symbols.size()]; for (int i = 0; i < symbols.size(); i++) { Symbol symbol = symbols.get(i); variableNames[i] = symbol.getName(); isConsts[i] = symbol.getDeclType() == Token.CONST; symbol.setIndex(i); } }
java
public void flattenSymbolTable(boolean flattenAllTables) { if (!flattenAllTables) { List<Symbol> newSymbols = new ArrayList<Symbol>(); if (this.symbolTable != null) { // Just replace "symbols" with the symbols in this object's // symbol table. Can't just work from symbolTable map since // we need to retain duplicate parameters. for (int i = 0; i < symbols.size(); i++) { Symbol symbol = symbols.get(i); if (symbol.getContainingTable() == this) { newSymbols.add(symbol); } } } symbols = newSymbols; } variableNames = new String[symbols.size()]; isConsts = new boolean[symbols.size()]; for (int i = 0; i < symbols.size(); i++) { Symbol symbol = symbols.get(i); variableNames[i] = symbol.getName(); isConsts[i] = symbol.getDeclType() == Token.CONST; symbol.setIndex(i); } }
[ "public", "void", "flattenSymbolTable", "(", "boolean", "flattenAllTables", ")", "{", "if", "(", "!", "flattenAllTables", ")", "{", "List", "<", "Symbol", ">", "newSymbols", "=", "new", "ArrayList", "<", "Symbol", ">", "(", ")", ";", "if", "(", "this", ".", "symbolTable", "!=", "null", ")", "{", "// Just replace \"symbols\" with the symbols in this object's", "// symbol table. Can't just work from symbolTable map since", "// we need to retain duplicate parameters.", "for", "(", "int", "i", "=", "0", ";", "i", "<", "symbols", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Symbol", "symbol", "=", "symbols", ".", "get", "(", "i", ")", ";", "if", "(", "symbol", ".", "getContainingTable", "(", ")", "==", "this", ")", "{", "newSymbols", ".", "add", "(", "symbol", ")", ";", "}", "}", "}", "symbols", "=", "newSymbols", ";", "}", "variableNames", "=", "new", "String", "[", "symbols", ".", "size", "(", ")", "]", ";", "isConsts", "=", "new", "boolean", "[", "symbols", ".", "size", "(", ")", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "symbols", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Symbol", "symbol", "=", "symbols", ".", "get", "(", "i", ")", ";", "variableNames", "[", "i", "]", "=", "symbol", ".", "getName", "(", ")", ";", "isConsts", "[", "i", "]", "=", "symbol", ".", "getDeclType", "(", ")", "==", "Token", ".", "CONST", ";", "symbol", ".", "setIndex", "(", "i", ")", ";", "}", "}" ]
Assign every symbol a unique integer index. Generate arrays of variable names and constness that can be indexed by those indices. @param flattenAllTables if true, flatten all symbol tables, included nested block scope symbol tables. If false, just flatten the script's or function's symbol table.
[ "Assign", "every", "symbol", "a", "unique", "integer", "index", ".", "Generate", "arrays", "of", "variable", "names", "and", "constness", "that", "can", "be", "indexed", "by", "those", "indices", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/ScriptNode.java#L267-L291
21,389
mozilla/rhino
src/org/mozilla/javascript/ast/LabeledStatement.java
LabeledStatement.setLabels
public void setLabels(List<Label> labels) { assertNotNull(labels); if (this.labels != null) this.labels.clear(); for (Label l : labels) { addLabel(l); } }
java
public void setLabels(List<Label> labels) { assertNotNull(labels); if (this.labels != null) this.labels.clear(); for (Label l : labels) { addLabel(l); } }
[ "public", "void", "setLabels", "(", "List", "<", "Label", ">", "labels", ")", "{", "assertNotNull", "(", "labels", ")", ";", "if", "(", "this", ".", "labels", "!=", "null", ")", "this", ".", "labels", ".", "clear", "(", ")", ";", "for", "(", "Label", "l", ":", "labels", ")", "{", "addLabel", "(", "l", ")", ";", "}", "}" ]
Sets label list, setting the parent of each label in the list. Replaces any existing labels. @throws IllegalArgumentException} if labels is {@code null}
[ "Sets", "label", "list", "setting", "the", "parent", "of", "each", "label", "in", "the", "list", ".", "Replaces", "any", "existing", "labels", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/LabeledStatement.java#L53-L60
21,390
mozilla/rhino
src/org/mozilla/javascript/ast/LabeledStatement.java
LabeledStatement.addLabel
public void addLabel(Label label) { assertNotNull(label); labels.add(label); label.setParent(this); }
java
public void addLabel(Label label) { assertNotNull(label); labels.add(label); label.setParent(this); }
[ "public", "void", "addLabel", "(", "Label", "label", ")", "{", "assertNotNull", "(", "label", ")", ";", "labels", ".", "add", "(", "label", ")", ";", "label", ".", "setParent", "(", "this", ")", ";", "}" ]
Adds a label and sets its parent to this node. @throws IllegalArgumentException} if label is {@code null}
[ "Adds", "a", "label", "and", "sets", "its", "parent", "to", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/LabeledStatement.java#L66-L70
21,391
mozilla/rhino
src/org/mozilla/javascript/ast/LabeledStatement.java
LabeledStatement.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (AstNode label : labels) { label.visit(v); } statement.visit(v); } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (AstNode label : labels) { label.visit(v); } statement.visit(v); } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "for", "(", "AstNode", "label", ":", "labels", ")", "{", "label", ".", "visit", "(", "v", ")", ";", "}", "statement", ".", "visit", "(", "v", ")", ";", "}", "}" ]
Visits this node, then each label in the label-list, and finally the statement.
[ "Visits", "this", "node", "then", "each", "label", "in", "the", "label", "-", "list", "and", "finally", "the", "statement", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/LabeledStatement.java#L127-L135
21,392
mozilla/rhino
src/org/mozilla/javascript/ast/XmlLiteral.java
XmlLiteral.setFragments
public void setFragments(List<XmlFragment> fragments) { assertNotNull(fragments); this.fragments.clear(); for (XmlFragment fragment : fragments) addFragment(fragment); }
java
public void setFragments(List<XmlFragment> fragments) { assertNotNull(fragments); this.fragments.clear(); for (XmlFragment fragment : fragments) addFragment(fragment); }
[ "public", "void", "setFragments", "(", "List", "<", "XmlFragment", ">", "fragments", ")", "{", "assertNotNull", "(", "fragments", ")", ";", "this", ".", "fragments", ".", "clear", "(", ")", ";", "for", "(", "XmlFragment", "fragment", ":", "fragments", ")", "addFragment", "(", "fragment", ")", ";", "}" ]
Sets fragment list, removing any existing fragments first. Sets the parent pointer for each fragment in the list to this node. @param fragments fragment list. Replaces any existing fragments. @throws IllegalArgumentException} if {@code fragments} is {@code null}
[ "Sets", "fragment", "list", "removing", "any", "existing", "fragments", "first", ".", "Sets", "the", "parent", "pointer", "for", "each", "fragment", "in", "the", "list", "to", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/XmlLiteral.java#L53-L58
21,393
mozilla/rhino
src/org/mozilla/javascript/ast/XmlLiteral.java
XmlLiteral.addFragment
public void addFragment(XmlFragment fragment) { assertNotNull(fragment); fragments.add(fragment); fragment.setParent(this); }
java
public void addFragment(XmlFragment fragment) { assertNotNull(fragment); fragments.add(fragment); fragment.setParent(this); }
[ "public", "void", "addFragment", "(", "XmlFragment", "fragment", ")", "{", "assertNotNull", "(", "fragment", ")", ";", "fragments", ".", "add", "(", "fragment", ")", ";", "fragment", ".", "setParent", "(", "this", ")", ";", "}" ]
Adds a fragment to the fragment list. Sets its parent to this node. @throws IllegalArgumentException} if {@code fragment} is {@code null}
[ "Adds", "a", "fragment", "to", "the", "fragment", "list", ".", "Sets", "its", "parent", "to", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/XmlLiteral.java#L64-L68
21,394
mozilla/rhino
src/org/mozilla/javascript/ast/XmlLiteral.java
XmlLiteral.visit
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (XmlFragment frag : fragments) { frag.visit(v); } } }
java
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (XmlFragment frag : fragments) { frag.visit(v); } } }
[ "@", "Override", "public", "void", "visit", "(", "NodeVisitor", "v", ")", "{", "if", "(", "v", ".", "visit", "(", "this", ")", ")", "{", "for", "(", "XmlFragment", "frag", ":", "fragments", ")", "{", "frag", ".", "visit", "(", "v", ")", ";", "}", "}", "}" ]
Visits this node, then visits each child fragment in lexical order.
[ "Visits", "this", "node", "then", "visits", "each", "child", "fragment", "in", "lexical", "order", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/XmlLiteral.java#L82-L89
21,395
mozilla/rhino
src/org/mozilla/javascript/ast/AstNode.java
AstNode.getAbsolutePosition
public int getAbsolutePosition() { int pos = position; AstNode parent = this.parent; while (parent != null) { pos += parent.getPosition(); parent = parent.getParent(); } return pos; }
java
public int getAbsolutePosition() { int pos = position; AstNode parent = this.parent; while (parent != null) { pos += parent.getPosition(); parent = parent.getParent(); } return pos; }
[ "public", "int", "getAbsolutePosition", "(", ")", "{", "int", "pos", "=", "position", ";", "AstNode", "parent", "=", "this", ".", "parent", ";", "while", "(", "parent", "!=", "null", ")", "{", "pos", "+=", "parent", ".", "getPosition", "(", ")", ";", "parent", "=", "parent", ".", "getParent", "(", ")", ";", "}", "return", "pos", ";", "}" ]
Returns the absolute document position of the node. Computes it by adding the node's relative position to the relative positions of all its parents.
[ "Returns", "the", "absolute", "document", "position", "of", "the", "node", ".", "Computes", "it", "by", "adding", "the", "node", "s", "relative", "position", "to", "the", "relative", "positions", "of", "all", "its", "parents", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstNode.java#L194-L202
21,396
mozilla/rhino
src/org/mozilla/javascript/ast/AstNode.java
AstNode.setParent
public void setParent(AstNode parent) { if (parent == this.parent) { return; } // Convert position back to absolute. if (this.parent != null) { setRelative(-this.parent.getAbsolutePosition()); } this.parent = parent; if (parent != null) { setRelative(parent.getAbsolutePosition()); } }
java
public void setParent(AstNode parent) { if (parent == this.parent) { return; } // Convert position back to absolute. if (this.parent != null) { setRelative(-this.parent.getAbsolutePosition()); } this.parent = parent; if (parent != null) { setRelative(parent.getAbsolutePosition()); } }
[ "public", "void", "setParent", "(", "AstNode", "parent", ")", "{", "if", "(", "parent", "==", "this", ".", "parent", ")", "{", "return", ";", "}", "// Convert position back to absolute.", "if", "(", "this", ".", "parent", "!=", "null", ")", "{", "setRelative", "(", "-", "this", ".", "parent", ".", "getAbsolutePosition", "(", ")", ")", ";", "}", "this", ".", "parent", "=", "parent", ";", "if", "(", "parent", "!=", "null", ")", "{", "setRelative", "(", "parent", ".", "getAbsolutePosition", "(", ")", ")", ";", "}", "}" ]
Sets the node parent. This method automatically adjusts the current node's start position to be relative to the new parent. @param parent the new parent. Can be {@code null}.
[ "Sets", "the", "node", "parent", ".", "This", "method", "automatically", "adjusts", "the", "current", "node", "s", "start", "position", "to", "be", "relative", "to", "the", "new", "parent", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstNode.java#L250-L264
21,397
mozilla/rhino
src/org/mozilla/javascript/ast/AstNode.java
AstNode.addChild
public void addChild(AstNode kid) { assertNotNull(kid); int end = kid.getPosition() + kid.getLength(); setLength(end - this.getPosition()); addChildToBack(kid); kid.setParent(this); }
java
public void addChild(AstNode kid) { assertNotNull(kid); int end = kid.getPosition() + kid.getLength(); setLength(end - this.getPosition()); addChildToBack(kid); kid.setParent(this); }
[ "public", "void", "addChild", "(", "AstNode", "kid", ")", "{", "assertNotNull", "(", "kid", ")", ";", "int", "end", "=", "kid", ".", "getPosition", "(", ")", "+", "kid", ".", "getLength", "(", ")", ";", "setLength", "(", "end", "-", "this", ".", "getPosition", "(", ")", ")", ";", "addChildToBack", "(", "kid", ")", ";", "kid", ".", "setParent", "(", "this", ")", ";", "}" ]
Adds a child or function to the end of the block. Sets the parent of the child to this node, and fixes up the start position of the child to be relative to this node. Sets the length of this node to include the new child. @param kid the child @throws IllegalArgumentException if kid is {@code null}
[ "Adds", "a", "child", "or", "function", "to", "the", "end", "of", "the", "block", ".", "Sets", "the", "parent", "of", "the", "child", "to", "this", "node", "and", "fixes", "up", "the", "start", "position", "of", "the", "child", "to", "be", "relative", "to", "this", "node", ".", "Sets", "the", "length", "of", "this", "node", "to", "include", "the", "new", "child", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstNode.java#L274-L280
21,398
mozilla/rhino
src/org/mozilla/javascript/ast/AstNode.java
AstNode.getAstRoot
public AstRoot getAstRoot() { AstNode parent = this; // this node could be the AstRoot while (parent != null && !(parent instanceof AstRoot)) { parent = parent.getParent(); } return (AstRoot)parent; }
java
public AstRoot getAstRoot() { AstNode parent = this; // this node could be the AstRoot while (parent != null && !(parent instanceof AstRoot)) { parent = parent.getParent(); } return (AstRoot)parent; }
[ "public", "AstRoot", "getAstRoot", "(", ")", "{", "AstNode", "parent", "=", "this", ";", "// this node could be the AstRoot", "while", "(", "parent", "!=", "null", "&&", "!", "(", "parent", "instanceof", "AstRoot", ")", ")", "{", "parent", "=", "parent", ".", "getParent", "(", ")", ";", "}", "return", "(", "AstRoot", ")", "parent", ";", "}" ]
Returns the root of the tree containing this node. @return the {@link AstRoot} at the root of this node's parent chain, or {@code null} if the topmost parent is not an {@code AstRoot}.
[ "Returns", "the", "root", "of", "the", "tree", "containing", "this", "node", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstNode.java#L287-L293
21,399
mozilla/rhino
src/org/mozilla/javascript/ast/AstNode.java
AstNode.shortName
public String shortName() { String classname = getClass().getName(); int last = classname.lastIndexOf("."); return classname.substring(last + 1); }
java
public String shortName() { String classname = getClass().getName(); int last = classname.lastIndexOf("."); return classname.substring(last + 1); }
[ "public", "String", "shortName", "(", ")", "{", "String", "classname", "=", "getClass", "(", ")", ".", "getName", "(", ")", ";", "int", "last", "=", "classname", ".", "lastIndexOf", "(", "\".\"", ")", ";", "return", "classname", ".", "substring", "(", "last", "+", "1", ")", ";", "}" ]
Returns a short, descriptive name for the node, such as "ArrayComprehension".
[ "Returns", "a", "short", "descriptive", "name", "for", "the", "node", "such", "as", "ArrayComprehension", "." ]
fa8a86df11d37623f5faa8d445a5876612bc47b0
https://github.com/mozilla/rhino/blob/fa8a86df11d37623f5faa8d445a5876612bc47b0/src/org/mozilla/javascript/ast/AstNode.java#L334-L338