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
6dcc675e
Commit
6dcc675e
authored
Feb 01, 2010
by
Roberto Raggi
Browse files
Guess the type of a global variable by looking at its initializer.
parent
a8bc5a4b
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsbind.cpp
View file @
6dcc675e
...
...
@@ -30,6 +30,7 @@
#include
"parser/qmljsast_p.h"
#include
"qmljsbind.h"
#include
"qmljslink.h"
#include
"qmljscheck.h"
#include
"qmljsmetatypesystem.h"
#include
<QtCore/QDir>
...
...
@@ -126,7 +127,8 @@ class ProcessSourceElements: protected AST::Visitor
public:
ProcessSourceElements
(
Interpreter
::
Engine
*
interp
)
:
_interp
(
interp
)
:
_interp
(
interp
),
typeOfExpression
(
interp
)
{
}
...
...
@@ -149,11 +151,19 @@ protected:
virtual
bool
visit
(
VariableDeclaration
*
ast
)
{
if
(
ast
->
name
)
_interp
->
globalObject
()
->
setProperty
(
ast
->
name
->
asString
(),
_interp
->
undefinedValue
());
if
(
ast
->
name
)
{
const
Value
*
value
=
_interp
->
undefinedValue
();
if
(
ast
->
expression
)
value
=
typeOfExpression
(
ast
->
expression
,
_interp
->
globalObject
());
_interp
->
globalObject
()
->
setProperty
(
ast
->
name
->
asString
(),
value
);
}
return
false
;
}
Check
typeOfExpression
;
};
}
// end of anonymous namespace
...
...
src/libs/qmljs/qmljscheck.cpp
View file @
6dcc675e
...
...
@@ -286,13 +286,19 @@ bool Check::visit(AST::FieldMemberExpression *ast)
return
false
;
}
bool
Check
::
visit
(
AST
::
NewMemberExpression
*
)
bool
Check
::
visit
(
AST
::
NewMemberExpression
*
ast
)
{
if
(
const
FunctionValue
*
ctor
=
value_cast
<
const
FunctionValue
*>
(
check
(
ast
->
base
)))
{
_result
=
ctor
->
construct
();
}
return
false
;
}
bool
Check
::
visit
(
AST
::
NewExpression
*
)
bool
Check
::
visit
(
AST
::
NewExpression
*
ast
)
{
if
(
const
FunctionValue
*
ctor
=
value_cast
<
const
FunctionValue
*>
(
check
(
ast
->
expression
)))
{
_result
=
ctor
->
construct
();
}
return
false
;
}
...
...
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