Exemplo n.º 1
0
void
CMVarNode::Update
	(
	CMVarNode* node
	)
{
	SetValue(node->GetValue());
	SetValid(node->ValueIsValid());

	// value or pointer

	if (!node->HasChildren())
		{
		MakePointer(node->itsIsPointerFlag);
		if (itsIsPointerFlag && HasChildren())
			{
			UpdateContent();
			}
		}

	// struct or static array

	else if (SameElements(node))
		{
		MakePointer(node->itsIsPointerFlag, kJFalse);
		MergeChildren(node);
		}
	else
		{
		MakePointer(node->itsIsPointerFlag, kJFalse);
		StealChildren(node);
		}
}
Exemplo n.º 2
0
void
CMVarNode::UpdateFailed
	(
	const JString& data
	)
{
	SetValue(data);
	MakePointer(kJFalse);
	SetValid(kJFalse);		// faster after deleting children
}
Exemplo n.º 3
0
int main()
#endif
{
	try
	{
		MakePointer(NEW(Game()))->Run();
	}
	catch(Exception* exception)
	{
		std::ostringstream s;
		MakePointer(exception)->PrintStack(s);
#ifdef PRODUCTION
		std::fstream("error.txt", std::ios::out) << s.str() << '\n';
#else
		std::cout << s.str() << '\n';
#endif
	}

	return 0;
}
Exemplo n.º 4
0
ptr<File> FileSystem::TryLoadFile(const String& fileName)
{
	try
	{
		return LoadFile(fileName);
	}
	catch(Exception* exception)
	{
		MakePointer(exception);
		return 0;
	}
}
Exemplo n.º 5
0
void
CMVarNode::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == CMGetLink() && ShouldUpdate(message))
		{
		// root node only

		if (itsShouldUpdateFlag)
			{
			UpdateChildren();
			}
		else
			{
			itsNeedsUpdateFlag = kJTrue;
			}
		}

	else if (sender == itsValueCommand &&
			 message.Is(CMVarCommand::kValueUpdated))
		{
		const CMVarCommand::ValueMessage& info =
			dynamic_cast<const CMVarCommand::ValueMessage&>(message);

		SetValid(kJTrue);
		Update(info.GetRootNode());
		}
	else if (sender == itsValueCommand &&
			 message.Is(CMVarCommand::kValueFailed))
		{
		SetValue(itsValueCommand->GetData());
		MakePointer(kJFalse);
		}

	else if (sender == itsContentCommand &&
			 message.Is(CMVarCommand::kValueUpdated))
		{
		const CMVarCommand::ValueMessage& info =
			dynamic_cast<const CMVarCommand::ValueMessage&>(message);

		CMVarNode* root = info.GetRootNode();

		// value or pointer

		if (!root->HasChildren())
			{
			DeleteAllChildren();
			CMVarNode* child = (CMGetLink())->CreateVarNode(this, root->GetName(),
															root->GetFullName(),
															root->GetValue());
			assert( child != NULL );
			child->MakePointer(root->itsIsPointerFlag);
			}

		// struct or static array

		else if (SameElements(root))
			{
			MergeChildren(root);
			}
		else
			{
			StealChildren(root);
			}
		}
	else if (sender == itsContentCommand &&
			 message.Is(CMVarCommand::kValueFailed))
		{
		DeleteAllChildren();
		CMVarNode* child = (CMGetLink())->CreateVarNode(this, "", "", itsContentCommand->GetData());
		assert( child != NULL );
		child->SetValid(kJFalse);
		}

	else
		{
		JNamedTreeNode::Receive(sender, message);
		}
}
Exemplo n.º 6
0
Arquivo: type.cpp Projeto: wh5a/xgill
Type* Type::Read(Buffer *buf)
{
  uint32_t kind = 0;
  uint32_t width = 0;
  uint32_t count = 0;
  bool sign = false;
  bool varargs = false;
  String *name = NULL;
  Type *target_type = NULL;
  TypeCSU *csu_type = NULL;
  Vector<Type*> argument_types;

  Try(ReadOpenTag(buf, TAG_Type));
  while (!ReadCloseTag(buf, TAG_Type)) {
    switch (PeekOpenTag(buf)) {
    case TAG_Kind: {
      Try(!kind);
      Try(ReadTagUInt32(buf, TAG_Kind, &kind));
      break;
    }
    case TAG_Width: {
      Try(ReadTagUInt32(buf, TAG_Width, &width));
      break;
    }
    case TAG_Sign: {
      Try(ReadTagEmpty(buf, TAG_Sign));
      sign = true;
      break;
    }
    case TAG_Name: {
      Try(!name);
      Try(kind == YK_CSU);
      name = String::ReadWithTag(buf, TAG_Name);
      break;
    }
    case TAG_Type: {
      Try(!target_type);
      Try(kind == YK_Pointer || kind == YK_Array || kind == YK_Function);
      target_type = Type::Read(buf);
      break;
    }
    case TAG_Count: {
      Try(kind == YK_Array);
      Try(ReadTagUInt32(buf, TAG_Count, &count));
      break;
    }
    case TAG_TypeFunctionCSU: {
      Try(!csu_type);
      Try(ReadOpenTag(buf, TAG_TypeFunctionCSU));
      csu_type = Type::Read(buf)->AsCSU();
      Try(ReadCloseTag(buf, TAG_TypeFunctionCSU));
      break;
    }
    case TAG_TypeFunctionVarArgs: {
      Try(kind == YK_Function);
      Try(ReadTagEmpty(buf, TAG_TypeFunctionVarArgs));
      varargs = true;
      break;
    }
    case TAG_TypeFunctionArguments: {
      Try(kind == YK_Function);
      Try(argument_types.Empty());
      Try(ReadOpenTag(buf, TAG_TypeFunctionArguments));
      while (!ReadCloseTag(buf, TAG_TypeFunctionArguments)) {
        Type *ntype = Type::Read(buf);
        argument_types.PushBack(ntype);
      }
      break;
    }
    default:
      Try(false);
    }
  }

  switch ((TypeKind)kind) {
  case YK_Error:
    return MakeError();
  case YK_Void:
    return MakeVoid();
  case YK_Int:
    return MakeInt(width, sign);
  case YK_Float:
    return MakeFloat(width);
  case YK_Pointer:
    Try(target_type);
    return MakePointer(target_type, width);
  case YK_Array:
    Try(target_type);
    return MakeArray(target_type, count);
  case YK_CSU:
    Try(name);
    return MakeCSU(name);
  case YK_Function:
    Try(target_type);
    return MakeFunction(target_type, csu_type, varargs, argument_types);
  default:
    Try(false);
  }
}