Exemplo n.º 1
0
def CreateArgFile(fullName,lang, modules):
  global srcext
  info = convert.ExtractArgFileInfo(fullName)
  if info == None:
    return None
  else:
    (modcls, op) = info

  if lang == 'sl':
    template = util.GetTemplate('arg-file-cpp-sl')
    str = ""
    for mod0 in modules:
      mod = string.replace(mod0, "_", "_u")
      str = str + "init_" + mod + "();"
    data = util.SubString('<<INIT>>', str, template)
    data = util.SubString('<<MOD>>', modcls, data)
    data = util.SubString('<<OP>>', op, data)
  else:
# Remove any package path if it exists (n/a for c++)
    match = re.match("^.*\.([^.]+)$", modcls, re.M)
    if match != None:
      modcls = match.group(1)
    template = util.GetTemplate('arg-file-cpp-pp')
    data = util.SubString('<<CLASS>>',modcls, template)
    data = util.SubString('<<OP>>', op, data)

  if data == None:
    return false
  return util.WriteFile("icode." + srcext, data)
Exemplo n.º 2
0
def RunImplTestCase(fullName, lang):
    ok = true
    modules = None

    if ok:
        ok = convert.ConvertLanguage(lang, fullName)

    if ok:
        ok = convert.CreateOptionsFile(fullName)

    if ok:
        # Find the module or class names of the input specification.
        modules = convert.ModulesInSpecification(fullName, lang)
        if modules == None:
            ok = false

    convert.ExtractArgFileInfo(fullName)

    if ok:
        ok = CodeGenerateImpl(fullName, lang, modules)

    if ok:
        ok = CompileRunAndCompare(fullName, lang, 'impl', modules)

    return (ok, modules)
Exemplo n.º 3
0
def RunSpecTestCases(fullNames, lang, coverageFile):

    # remove files we expect output in to.
    for fullName in fullNames:
        util.RemoveTestFiles(fullName,
                             [".arg.pt", ".arg.res", ".arg.err", ".arg.msg"])

    exitCode0 = os.system("rm -f quotes/*.java")

    # run the test cases
    cmd = cmdline.LookUpWildCard('java', lang, 'spec', 'code-generator')
    cmd = cmd + " -D -a -b -R " + coverageFile
    exitCode = util.RunCommand(
        cmd, 0, "Possible core dump while interpreting specification.")

    okNames = []
    # Now validate the results
    for fullName in fullNames:
        bn = util.ExtractName(fullName)
        semResName = bn + ".arg.res"
        resName = bn + ".res"
        report.setTestCaseName(fullName)
        ok = true

        if ok:
            # Find the module or class names of the input specification.
            modules = convert.ModulesInSpecification(fullName, lang)
            if modules == None:
                ok = false

        # Clean out the files we expect as output from the code generation.
        for mod in modules:
            util.DeleteFiles([mod + ".java", "external_" + mod + ".java"])

        # See if a result file was created
        if ok:
            if not os.path.exists(semResName):
                report.Error(
                    "No result file generated for test case " + fullName,
                    "Maybe the code generation failed for " +
                    "one of the previous test cases")
                ok = false

        convert.ExtractArgFileInfo(fullName)

        if ok:
            ok = ExtractSourceFiles(fullName, lang, modules)

        if ok:
            ok = CompileRunAndCompare(fullName, lang, 'spec', modules)

        if ok:
            okNames.append(fullName)

    return (okNames, modules)
Exemplo n.º 4
0
def CreateArgumentAst(fullName, lang):
    info = convert.ExtractArgFileInfo(fullName)
    if info == None:
        return None
    else:
        (modcls, op) = info

    if lang == 'sl':
        template = util.GetTemplate("arg-file-pog")
    else:
        template = util.GetTemplate("arg-file-pog")

    data = util.SubString('<<MODORCLASS>>', modcls, template)
    data = util.SubString('<<OPERATION>>', op, data)
    return data
Exemplo n.º 5
0
def CreateArgumentAst(fullName, lang):
  info = convert.ExtractArgFileInfo(fullName)
  if info == None:
    return None
  else:
    (modcls, op) = info

  isStatic = false
  if modcls == None:
    isStatic = true
    (modcls, op) = op
  
  if lang == 'sl' or isStatic:
    template = util.GetTemplate("arg-file-ip-arguments-sl")
  elif lang == 'pp' or isStatic:
    template = util.GetTemplate("arg-file-ip-arguments-pp")
  else:
    template = util.GetTemplate("arg-file-ip-arguments-rt")

  data = util.SubString('<<MODORCLASS>>', modcls, template)
  data = util.SubString('<<OPERATION>>', op, data)
  return data
Exemplo n.º 6
0
def CreateArgFile(fullName, lang, modules):
    info = convert.ExtractArgFileInfo(fullName)
    if info == None:
        return None
    else:
        (modcls, op) = info

    if lang == 'sl':
        template = util.GetTemplate('arg-file-java-sl')
        str = ""
        for mod in modules:
            str = str + "init_" + mod + "();"
        data = util.SubString('<<INIT>>', str, template)
        data = util.SubString('<<MOD>>', modcls, data)
        data = util.SubString('<<OP>>', op, data)
    else:
        template = util.GetTemplate('arg-file-java-pp')
        data = util.SubString('<<CLASS>>', modcls, template)
        data = util.SubString('<<OP>>', op, data)

    if data == None:
        return false

    return util.WriteFile("TMAIN.java", data)