| 1039 | } |
| 1040 | |
| 1041 | int asCContext::SetArgByte(asUINT arg, asBYTE value) |
| 1042 | { |
| 1043 | if( m_status != asEXECUTION_PREPARED ) |
| 1044 | return asCONTEXT_NOT_PREPARED; |
| 1045 | |
| 1046 | if( arg >= (unsigned)m_initialFunction->parameterTypes.GetLength() ) |
| 1047 | { |
| 1048 | m_status = asEXECUTION_ERROR; |
| 1049 | return asINVALID_ARG; |
| 1050 | } |
| 1051 | |
| 1052 | // Verify the type of the argument |
| 1053 | asCDataType *dt = &m_initialFunction->parameterTypes[arg]; |
| 1054 | if( dt->IsObject() || dt->IsFuncdef() || dt->IsReference() ) |
| 1055 | { |
| 1056 | m_status = asEXECUTION_ERROR; |
| 1057 | return asINVALID_TYPE; |
| 1058 | } |
| 1059 | |
| 1060 | if( dt->GetSizeInMemoryBytes() != 1 ) |
| 1061 | { |
| 1062 | m_status = asEXECUTION_ERROR; |
| 1063 | return asINVALID_TYPE; |
| 1064 | } |
| 1065 | |
| 1066 | // Determine the position of the argument |
| 1067 | int offset = 0; |
| 1068 | if( m_initialFunction->objectType ) |
| 1069 | offset += AS_PTR_SIZE; |
| 1070 | |
| 1071 | // If function returns object by value an extra pointer is pushed on the stack |
| 1072 | if( m_returnValueSize ) |
| 1073 | offset += AS_PTR_SIZE; |
| 1074 | |
| 1075 | for( asUINT n = 0; n < arg; n++ ) |
| 1076 | offset += m_initialFunction->parameterTypes[n].GetSizeOnStackDWords(); |
| 1077 | |
| 1078 | // Set the value |
| 1079 | *(asBYTE*)&m_regs.stackFramePointer[offset] = value; |
| 1080 | |
| 1081 | return 0; |
| 1082 | } |
| 1083 | |
| 1084 | int asCContext::SetArgWord(asUINT arg, asWORD value) |
| 1085 | { |