Provide uniform isXxx functions in the standard modules.
Bug fix/workaround for sync/single args; minor reformatting in ChapelSyncvar.chpl
Followed up on reviewer's comments.
Merged chapel-lang/master
Converted one more file to the new names.
Merge pull request #212 from vasslitvinov/uniform-isXxxType-queries

Provide uniform isXxx functions in the standard modules.

With this patch, the following param functions are provided that test
whether the argument is or is of the corresponding type:

  isVoid
  isBool
  isInt
  isUint
  isReal
  isImag
  isComplex
  isString

  isEnum
  isTuple
  isHomogeneousTuple

  isClass
  isRecord
  isUnion

  isRange
  isDomain
  isArray
  isDmap    // a dmap-wrapped distribution

  isSync
  isSingle
  isAtomic

The following aggregate queries are also provided:

  isFloat       // real, imag
  isIntegral    // int, uint
  isNumeric     // int, uint, real, imag, complex

  isPrimitive   // primitive type as defined by the spec:
                // void, bool, int, uint, real, imag, complex, string

Each function has a version that takes a 'type' argument
and a version that takes a non-type argument, typically by blank intent.
There are also the corresponding isXxxType() and isXxxValue varieties.
For example:

  proc isRecord(type t)     param  return isRecordType(t);
  proc isRecord(e)          param  return isRecordValue(e);
  proc isRecordType(type t) param ...
  proc isRecordValue(e)     param ...

isHomogeneousTupleValue() is defined on tuples only,
to preserve the existing behavior of isHomogeneousTuple().

  A call to isHomogeneousTuple(non-type arg) invokes
  isHomogeneousTupleValue(non-type arg).  Currently the former is
  defined on tuples only.  For consistency with that, I defined the
  latter on tuples only, too. We can revisit this if desired.

Also added the following queries:

  isType  - true when the argument is a type,  false otherwise
  isParam - true when the argument is a param, false otherwise

I inlined (then deleted) a couple of _isXxx functions that had single uses.

I replaced chpl__isRange() with isRange(), and analogously
for a couple of others.

There are a few other functions whose names start with _
that I did not address in this commit.

TODO: handle _isPrimitiveType - Brad has a patch for it.


DETAILED NOTES

The above functions on types have all been there already, so this
patch renames some of them -- see the script below for details -- plus
reorganizes them somewhat.

The above functions on values were mostly missing, so this patch
adds them, plus reorganizes and/or renames a couple of them.

I added the pragma "no instantiation limit" to the type-oriented queries
for consistency with what has been in Types.chpl already.
We might need to add it to the value-oriented queries.

I needed to change chpl__isType -> isType in the compiler.
No other top-level subdirectories needed any updates,
as far as I can tell.

Most diffs in this commit are due to uses of the above functions.
The diffs due to definition changes are mostly in:

modules/internal/ChapelBase.chpl  (at the bottom of the diffs)
modules/internal/ChapelSyncvar.chpl
modules/internal/ChapelTuple.chpl
modules/standard/Types.chpl  (most def changes are here)

The functions like isSyncType/isSyncValue, when they already existed,
were left in the individual files where the corresponding Chapel types
are defined. The ones that needed to be added with trivial implementations
went into Types.cpp.
I put the functions isXxx (not isXxxType/isXxxValue) all uniformly
in Types.cpp.

The following implementation of isSync:
  proc isSync(e) param return isSyncValue(e);
currently would not produce correct result, so I put in a workaround.
Ditto isSingle().

Regarding the Value variety: Brad has a different naming scheme for
them, so for now consider them to be for internal purposes only.

Quoting Brad: "I still think that a better naming scheme for
isFooValue(x) would be to support:

isFooValue -- only returns true if x is a literal or param of type foo
isFooVariable -- only returns true if x is a const or var of type foo
hasFooValue(x) -- returns true if either of the above are true.
                  This is what isFooValue() does today as I understand it.

For me, the benefit here is that it gets away from suggesting that a
variable is a value -- it seems more accurate to me to say that a
variable has a value.



For archiving purposes - I used this script to do the renaming:

------------------------------------------------------------------
#!/usr/bin/env python

import sys, os, shutil, subprocess, string, signal
import re

verbose = True
vv = False
vrepl = True

# Pairs "from name", "to name".
# Ordered by the "to name". Aggregate queries are all at the bottom.
#
replspec = [
#  ("isArrayType",       "isArray"),
# ("isAtomicType",      "isAtomic"),
  ("_isBooleanType",    "isBoolType"),
# ("isClassType",       "isClass"),
  ("_isComplexType",    "isComplexType"),
# ("isDmapType",        "isDmap"),
# ("isDomainType",      "isDomain"),
  ("_isEnumeratedType", "isEnumType"),
  ("_isImagType",       "isImagType"),
  ("_isSignedType",     "isIntType"),
# ("isRangeType",       "isRange"),
  ("_isRealType",       "isRealType"),
# ("isRecordType",      "isRecord"),
  ("_isSingleType",     "isSingleType"),
  ("_isSingle",         "isSingle"),
  ("_isSyncType",       "isSyncType"),
  ("_isSync",           "isSync"),
# ("isTupleType",       "isTuple"),
  ("_isUnsignedType",   "isUintType"),
# ("isUnionType",       "isUnion"),
#
  ("_isIntegralType",   "isIntegralType"),
  ("_isFloatType",      "isFloatType"),
  ("_isNumericType",    "isNumericType"),
#
  ("chpl__isType",      "isType"),
  ("chpl__isRange",     "isRange"),
  ("chpl__isDomain",    "isDomain"),
  ("chpl__isArray",     "isArray"),
  ("chpl__isDmap",      "isDmap"),
]

if vv:
  print replspec

def REPL(sfrom, sto):
  sfromW = '\\b' + sfrom + '\\b'
  global srcContents
  (srcContents, cnt) = re.subn(sfromW, sto, srcContents)
  if cnt > 0 and vrepl:
    sys.stdout.write("%4d  %20s -> %10s\n"%(cnt, sfrom, sto))
  return cnt

print "starting", "\n"

# invoke from CHPL_HOME
# I also ran similar incantations on subdirs: compiler runtime spec
sourcesStream = os.popen("find modules* test -name \\*.chpl")
for srcName in sourcesStream:
  srcName = srcName.rstrip()
  if os.path.isdir(srcName):
    print "=== ", srcName, " ===  directory"
    continue
  print "=== ", srcName, " ==="
  srcFile = open(srcName)
  srcContents = srcFile.read()
  srcFile.close()
  if vv:
    print srcContents
  cnt = 0
  for replPair in replspec:
    cnt += REPL(replPair[0], replPair[1])

  if vv:
    print "totalreplaced: ", cnt
    print srcContents

  if cnt > 0:
    sys.stdout.write("updating%5d  repls  %s\n"%(cnt, srcName))
    shutil.move(srcName, srcName+".bak")
    srcRepl = open(srcName, 'w')
    srcRepl.write(srcContents)
    srcRepl.close()
    

print "done"
sourcesStream.close()
------------------------------------------------------------------