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
0cf48cb4
Commit
0cf48cb4
authored
Feb 01, 2010
by
Roberto Raggi
Browse files
Introduced ASTFunctionValue.
parent
450ad48f
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsbind.cpp
View file @
0cf48cb4
...
...
@@ -37,6 +37,58 @@ using namespace QmlJS;
using
namespace
QmlJS
::
AST
;
using
namespace
QmlJS
::
Interpreter
;
namespace
{
class
ASTFunctionValue
:
public
FunctionValue
{
FunctionDeclaration
*
_ast
;
QList
<
NameId
*>
_argumentNames
;
public:
ASTFunctionValue
(
FunctionDeclaration
*
ast
,
Interpreter
::
Engine
*
engine
)
:
FunctionValue
(
engine
),
_ast
(
ast
)
{
setPrototype
(
engine
->
functionPrototype
());
for
(
FormalParameterList
*
it
=
ast
->
formals
;
it
;
it
=
it
->
next
)
_argumentNames
.
append
(
it
->
name
);
}
FunctionDeclaration
*
ast
()
const
{
return
_ast
;
}
virtual
const
Value
*
returnValue
()
const
{
return
engine
()
->
undefinedValue
();
}
virtual
int
argumentCount
()
const
{
return
_argumentNames
.
size
();
}
virtual
const
Value
*
argument
(
int
)
const
{
return
engine
()
->
undefinedValue
();
}
virtual
QString
argumentName
(
int
index
)
const
{
if
(
index
<
_argumentNames
.
size
())
{
if
(
NameId
*
nameId
=
_argumentNames
.
at
(
index
))
return
nameId
->
asString
();
}
return
FunctionValue
::
argumentName
(
index
);
}
virtual
bool
isVariadic
()
const
{
return
true
;
}
};
}
// end of anonymous namespace
Bind
::
Bind
(
Document
::
Ptr
doc
,
Interpreter
::
Engine
*
interp
)
:
_doc
(
doc
),
_interp
(
interp
),
...
...
@@ -261,11 +313,7 @@ bool Bind::visit(FunctionDeclaration *ast)
if
(
_currentObjectValue
->
property
(
ast
->
name
->
asString
()))
return
false
;
Function
*
function
=
_interp
->
newFunction
();
for
(
FormalParameterList
*
iter
=
ast
->
formals
;
iter
;
iter
=
iter
->
next
)
{
function
->
addArgument
(
_interp
->
undefinedValue
());
// ### introduce unknownValue
// ### store argument names
}
ASTFunctionValue
*
function
=
new
ASTFunctionValue
(
ast
,
_interp
);
_currentObjectValue
->
setProperty
(
ast
->
name
->
asString
(),
function
);
return
false
;
// ### eventually want to visit function bodies
}
src/libs/qmljs/qmljsinterpreter.cpp
View file @
0cf48cb4
...
...
@@ -918,7 +918,7 @@ const Value *FunctionValue::argument(int) const
QString
FunctionValue
::
argumentName
(
int
index
)
const
{
return
QString
::
fromLatin1
(
"arg%1"
).
arg
(
index
);
return
QString
::
fromLatin1
(
"arg%1"
).
arg
(
index
+
1
);
}
bool
FunctionValue
::
isVariadic
()
const
...
...
src/plugins/qmljseditor/qmlcodecompletion.cpp
View file @
0cf48cb4
...
...
@@ -424,10 +424,13 @@ void FunctionArgumentWidget::updateHintText()
if
(
i
!=
0
)
prettyMethod
+=
QLatin1String
(
", "
);
prettyMethod
+=
QLatin1String
(
"arg"
);
QString
arg
=
m_signature
.
at
(
i
);
if
(
arg
.
isEmpty
())
{
arg
=
QLatin1String
(
"arg"
);
arg
+=
QString
::
number
(
i
+
1
);
}
if
(
m_minimumArgumentCount
!=
1
)
prettyMethod
+=
QString
::
number
(
i
+
1
);
prettyMethod
+=
arg
;
}
prettyMethod
+=
QLatin1Char
(
')'
);
...
...
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