Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
15ae1001
"src/git@git.qt.io:tohunger/qt-creator.git" did not exist on "f9eea7e1ece035a33e767917dab8e2a26041e5fd"
Commit
15ae1001
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Process QML Script elements.
parent
4d34ee73
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/qmljs/qmljsbind.cpp
+57
-11
57 additions, 11 deletions
src/libs/qmljs/qmljsbind.cpp
src/libs/qmljs/qmljsbind.h
+5
-2
5 additions, 2 deletions
src/libs/qmljs/qmljsbind.h
src/libs/qmljs/qmljslink.cpp
+2
-0
2 additions, 0 deletions
src/libs/qmljs/qmljslink.cpp
with
64 additions
and
13 deletions
src/libs/qmljs/qmljsbind.cpp
+
57
−
11
View file @
15ae1001
...
...
@@ -31,6 +31,9 @@
#include
"qmljsbind.h"
#include
"qmljslink.h"
#include
"qmljsmetatypesystem.h"
#include
<QtCore/QDir>
#include
<QtCore/QFileInfo>
#include
<QtCore/QDebug>
using
namespace
QmlJS
;
...
...
@@ -119,8 +122,9 @@ public:
}
// end of anonymous namespace
Bind
::
Bind
(
Document
::
Ptr
doc
,
Interpreter
::
Engine
*
interp
)
Bind
::
Bind
(
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
,
Interpreter
::
Engine
*
interp
)
:
_doc
(
doc
),
_snapshot
(
snapshot
),
_interp
(
interp
),
_currentObjectValue
(
0
),
_typeEnvironment
(
0
),
...
...
@@ -164,7 +168,7 @@ ObjectValue *Bind::scopeChainAt(Document::Ptr currentDocument, const Snapshot &s
Snapshot
::
const_iterator
end
=
snapshot
.
end
();
for
(
Snapshot
::
const_iterator
iter
=
snapshot
.
begin
();
iter
!=
end
;
++
iter
)
{
Document
::
Ptr
doc
=
*
iter
;
Bind
*
newBind
=
new
Bind
(
doc
,
interp
);
Bind
*
newBind
=
new
Bind
(
doc
,
snapshot
,
interp
);
binds
+=
newBind
;
if
(
doc
==
currentDocument
)
currentBind
=
newBind
;
...
...
@@ -197,22 +201,64 @@ QString Bind::toString(UiQualifiedId *qualifiedId, QChar delimiter)
return
result
;
}
ExpressionNode
*
Bind
::
expression
(
UiScriptBinding
*
ast
)
const
{
if
(
ExpressionStatement
*
statement
=
cast
<
ExpressionStatement
*>
(
ast
->
statement
))
return
statement
->
expression
;
return
0
;
}
void
Bind
::
processScript
(
AST
::
UiQualifiedId
*
qualifiedId
,
AST
::
UiObjectInitializer
*
initializer
)
{
Q_UNUSED
(
qualifiedId
);
if
(
!
initializer
)
return
;
for
(
UiObjectMemberList
*
it
=
initializer
->
members
;
it
;
it
=
it
->
next
)
{
if
(
UiScriptBinding
*
binding
=
cast
<
UiScriptBinding
*>
(
it
->
member
))
{
const
QString
bindingName
=
toString
(
binding
->
qualifiedId
);
if
(
bindingName
==
QLatin1String
(
"source"
))
{
if
(
StringLiteral
*
literal
=
cast
<
StringLiteral
*>
(
expression
(
binding
)))
{
QFileInfo
fileInfo
(
QDir
(
_doc
->
path
()),
literal
->
value
->
asString
());
Document
::
Ptr
script
=
_snapshot
.
document
(
fileInfo
.
absoluteFilePath
());
// ### process the script
}
}
}
else
if
(
UiSourceElement
*
binding
=
cast
<
UiSourceElement
*>
(
it
->
member
))
{
if
(
FunctionDeclaration
*
decl
=
cast
<
FunctionDeclaration
*>
(
binding
->
sourceElement
))
{
accept
(
decl
);
// process the function declaration
}
else
{
// ### unexpected source element
}
}
else
{
// ### unexpected binding.
}
}
}
ObjectValue
*
Bind
::
bindObject
(
UiQualifiedId
*
qualifiedTypeNameId
,
UiObjectInitializer
*
initializer
)
{
ObjectValue
*
parentObjectValue
;
ObjectValue
*
parentObjectValue
=
0
;
const
QString
typeName
=
toString
(
qualifiedTypeNameId
);
if
(
t
oString
(
qualifiedT
ypeName
Id
)
==
QLatin1String
(
"Script"
))
{
if
(
typeName
==
QLatin1String
(
"Script"
))
{
// Script blocks all contribute to the same scope
parentObjectValue
=
switchObjectValue
(
_functionEnvironment
);
}
else
{
// normal component instance
ASTObjectValue
*
objectValue
=
new
ASTObjectValue
(
qualifiedTypeNameId
,
initializer
,
_interp
);
parentObjectValue
=
switchObjectValue
(
objectValue
);
if
(
parentObjectValue
)
objectValue
->
setProperty
(
"parent"
,
parentObjectValue
);
else
_rootObjectValue
=
objectValue
;
processScript
(
qualifiedTypeNameId
,
initializer
);
return
switchObjectValue
(
parentObjectValue
);
}
// normal component instance
ASTObjectValue
*
objectValue
=
new
ASTObjectValue
(
qualifiedTypeNameId
,
initializer
,
_interp
);
parentObjectValue
=
switchObjectValue
(
objectValue
);
if
(
parentObjectValue
)
objectValue
->
setProperty
(
QLatin1String
(
"parent"
),
parentObjectValue
);
else
_rootObjectValue
=
objectValue
;
accept
(
initializer
);
return
switchObjectValue
(
parentObjectValue
);
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljsbind.h
+
5
−
2
View file @
15ae1001
...
...
@@ -44,7 +44,7 @@ class Link;
class
QMLJS_EXPORT
Bind
:
protected
AST
::
Visitor
{
protected:
Bind
(
Document
::
Ptr
doc
,
Interpreter
::
Engine
*
interp
);
Bind
(
Document
::
Ptr
doc
,
const
Snapshot
&
snapshot
,
Interpreter
::
Engine
*
interp
);
public:
virtual
~
Bind
();
...
...
@@ -58,7 +58,9 @@ public:
protected:
using
AST
::
Visitor
::
visit
;
QString
toString
(
AST
::
UiQualifiedId
*
qualifiedId
,
QChar
delimiter
=
QChar
(
'.'
));
static
QString
toString
(
AST
::
UiQualifiedId
*
qualifiedId
,
QChar
delimiter
=
QChar
(
'.'
));
AST
::
ExpressionNode
*
expression
(
AST
::
UiScriptBinding
*
ast
)
const
;
void
processScript
(
AST
::
UiQualifiedId
*
qualifiedId
,
AST
::
UiObjectInitializer
*
initializer
);
void
accept
(
AST
::
Node
*
node
);
...
...
@@ -78,6 +80,7 @@ protected:
private:
Document
::
Ptr
_doc
;
Snapshot
_snapshot
;
Interpreter
::
Engine
*
_interp
;
Interpreter
::
ObjectValue
*
_currentObjectValue
;
...
...
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljslink.cpp
+
2
−
0
View file @
15ae1001
...
...
@@ -147,6 +147,8 @@ void LinkImports::operator()(const QList<Bind *> &binds)
ObjectValue
*
Link
::
operator
()(
const
QList
<
Bind
*>
&
binds
,
Bind
*
currentBind
,
UiObjectMember
*
currentObject
)
{
Q_UNUSED
(
binds
);
ObjectValue
*
scopeObject
;
if
(
UiObjectDefinition
*
definition
=
cast
<
UiObjectDefinition
*>
(
currentObject
))
scopeObject
=
currentBind
->
_qmlObjectDefinitions
.
value
(
definition
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment