MCPcopy Create free account
hub / github.com/anjo76/angelscript / CompileConversion

Method CompileConversion

sdk/angelscript/source/as_compiler.cpp:12042–12203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12040}
12041
12042int asCCompiler::CompileConversion(asCScriptNode *node, asCExprContext *ctx)
12043{
12044 asCExprContext expr(engine);
12045 asCDataType to;
12046 bool anyErrors = false;
12047 EImplicitConv convType;
12048 if( node->nodeType == snConstructCall || node->nodeType == snFunctionCall )
12049 {
12050 convType = asIC_EXPLICIT_VAL_CAST;
12051
12052 // Verify that there is only one argument
12053 if( node->lastChild->firstChild == 0 ||
12054 node->lastChild->firstChild != node->lastChild->lastChild )
12055 {
12056 Error(TXT_ONLY_ONE_ARGUMENT_IN_CAST, node->lastChild);
12057 expr.type.SetDummy();
12058 anyErrors = true;
12059 }
12060 else if (node->lastChild->firstChild &&
12061 node->lastChild->firstChild->nodeType == snNamedArgument)
12062 {
12063 Error(TXT_INVALID_USE_OF_NAMED_ARGS, node->lastChild);
12064 expr.type.SetDummy();
12065 anyErrors = true;
12066 }
12067 else
12068 {
12069 // Compile the expression
12070 int r = CompileAssignment(node->lastChild->firstChild, &expr);
12071 if( r < 0 )
12072 anyErrors = true;
12073 }
12074
12075 // Determine the requested type
12076 to = builder->CreateDataTypeFromNode(node->firstChild, script, outFunc->nameSpace, false, 0, true, 0, 0, &m_namespaceVisibility);
12077 to.MakeReadOnly(true); // Default to const
12078 asASSERT(to.IsPrimitive());
12079 }
12080 else
12081 {
12082 convType = asIC_EXPLICIT_REF_CAST;
12083
12084 // Compile the expression
12085 int r = CompileAssignment(node->lastChild, &expr);
12086 if( r < 0 )
12087 anyErrors = true;
12088
12089 // Determine the requested type
12090 to = builder->CreateDataTypeFromNode(node->firstChild, script, outFunc->nameSpace, false, 0, true, 0, 0, &m_namespaceVisibility);
12091
12092 // If the type support object handles, then use it
12093 if( to.SupportHandles() )
12094 {
12095 to.MakeHandle(true);
12096 if( expr.type.dataType.IsObjectConst() )
12097 to.MakeHandleToConst(true);
12098 }
12099 else if( !to.IsObjectHandle() )

Callers

nothing calls this directly

Calls 15

SetDummyMethod · 0.80
MakeReadOnlyMethod · 0.80
IsPrimitiveMethod · 0.80
SupportHandlesMethod · 0.80
MakeHandleMethod · 0.80
IsObjectConstMethod · 0.80
MakeHandleToConstMethod · 0.80
IsObjectHandleMethod · 0.80
GetTypeInfoMethod · 0.80
IsClassMethodMethod · 0.80
IsObjectMethod · 0.80

Tested by

no test coverage detected