Ejemplo n.º 1
0
void CppHeaderGenerator::writeFieldAccessors(QTextStream &s, const AbstractMetaField *java_field) {
    Q_ASSERT(java_field->isProtected());

    const AbstractMetaFunction *setter = java_field->setter();
    const AbstractMetaFunction *getter = java_field->getter();

    if (!java_field->type()->isConstant())
        writeFunction(s, setter);

    writeFunction(s, getter);
}
Ejemplo n.º 2
0
void writeClass(FILE * outc, FILE * outh, Object * tree, int indent)
{

    ListObject *oIter;

    oIter = tree->definedSymbols;
    //fprintf(outh, "%s %s " COMPILER_SEP "%s %s;\n", "typedef", "struct", tree->name,
    //        tree->name);
    fprintf(outh, "%s " COMPILER_SEP "%s {\n", "struct", tree->name);

    while (oIter != 0) {
        if (oIter->value->category == Variable) {
            writeDeclareClassVariable (oIter, outh, tree);
        } else {
            oIter = oIter->next;
            break;
        }
        oIter = oIter->next;
    }

    fprintf(outh, "};\n");



    while (oIter != 0) {
        if (isVerb(oIter->value)) {
            writeFunction(outh, tree, indent, false);
        } else {
            writeTreeHelper(outc, outh, tree, indent);
        }
    }

}
Ejemplo n.º 3
0
void writeTreeHelper(FILE * outc, FILE * outh, Object * tree, int indent)
{

    ListObject *oIter;
    ListString *sIter;

    if (tree == 0) {
        warningMsg("tree was null in writeTree. (ObjectTree.c)\n");
        return;
    }

    if (outc == 0 || outh == 0) {
        warningMsg("output file was null in writeTree. (ObjectTree.c)\n");
        return;
    }

    oIter = tree->definedSymbols;
    sIter = tree->paramTypes;

    //construct and print function header
    if (isVerb(tree) && !getFlag(tree, FLAG_EXTERNAL)) {
        compilerDebugPrintf("Writing function %s\n",tree->fullname);
        writeFunction(outh, tree, indent, false);
    } else if (tree->category == Type && !getFlag(tree, FLAG_EXTERNAL)) {
        writeClass(outc, outh, tree, indent);
    } else if (tree->category == Dummy) {
        //Dummy
    } else {
        writeOther(outc, outh, tree, indent);
    }

}
Ejemplo n.º 4
0
/**
 * @brief Writes the functions associated with a state.
 * @param i The indentation level.
 * @param state State containing the functions.
 * @param object Object Containing the states.
 * @param pex Binary to decompile.
 */
void Decompiler::PscCoder::writeFunctions(int i, const Pex::State &state, const Pex::Object& object, const Pex::Binary &pex)
{
    for (auto& func : state.getFunctions())
    {
        write("");
        writeFunction(i, func, object, pex);
    }
}
Ejemplo n.º 5
0
/**
* @brief Write the property definition.
* @param i The indent level.
* @param prop The property to write.
* @param object Object containing the properties definitions.
* @param pex Binary to decompile.
*/
void Decompiler::PscCoder::writeProperty(int i, const Pex::Property& prop, const Pex::Object &object, const Pex::Binary& pex)
{
    auto stream = indent(i);
    auto isAutoReadOnly = !prop.hasAutoVar() &&
                          prop.isReadable() &&
                          !prop.isWritable() &&
                          prop.getReadFunction().getInstructions().size() == 1 &&
                          prop.getReadFunction().getInstructions()[0].getOpCode() == Pex::OpCode::RETURN &&
                          prop.getReadFunction().getInstructions()[0].getArgs().size() == 1;
    stream << mapType(prop.getTypeName().asString()) << " Property " << prop.getName();
    if (prop.hasAutoVar()) {
        auto var = object.getVariables().findByName(prop.getAutoVarName());
        if (var == nullptr)
            throw std::runtime_error("Auto variable for property not found");

        auto initialValue = var->getDefaultValue();
        if (initialValue.getType() != Pex::ValueType::None)
            stream << " = " << initialValue.toString();
        stream << " Auto";

        // The flags defined on the variable must be set on the property
        writeUserFlag(stream, *var, pex);
        if (var->getConstFlag())
            stream << " Const";
    } else if (isAutoReadOnly) {
        stream << " = " << prop.getReadFunction().getInstructions()[0].getArgs()[0].toString();
        stream << " AutoReadOnly";
    }
    writeUserFlag(stream, prop, pex);
    write(stream);
    writeDocString(i, prop);

    if (!prop.hasAutoVar() && !isAutoReadOnly) {
        if (prop.isReadable())
            writeFunction(i + 1, prop.getReadFunction(), object, pex, "Get");
        if (prop.isWritable())
            writeFunction(i + 1, prop.getWriteFunction(), object, pex, "Set");
        write(indent(i) << "EndProperty");
    }
}
Ejemplo n.º 6
0
void writeForwardDeclarations (FILE * outh, Object * tree)
{
    ListObject *fiter;
    int indent = 0;
    fiter = tree->definedSymbols;
    //Do the forward declarations
    while (fiter) {
        if (isVerb(fiter->value)) {
            if (!getFlag(fiter->value, FLAG_EXTERNAL)) {
                compilerDebugPrintf("Forward decling %s\n", fiter->value->fullname);
                writeFunction(outh, fiter->value, indent, true);
            }
        }
        fiter = fiter->next;
    }
}
Ejemplo n.º 7
0
void numberToFunction(int number, char* secondary){
	if (number == 1){
		readFunction(secondary);
	}
	else if (number == 2){
		writeFunction(secondary);
	}
	else if (number == 3){
		deleteFunction(secondary);
	}
	else if (number == 4){
		printFunction();
	}
	else if (number == 0){
		printf("Not a valid command!\n");
	}
	else if (number == 404){
		printf("The file you provided does not exist.\n");
	}
}
Ejemplo n.º 8
0
int main() {
  int n, m, a[128][128], aa[128][128], b[128], bb[128], c[128], cc[128];
  int tmp;
  char minmax[16], buf[32], ch;

  freopen("dual.in", "r", stdin);
  freopen("dual.out", "w", stdout);
  scanf("%d%d", &n, &m);
  scanf("%s", minmax);
  readFunction(a[0], n);
  scanf(" with");
  for (int i = 1; i <= n; ++i) {
    scanf(" x%d%[^\n]", &tmp, buf);
    switch (buf[0]) {
    case ' ': c[i] = 0; break;
    case '>': c[i] = 1; break;
    case '<': c[i] = 2; break;
    }
  }
  scanf(" under");
  for (int i = 1; i <= m; ++i) {
    readFunction(a[i], n);
    ch = getchar();
    switch (ch) {
    case '=': b[i] = 0; break;
    case '>': b[i] = 1; getchar(); break;
    case '<': b[i] = 2; getchar(); break;
    }
    scanf("%d", &a[i][0]);
  }

  for (int i = 0; i <= m; ++i) {
    for (int j = 0; j <= n; ++j) {
      aa[j][i] = a[i][j];
    }
  }
  // WA
  /*		for (int i = 1; i <= m; ++i) {
        cc[i] = b[i];
        }
        for (int i = 1; i <= n; ++i) {
        bb[i] = (c[i] == 0 ? 0 : 3 - c[i]);
        }
        */		if (strcmp(minmax, "min") == 0) {
          for (int i = 1; i <= m; ++i) {
            cc[i] = b[i];
          }
          for (int i = 1; i <= n; ++i) {
            bb[i] = (c[i] == 0 ? 0 : 3 - c[i]);
          }
        } else {
          for (int i = 1; i <= m; ++i) {
            cc[i] = (b[i] == 0 ? 0 : 3 - b[i]);
          }
          for (int i = 1; i <= n; ++i) {
            bb[i] = c[i];
          }
        }


        printf("%d %d\n", m, n);
        if (strcmp(minmax, "min") == 0) {
          printf("max ");
        } else {
          printf("min ");
        }
        writeFunction(aa[0], m);
        printf("\nwith\n");
        for (int i = 1; i <= m; ++i) {
          printf("y%d%s\n", i, condition[cc[i]]);
        }
        printf("under\n");
        for (int i = 1; i <= n; ++i) {
          writeFunction(aa[i], m);
          printf("%s%d\n", restriction[bb[i]], aa[i][0]);
        }

        return 0;
}
Ejemplo n.º 9
0
void envoiCommandClient(int socket_descriptor, char *command)
{
    /* Envoi de la command vers le serveur */
    writeFunction(socket_descriptor, command);
}
Ejemplo n.º 10
0
void envoiPseudoClient(char *p, int socket_descriptor)
{
    writeFunction(socket_descriptor, p);
}