forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticType.cpp
More file actions
86 lines (77 loc) · 2.96 KB
/
StaticType.cpp
File metadata and controls
86 lines (77 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "RuntimeTypePch.h"
namespace Js
{
StaticType *
StaticType::New(ScriptContext* scriptContext, TypeId typeId, RecyclableObject* prototype, JavascriptMethod entryPoint)
{
return RecyclerNew(scriptContext->GetRecycler(), StaticType, scriptContext, typeId, prototype, entryPoint);
}
bool
StaticType::Is(TypeId typeId)
{
return typeId <= TypeIds_LastStaticType;
}
BOOL RecyclableObject::GetDiagValueString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext)
{
ENTER_PINNED_SCOPE(JavascriptString, valueStr);
ScriptContext *scriptContext = GetScriptContext();
switch(GetTypeId())
{
case TypeIds_Undefined:
valueStr = GetLibrary()->GetUndefinedDisplayString();
break;
case TypeIds_Null:
valueStr = GetLibrary()->GetNullDisplayString();
break;
case TypeIds_Integer:
valueStr = scriptContext->GetIntegerString(this);
break;
case TypeIds_Boolean:
valueStr = JavascriptBoolean::FromVar(this)->GetValue() ?
GetLibrary()->GetTrueDisplayString()
: GetLibrary()->GetFalseDisplayString();
break;
case TypeIds_Number:
valueStr = JavascriptNumber::ToStringRadix10(JavascriptNumber::GetValue(this), scriptContext);
break;
case TypeIds_String:
valueStr = JavascriptString::FromVar(this);
break;
default:
valueStr = GetLibrary()->GetUndefinedDisplayString();
}
stringBuilder->Append(valueStr->GetString(), valueStr->GetLength());
LEAVE_PINNED_SCOPE();
return TRUE;
}
BOOL RecyclableObject::GetDiagTypeString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext)
{
switch(GetTypeId())
{
case TypeIds_Undefined:
stringBuilder->AppendCppLiteral(_u("Undefined"));
break;
case TypeIds_Null:
stringBuilder->AppendCppLiteral(_u("Null"));
break;
case TypeIds_Integer:
case TypeIds_Number:
stringBuilder->AppendCppLiteral(_u("Number"));
break;
case TypeIds_Boolean:
stringBuilder->AppendCppLiteral(_u("Boolean"));
break;
case TypeIds_String:
stringBuilder->AppendCppLiteral(_u("String"));
break;
default:
stringBuilder->AppendCppLiteral(_u("Object, (Static Type)"));
break;
}
return TRUE;
}
}