Ejemplo n.º 1
0
void ModuleScope :: saveListMember(ident_t name, ident_t memberName)
{
   // HOTFIX : do not include itself
   IdentifierString sectionName("'", name);

   _Memory* section = module->mapSection(module->mapReference(sectionName, false) | mskMetaRDataRef, false);

   // check if the module alread included
   MemoryReader metaReader(section);
   while (!metaReader.Eof()) {
      ident_t s = metaReader.getLiteral(DEFAULT_STR);
      if (s.compare(memberName))
         return;
   }

   // otherwise add it to the list
   MemoryWriter metaWriter(section);

   metaWriter.writeLiteral(memberName.c_str());
}
Ejemplo n.º 2
0
ref_t resolveMessage(_Module* module, ident_t method)
{
   int paramCount = 0;
   ref_t actionRef = 0;
   ref_t flags = 0;

   if (method.startsWith("params#")) {
      flags |= VARIADIC_MESSAGE;

      method = method.c_str() + getlength("params#");
   }
   if (method.startsWith("prop#")) {
      flags |= PROPERTY_MESSAGE;

      method = method.c_str() + getlength("prop#");
   }
   if (method.startsWith("#invoke")) {
      flags |= SPECIAL_MESSAGE;
   }
   if (method.startsWith("#private&")) {
      flags |= STATIC_MESSAGE;

      method = method.c_str() + getlength("#private&");
   }
   if (method.compare("#init")) {
      flags |= SPECIAL_MESSAGE;
   }

   IdentifierString actionName;
   int paramIndex = method.find('[', -1);
   if (paramIndex != -1) {
      actionName.copy(method, paramIndex);

      IdentifierString countStr(method + paramIndex + 1, getlength(method) - paramIndex - 2);
      paramCount = countStr.ident().toInt();
   }
   else actionName.copy(method);

   //if (actionName.compare("dispatch")) {
   //   actionRef = DISPATCH_MESSAGE_ID;
   //}
   //else if (actionName.compare("#new")) {
   //   actionRef = NEWOBJECT_MESSAGE_ID;
   //}
   ///*else */if (actionName.compare("#init")) {
   //   actionRef = INIT_MESSAGE_ID;
   //}
   //else {
   //   if (method.find("set&") != NOTFOUND_POS) {
   //      actionName.cut(0, 4);
   //      flags = PROPSET_MESSAGE;
   //   }
   //   else if (method.startsWith("#cast<") && paramCount > 0) {
   //      flags = SPECIAL_MESSAGE;
   //   }
   ////   else if (actionName.compare("set")) {
   ////      flags = PROPSET_MESSAGE;
   ////   }

      ref_t signature = 0;
      size_t index = actionName.ident().find('<');
      if (index != NOTFOUND_POS) {
         ref_t references[ARG_COUNT];
         size_t end = actionName.ident().find('>');
         size_t len = 0;
         size_t i = index + 1;
         while (i < end) {
            size_t j = actionName.ident().find(i, ',', end);

            IdentifierString temp(actionName.c_str() + i, j-i);
            references[len++] = module->mapReference(temp, true);

            i = j + 1;
         }

         signature = module->mapSignature(references, len, true);

         actionName.truncate(index);
      }

      actionRef = module->mapAction(actionName, signature, true);
      if (actionRef == 0) {
         printLine("Unknown subject ", actionName);

         return 0;
      }
   //}

   return encodeMessage(actionRef, paramCount, flags);
}