Skip to content
GitLab
Menu
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
aa92c84e
Commit
aa92c84e
authored
Jan 26, 2010
by
Roberto Raggi
Browse files
Group the members of ConvertToString and ConvertToNumber.
parent
204aeb70
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/qmljsinterpreter.cpp
View file @
aa92c84e
...
...
@@ -1060,6 +1060,45 @@ const Value *ConvertToNumber::switchResult(const Value *value)
return
previousResult
;
}
void
ConvertToNumber
::
visit
(
const
NullValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
UndefinedValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
NumberValue
*
value
)
{
_result
=
value
;
}
void
ConvertToNumber
::
visit
(
const
BooleanValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
StringValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
ObjectValue
*
object
)
{
if
(
const
FunctionValue
*
valueOfMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"valueOf"
)))
{
_result
=
value_cast
<
const
NumberValue
*>
(
valueOfMember
->
call
(
object
));
// ### invoke convert-to-number?
}
}
void
ConvertToNumber
::
visit
(
const
FunctionValue
*
object
)
{
if
(
const
FunctionValue
*
valueOfMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"valueOf"
)))
{
_result
=
value_cast
<
const
NumberValue
*>
(
valueOfMember
->
call
(
object
));
// ### invoke convert-to-number?
}
}
ConvertToString
::
ConvertToString
(
Engine
*
engine
)
:
_engine
(
engine
),
_result
(
0
)
{
...
...
@@ -1082,6 +1121,45 @@ const Value *ConvertToString::switchResult(const Value *value)
return
previousResult
;
}
void
ConvertToString
::
visit
(
const
NullValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
UndefinedValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
NumberValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
BooleanValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
StringValue
*
value
)
{
_result
=
value
;
}
void
ConvertToString
::
visit
(
const
ObjectValue
*
object
)
{
if
(
const
FunctionValue
*
toStringMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"toString"
)))
{
_result
=
value_cast
<
const
StringValue
*>
(
toStringMember
->
call
(
object
));
// ### invoke convert-to-string?
}
}
void
ConvertToString
::
visit
(
const
FunctionValue
*
object
)
{
if
(
const
FunctionValue
*
toStringMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"toString"
)))
{
_result
=
value_cast
<
const
StringValue
*>
(
toStringMember
->
call
(
object
));
// ### invoke convert-to-string?
}
}
ConvertToObject
::
ConvertToObject
(
Engine
*
engine
)
:
_engine
(
engine
),
_result
(
0
)
{
...
...
@@ -1740,86 +1818,3 @@ ObjectValue *Engine::newQmlObject(const QString &name)
#endif
}
////////////////////////////////////////////////////////////////////////////////
// convert to number
////////////////////////////////////////////////////////////////////////////////
void
ConvertToNumber
::
visit
(
const
NullValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
UndefinedValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
NumberValue
*
value
)
{
_result
=
value
;
}
void
ConvertToNumber
::
visit
(
const
BooleanValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
StringValue
*
)
{
_result
=
_engine
->
numberValue
();
}
void
ConvertToNumber
::
visit
(
const
ObjectValue
*
object
)
{
if
(
const
FunctionValue
*
valueOfMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"valueOf"
)))
{
_result
=
value_cast
<
const
NumberValue
*>
(
valueOfMember
->
call
(
object
));
// ### invoke convert-to-number?
}
}
void
ConvertToNumber
::
visit
(
const
FunctionValue
*
object
)
{
if
(
const
FunctionValue
*
valueOfMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"valueOf"
)))
{
_result
=
value_cast
<
const
NumberValue
*>
(
valueOfMember
->
call
(
object
));
// ### invoke convert-to-number?
}
}
////////////////////////////////////////////////////////////////////////////////
// convert to string
////////////////////////////////////////////////////////////////////////////////
void
ConvertToString
::
visit
(
const
NullValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
UndefinedValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
NumberValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
BooleanValue
*
)
{
_result
=
_engine
->
stringValue
();
}
void
ConvertToString
::
visit
(
const
StringValue
*
value
)
{
_result
=
value
;
}
void
ConvertToString
::
visit
(
const
ObjectValue
*
object
)
{
if
(
const
FunctionValue
*
toStringMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"toString"
)))
{
_result
=
value_cast
<
const
StringValue
*>
(
toStringMember
->
call
(
object
));
// ### invoke convert-to-string?
}
}
void
ConvertToString
::
visit
(
const
FunctionValue
*
object
)
{
if
(
const
FunctionValue
*
toStringMember
=
value_cast
<
const
FunctionValue
*>
(
object
->
lookup
(
"toString"
)))
{
_result
=
value_cast
<
const
StringValue
*>
(
toStringMember
->
call
(
object
));
// ### invoke convert-to-string?
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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