void CScStack::Push(CScValue *Val) { m_SP++; if (m_SP < m_Values.GetSize()) { m_Values[m_SP]->Cleanup(); m_Values[m_SP]->Copy(Val); } else { CScValue *val = new CScValue(Game); val->Copy(Val); m_Values.Add(val); } }
HRESULT CScValue::SetProp(char *Name, CScValue *Val, bool CopyWhole, bool SetAsConst) { if(m_Type==VAL_VARIABLE_REF) return m_ValRef->SetProp(Name, Val); HRESULT ret = E_FAIL; if(m_Type==VAL_NATIVE && m_ValNative) { ret = m_ValNative->ScSetProperty(Name, Val); } if(FAILED(ret)) { CScValue* val = NULL; m_ValIter = m_ValObject.find(Name); if (m_ValIter != m_ValObject.end()) { val = m_ValIter->second; } if(!val) val = new CScValue(Game); else val->Cleanup(); val->Copy(Val, CopyWhole); val->m_IsConstVar = SetAsConst; m_ValObject[Name] = val; if(m_Type!=VAL_NATIVE) m_Type = VAL_OBJECT; /* m_ValIter = m_ValObject.find(Name); if (m_ValIter != m_ValObject.end()){ delete m_ValIter->second; m_ValIter->second = NULL; } CScValue* val = new CScValue(Game); val->Copy(Val, CopyWhole); val->m_IsConstVar = SetAsConst; m_ValObject[Name] = val; if(m_Type!=VAL_NATIVE) m_Type = VAL_OBJECT; */ } return S_OK; }