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
Marco Bubke
flatpak-qt-creator
Commits
95849cb0
Commit
95849cb0
authored
Feb 02, 2010
by
Roberto Raggi
Browse files
Store bindings and definitions in one single table.
parent
d5326f37
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsbind.cpp
View file @
95849cb0
...
...
@@ -270,7 +270,7 @@ bool Bind::visit(UiPublicMember *)
bool
Bind
::
visit
(
UiObjectDefinition
*
ast
)
{
ObjectValue
*
value
=
bindObject
(
ast
->
qualifiedTypeNameId
,
ast
->
initializer
);
_qmlObject
Definition
s
.
insert
(
ast
,
value
);
_qmlObjects
.
insert
(
ast
,
value
);
return
false
;
}
...
...
@@ -279,7 +279,7 @@ bool Bind::visit(UiObjectBinding *ast)
{
// const QString name = serialize(ast->qualifiedId);
ObjectValue
*
value
=
bindObject
(
ast
->
qualifiedTypeNameId
,
ast
->
initializer
);
_qmlObject
Binding
s
.
insert
(
ast
,
value
);
_qmlObjects
.
insert
(
ast
,
value
);
// ### FIXME: we don't handle dot-properties correctly (i.e. font.size)
// _currentObjectValue->setProperty(name, value);
...
...
src/libs/qmljs/qmljsbind.h
View file @
95849cb0
...
...
@@ -83,8 +83,7 @@ private:
Interpreter
::
ObjectValue
*
_functionEnvironment
;
Interpreter
::
ObjectValue
*
_rootObjectValue
;
QHash
<
AST
::
UiObjectDefinition
*
,
Interpreter
::
ObjectValue
*>
_qmlObjectDefinitions
;
QHash
<
AST
::
UiObjectBinding
*
,
Interpreter
::
ObjectValue
*>
_qmlObjectBindings
;
QHash
<
AST
::
Node
*
,
Interpreter
::
ObjectValue
*>
_qmlObjects
;
QStringList
_includedScripts
;
QStringList
_localImports
;
...
...
src/libs/qmljs/qmljslink.cpp
View file @
95849cb0
...
...
@@ -31,11 +31,7 @@ Link::~Link()
bind
->
_idEnvironment
->
setScope
(
0
);
bind
->
_functionEnvironment
->
setScope
(
0
);
foreach
(
ObjectValue
*
object
,
bind
->
_qmlObjectBindings
)
{
object
->
setPrototype
(
0
);
object
->
setScope
(
0
);
}
foreach
(
ObjectValue
*
object
,
bind
->
_qmlObjectDefinitions
)
{
foreach
(
ObjectValue
*
object
,
bind
->
_qmlObjects
)
{
object
->
setPrototype
(
0
);
object
->
setScope
(
0
);
}
...
...
@@ -55,13 +51,9 @@ ObjectValue *Link::scopeChainAt(Document::Ptr doc, Node *currentObject)
{
BindPtr
bind
=
doc
->
bind
();
ObjectValue
*
scopeObject
;
ObjectValue
*
scopeObject
=
0
;
if
(
UiObjectDefinition
*
definition
=
cast
<
UiObjectDefinition
*>
(
currentObject
))
scopeObject
=
bind
->
_qmlObjectDefinitions
.
value
(
definition
);
else
if
(
UiObjectBinding
*
binding
=
cast
<
UiObjectBinding
*>
(
currentObject
))
scopeObject
=
bind
->
_qmlObjectBindings
.
value
(
binding
);
else
return
bind
->
_interp
.
globalObject
();
scopeObject
=
bind
->
_qmlObjects
.
value
(
definition
);
if
(
!
scopeObject
)
return
bind
->
_interp
.
globalObject
();
...
...
@@ -103,29 +95,14 @@ void Link::linkImports()
populateImportedTypes
(
typeEnv
,
doc
);
// Set the prototypes.
{
QHash
<
UiObjectDefinition
*
,
ObjectValue
*>::
iterator
it
=
bind
->
_qmlObjectDefinitions
.
begin
();
QHash
<
UiObjectDefinition
*
,
ObjectValue
*>::
iterator
end
=
bind
->
_qmlObjectDefinitions
.
end
();
for
(;
it
!=
end
;
++
it
)
{
UiObjectDefinition
*
key
=
it
.
key
();
ObjectValue
*
value
=
it
.
value
();
if
(
!
key
->
qualifiedTypeNameId
)
continue
;
value
->
setPrototype
(
lookupType
(
typeEnv
,
key
->
qualifiedTypeNameId
));
}
}
{
QHash
<
UiObjectBinding
*
,
ObjectValue
*>::
iterator
it
=
bind
->
_qmlObjectBindings
.
begin
();
QHash
<
UiObjectBinding
*
,
ObjectValue
*>::
iterator
end
=
bind
->
_qmlObjectBindings
.
end
();
for
(;
it
!=
end
;
++
it
)
{
UiObjectBinding
*
key
=
it
.
key
();
ObjectValue
*
value
=
it
.
value
();
if
(
!
key
->
qualifiedTypeNameId
)
continue
;
value
->
setPrototype
(
lookupType
(
typeEnv
,
key
->
qualifiedTypeNameId
));
}
QHashIterator
<
Node
*
,
ObjectValue
*>
it
(
bind
->
_qmlObjects
);
while
(
it
.
hasNext
())
{
it
.
next
();
Node
*
binding
=
it
.
key
();
ObjectValue
*
value
=
it
.
value
();
if
(
UiQualifiedId
*
qualifiedId
=
qualifiedTypeNameId
(
binding
))
value
->
setPrototype
(
lookupType
(
typeEnv
,
qualifiedId
));
}
}
}
...
...
@@ -290,6 +267,16 @@ const ObjectValue *Link::lookupType(ObjectValue *env, UiQualifiedId *id)
return
objectValue
;
}
UiQualifiedId
*
Link
::
qualifiedTypeNameId
(
Node
*
node
)
{
if
(
UiObjectBinding
*
binding
=
AST
::
cast
<
UiObjectBinding
*>
(
node
))
return
binding
->
qualifiedTypeNameId
;
else
if
(
UiObjectDefinition
*
binding
=
AST
::
cast
<
UiObjectDefinition
*>
(
node
))
return
binding
->
qualifiedTypeNameId
;
else
return
0
;
}
QList
<
Document
::
Ptr
>
Link
::
reachableDocuments
(
Document
::
Ptr
startDoc
,
const
Snapshot
&
snapshot
)
{
QList
<
Document
::
Ptr
>
docs
;
...
...
src/libs/qmljs/qmljslink.h
View file @
95849cb0
...
...
@@ -29,6 +29,7 @@ public:
private:
static
QList
<
Document
::
Ptr
>
reachableDocuments
(
Document
::
Ptr
startDoc
,
const
Snapshot
&
snapshot
);
static
const
Interpreter
::
ObjectValue
*
lookupType
(
Interpreter
::
ObjectValue
*
env
,
AST
::
UiQualifiedId
*
id
);
static
AST
::
UiQualifiedId
*
qualifiedTypeNameId
(
AST
::
Node
*
node
);
void
linkImports
();
...
...
@@ -37,7 +38,7 @@ private:
AST
::
UiImport
*
import
,
const
QString
&
startPath
);
void
importNonFile
(
Interpreter
::
ObjectValue
*
typeEnv
,
Document
::
Ptr
doc
,
AST
::
UiImport
*
import
);
void
importObject
(
BindPtr
bind
,
const
QString
&
name
,
Interpreter
::
ObjectValue
*
object
,
NameId
*
targetNamespace
);
void
importObject
(
BindPtr
bind
,
const
QString
&
name
,
Interpreter
::
ObjectValue
*
object
,
NameId
*
targetNamespace
);
private:
Snapshot
_snapshot
;
...
...
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