2
|
1 |
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
2 |
// Use of this source code is governed by a BSD-style license that can be
|
|
3 |
// found in the LICENSE file.
|
|
4 |
|
|
5 |
package org.chromium.sdk.internal;
|
|
6 |
|
|
7 |
import org.chromium.sdk.JsFunction;
|
|
8 |
import org.chromium.sdk.Script;
|
|
9 |
|
|
10 |
/**
|
|
11 |
* Generic implementation of {@link JsFunction}.
|
|
12 |
*/
|
|
13 |
class JsFunctionImpl extends JsObjectImpl implements JsFunction {
|
|
14 |
JsFunctionImpl(CallFrameImpl callFrame, String parentFqn, ValueMirror valueState) {
|
|
15 |
super(callFrame, parentFqn, valueState);
|
|
16 |
}
|
|
17 |
|
|
18 |
public Script getScript() {
|
|
19 |
FunctionAdditionalProperties additionalProperties =
|
|
20 |
(FunctionAdditionalProperties) getSubpropertiesMirror().getAdditionalProperties();
|
|
21 |
|
|
22 |
int scriptId = additionalProperties.getScriptId();
|
|
23 |
if (scriptId == FunctionAdditionalProperties.NO_SCRIPT_ID) {
|
|
24 |
return null;
|
|
25 |
}
|
|
26 |
DebugSession debugSession = getCallFrame().getInternalContext().getDebugSession();
|
|
27 |
return debugSession.getScriptManager().findById(Long.valueOf(scriptId));
|
|
28 |
}
|
|
29 |
|
|
30 |
public int getSourcePosition() {
|
|
31 |
FunctionAdditionalProperties additionalProperties =
|
|
32 |
(FunctionAdditionalProperties) getSubpropertiesMirror().getAdditionalProperties();
|
|
33 |
|
|
34 |
return additionalProperties.getSourcePosition();
|
|
35 |
}
|
|
36 |
|
|
37 |
@Override
|
|
38 |
public JsFunction asFunction() {
|
|
39 |
return this;
|
|
40 |
}
|
|
41 |
}
|