Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
bdf8c948
Commit
bdf8c948
authored
Feb 10, 2010
by
Roberto Raggi
Browse files
Get rid off the friend QmlJS::Link declaration.
parent
8f5a1225
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsbind.cpp
View file @
bdf8c948
...
...
@@ -67,6 +67,31 @@ QStringList Bind::localImports() const
return
_localImports
;
}
Interpreter
::
ObjectValue
*
Bind
::
currentObjectValue
()
const
{
return
_currentObjectValue
;
}
Interpreter
::
ObjectValue
*
Bind
::
idEnvironment
()
const
{
return
_idEnvironment
;
}
Interpreter
::
ObjectValue
*
Bind
::
functionEnvironment
()
const
{
return
_functionEnvironment
;
}
Interpreter
::
ObjectValue
*
Bind
::
rootObjectValue
()
const
{
return
_rootObjectValue
;
}
Interpreter
::
ObjectValue
*
Bind
::
findQmlObject
(
AST
::
Node
*
node
)
const
{
return
_qmlObjects
.
value
(
node
);
}
ObjectValue
*
Bind
::
switchObjectValue
(
ObjectValue
*
newObjectValue
)
{
ObjectValue
*
oldObjectValue
=
_currentObjectValue
;
...
...
@@ -139,9 +164,9 @@ ObjectValue *Bind::bindObject(UiQualifiedId *qualifiedTypeNameId, UiObjectInitia
}
// normal component instance
ASTObjectValue
*
objectValue
=
new
ASTObjectValue
(
qualifiedTypeNameId
,
initializer
,
_doc
,
&
_
interp
);
ASTObjectValue
*
objectValue
=
new
ASTObjectValue
(
qualifiedTypeNameId
,
initializer
,
_doc
,
&
_
engine
);
QmlPrototypeReference
*
prototypeReference
=
new
QmlPrototypeReference
(
qualifiedTypeNameId
,
_doc
,
&
_
interp
);
new
QmlPrototypeReference
(
qualifiedTypeNameId
,
_doc
,
&
_
engine
);
objectValue
->
setPrototype
(
prototypeReference
);
parentObjectValue
=
switchObjectValue
(
objectValue
);
...
...
@@ -163,15 +188,15 @@ void Bind::accept(Node *node)
bool
Bind
::
visit
(
AST
::
UiProgram
*
)
{
_idEnvironment
=
_
interp
.
newObject
(
/*prototype =*/
0
);
_functionEnvironment
=
_
interp
.
newObject
(
/*prototype =*/
0
);
_idEnvironment
=
_
engine
.
newObject
(
/*prototype =*/
0
);
_functionEnvironment
=
_
engine
.
newObject
(
/*prototype =*/
0
);
return
true
;
}
bool
Bind
::
visit
(
AST
::
Program
*
)
{
_currentObjectValue
=
_
interp
.
globalObject
();
_rootObjectValue
=
_
interp
.
globalObject
();
_currentObjectValue
=
_
engine
.
globalObject
();
_rootObjectValue
=
_
engine
.
globalObject
();
return
true
;
}
...
...
@@ -237,7 +262,7 @@ bool Bind::visit(VariableDeclaration *ast)
if
(
!
ast
->
name
)
return
false
;
ASTVariableReference
*
ref
=
new
ASTVariableReference
(
ast
,
&
_
interp
);
ASTVariableReference
*
ref
=
new
ASTVariableReference
(
ast
,
&
_
engine
);
_currentObjectValue
->
setProperty
(
ast
->
name
->
asString
(),
ref
);
return
false
;
}
...
...
@@ -250,7 +275,7 @@ bool Bind::visit(FunctionDeclaration *ast)
//if (_currentObjectValue->property(ast->name->asString(), 0))
// return false;
ASTFunctionValue
*
function
=
new
ASTFunctionValue
(
ast
,
&
_
interp
);
ASTFunctionValue
*
function
=
new
ASTFunctionValue
(
ast
,
&
_
engine
);
// ### set the function's scope.
_currentObjectValue
->
setProperty
(
ast
->
name
->
asString
(),
function
);
...
...
src/libs/qmljs/qmljsbind.h
View file @
bdf8c948
...
...
@@ -53,12 +53,17 @@ public:
QStringList
includedScripts
()
const
;
QStringList
localImports
()
const
;
protected:
using
AST
::
Visitor
::
visit
;
Interpreter
::
ObjectValue
*
currentObjectValue
()
const
;
Interpreter
::
ObjectValue
*
idEnvironment
()
const
;
Interpreter
::
ObjectValue
*
functionEnvironment
()
const
;
Interpreter
::
ObjectValue
*
rootObjectValue
()
const
;
Interpreter
::
ObjectValue
*
findQmlObject
(
AST
::
Node
*
node
)
const
;
static
QString
toString
(
AST
::
UiQualifiedId
*
qualifiedId
,
QChar
delimiter
=
QChar
(
'.'
));
AST
::
ExpressionNode
*
expression
(
AST
::
UiScriptBinding
*
ast
)
const
;
void
processScript
(
AST
::
UiQualifiedId
*
qualifiedId
,
AST
::
UiObjectInitializer
*
initializer
);
protected:
using
AST
::
Visitor
::
visit
;
void
accept
(
AST
::
Node
*
node
);
...
...
@@ -77,13 +82,15 @@ protected:
virtual
bool
visit
(
AST
::
FunctionDeclaration
*
ast
);
virtual
bool
visit
(
AST
::
VariableDeclaration
*
ast
);
protected:
Interpreter
::
ObjectValue
*
switchObjectValue
(
Interpreter
::
ObjectValue
*
newObjectValue
);
Interpreter
::
ObjectValue
*
bindObject
(
AST
::
UiQualifiedId
*
qualifiedTypeNameId
,
AST
::
UiObjectInitializer
*
initializer
);
AST
::
ExpressionNode
*
expression
(
AST
::
UiScriptBinding
*
ast
)
const
;
void
processScript
(
AST
::
UiQualifiedId
*
qualifiedId
,
AST
::
UiObjectInitializer
*
initializer
);
private:
Document
*
_doc
;
Interpreter
::
Engine
_
interp
;
Interpreter
::
Engine
_
engine
;
Interpreter
::
ObjectValue
*
_currentObjectValue
;
Interpreter
::
ObjectValue
*
_idEnvironment
;
...
...
@@ -93,8 +100,6 @@ private:
QHash
<
AST
::
Node
*
,
Interpreter
::
ObjectValue
*>
_qmlObjects
;
QStringList
_includedScripts
;
QStringList
_localImports
;
friend
class
Link
;
};
}
// end of namespace Qml
...
...
src/libs/qmljs/qmljsinterpreter.cpp
View file @
bdf8c948
...
...
@@ -732,7 +732,8 @@ void Context::setTypeEnvironment(const QmlJS::Document *doc, const ObjectValue *
void
Context
::
pushScope
(
const
ObjectValue
*
object
)
{
_scopeChain
.
append
(
object
);
if
(
object
!=
0
)
_scopeChain
.
append
(
object
);
}
void
Context
::
popScope
()
...
...
src/libs/qmljs/qmljslink.cpp
View file @
bdf8c948
...
...
@@ -47,11 +47,11 @@ void Link::scopeChainAt(Document::Ptr doc, Node *currentObject)
ObjectValue
*
scopeObject
=
0
;
if
(
UiObjectDefinition
*
definition
=
cast
<
UiObjectDefinition
*>
(
currentObject
))
scopeObject
=
bind
->
_q
mlObject
s
.
value
(
definition
);
scopeObject
=
bind
->
findQ
mlObject
(
definition
);
else
if
(
UiObjectBinding
*
binding
=
cast
<
UiObjectBinding
*>
(
currentObject
))
scopeObject
=
bind
->
_q
mlObject
s
.
value
(
binding
);
scopeObject
=
bind
->
findQ
mlObject
(
binding
);
else
if
(
FunctionDeclaration
*
fun
=
cast
<
FunctionDeclaration
*>
(
currentObject
))
{
_context
->
pushScope
(
bind
->
_
rootObjectValue
);
_context
->
pushScope
(
bind
->
rootObjectValue
()
);
ObjectValue
*
activation
=
engine
()
->
newObject
(
/*prototype = */
0
);
for
(
FormalParameterList
*
it
=
fun
->
formals
;
it
;
it
=
it
->
next
)
{
...
...
@@ -62,10 +62,10 @@ void Link::scopeChainAt(Document::Ptr doc, Node *currentObject)
}
if
(
scopeObject
)
{
if
(
bind
->
_
rootObjectValue
)
_context
->
pushScope
(
bind
->
_
rootObjectValue
);
if
(
bind
->
rootObjectValue
()
)
_context
->
pushScope
(
bind
->
rootObjectValue
()
);
if
(
scopeObject
!=
bind
->
_
rootObjectValue
)
if
(
scopeObject
!=
bind
->
rootObjectValue
()
)
_context
->
pushScope
(
scopeObject
);
}
...
...
@@ -75,16 +75,13 @@ void Link::scopeChainAt(Document::Ptr doc, Node *currentObject)
if
(
Document
::
Ptr
scriptDoc
=
_snapshot
.
document
(
scriptFile
))
{
if
(
scriptDoc
->
jsProgram
())
{
_context
->
pushScope
(
scriptDoc
->
bind
()
->
_
rootObjectValue
);
_context
->
pushScope
(
scriptDoc
->
bind
()
->
rootObjectValue
()
);
}
}
}
if
(
bind
->
_functionEnvironment
)
_context
->
pushScope
(
bind
->
_functionEnvironment
);
if
(
bind
->
_idEnvironment
)
_context
->
pushScope
(
bind
->
_idEnvironment
);
_context
->
pushScope
(
bind
->
functionEnvironment
());
_context
->
pushScope
(
bind
->
idEnvironment
());
if
(
const
ObjectValue
*
typeEnvironment
=
_context
->
typeEnvironment
(
doc
.
data
()))
_context
->
pushScope
(
typeEnvironment
);
...
...
@@ -133,7 +130,7 @@ void Link::populateImportedTypes(Interpreter::ObjectValue *typeEnv, Document::Pt
continue
;
typeEnv
->
setProperty
(
componentName
(
otherFileInfo
.
fileName
()),
otherDoc
->
bind
()
->
_
rootObjectValue
);
otherDoc
->
bind
()
->
rootObjectValue
()
);
}
// explicit imports, whether directories or files
...
...
@@ -197,7 +194,7 @@ void Link::importFile(Interpreter::ObjectValue *typeEnv, Document::Ptr doc,
if
(
importNamespace
)
importInto
=
importNamespace
;
importInto
->
setProperty
(
targetName
,
otherDoc
->
bind
()
->
_
rootObjectValue
);
importInto
->
setProperty
(
targetName
,
otherDoc
->
bind
()
->
rootObjectValue
()
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment