Skip to content
Permalink
Browse files

Merge dc8a040 into ed29c2d

  • Loading branch information
vihanb committed Jan 11, 2017
2 parents ed29c2d + dc8a040 commit 179ffd971dd3ded17db1f7ab740f4d97c2b99f82
Showing with 1,071 additions and 983 deletions.
  1. +7 βˆ’1 .babelrc
  2. +3 βˆ’0 .gitignore
  3. +3 βˆ’0 .gitmodules
  4. +5 βˆ’0 .travis.yml
  5. +29 βˆ’4 Makefile
  6. +5 βˆ’2 benchmark/index.js
  7. +0 βˆ’45 bin/alias
  8. +0 βˆ’9 bin/cleanup
  9. +16 βˆ’0 bin/colors.sh
  10. 0 bin/cpm
  11. +105 βˆ’0 bin/gendeps.sh
  12. +60 βˆ’0 bin/genopt.sh
  13. +24 βˆ’13 bin/install
  14. +0 βˆ’9 bin/locrc
  15. +0 βˆ’31 bin/path
  16. +4 βˆ’0 bindings/index.js
  17. +12 βˆ’0 bindings/number/binding.gyp
  18. +3 βˆ’0 bindings/number/index.js
  19. +130 βˆ’0 bindings/number/src/binding.cc
  20. +87 βˆ’0 bindings/number/src/binding.h
  21. +228 βˆ’0 bindings/number/src/ops.cc
  22. +64 βˆ’0 bindings/primes/binding.gyp
  23. +4 βˆ’0 bindings/primes/index.js
  24. +1 βˆ’0 bindings/primes/primesieve
  25. +58 βˆ’0 bindings/primes/src/binding.cc
  26. +17 βˆ’0 build.js
  27. +3 βˆ’0 circle.yml
  28. +4 βˆ’2 package.json
  29. +1 βˆ’1 src/cli/debug.es6
  30. +1 βˆ’1 src/cli/prog.es6
  31. +1 βˆ’1 src/cli/repl.es6
  32. +0 βˆ’2 src/etc/scheme.es6
  33. +1 βˆ’1 src/interpreter/core/consts/dict.es6
  34. +1 βˆ’1 src/interpreter/core/env/func.es6
  35. +5 βˆ’6 src/interpreter/core/primitives/Array.es6
  36. +3 βˆ’16 src/interpreter/core/primitives/Number.es6
  37. +4 βˆ’6 src/interpreter/core/primitives/String.es6
  38. +50 βˆ’43 src/interpreter/core/primitives/op/number.es6
  39. +1 βˆ’1 src/interpreter/core/primitives/op/string.es6
  40. +0 βˆ’2 src/interpreter/exec.es6
  41. +13 βˆ’0 src/interpreter/index.js
  42. +4 βˆ’0 src/stdlib/api.es6
  43. +8 βˆ’0 src/stdlib/ns/Console.es6
  44. 0 src/stdlib/ns/{cheddar β†’ Console}/argc.es6
  45. 0 src/stdlib/ns/{cheddar/argv.es6 β†’ Console/args.es6}
  46. 0 src/stdlib/ns/{IO β†’ Console}/printf.es6
  47. +5 βˆ’5 src/stdlib/ns/{IO β†’ Console}/sprintf.es6
  48. +1 βˆ’3 src/stdlib/ns/IO.es6
  49. 0 src/stdlib/ns/IO/{stdin.es6 β†’ STDIN.es6}
  50. +1 βˆ’1 src/stdlib/ns/IO/fd.es6
  51. +2 βˆ’1 src/stdlib/ns/Math.es6
  52. +1 βˆ’1 src/stdlib/ns/Math/{prime.es6 β†’ isPrime.es6}
  53. +21 βˆ’0 src/stdlib/ns/Math/primes.es6
  54. +0 βˆ’74 src/stdlib/ns/Rational.es6
  55. +0 βˆ’23 src/stdlib/ns/Rational/abs.es6
  56. +0 βˆ’28 src/stdlib/ns/Rational/add.es6
  57. +0 βˆ’24 src/stdlib/ns/Rational/cbrt.es6
  58. +0 βˆ’24 src/stdlib/ns/Rational/ceil.es6
  59. +0 βˆ’30 src/stdlib/ns/Rational/cmp.es6
  60. +0 βˆ’28 src/stdlib/ns/Rational/div.es6
  61. +0 βˆ’24 src/stdlib/ns/Rational/floor.es6
  62. +0 βˆ’8 src/stdlib/ns/Rational/helpers/add.es6
  63. +0 βˆ’8 src/stdlib/ns/Rational/helpers/gcd.es6
  64. +0 βˆ’8 src/stdlib/ns/Rational/helpers/mul.es6
  65. +0 βˆ’74 src/stdlib/ns/Rational/helpers/of.es6
  66. +0 βˆ’8 src/stdlib/ns/Rational/helpers/pow.es6
  67. +0 βˆ’23 src/stdlib/ns/Rational/inv.es6
  68. +0 βˆ’24 src/stdlib/ns/Rational/ln.es6
  69. +0 βˆ’30 src/stdlib/ns/Rational/log.es6
  70. +0 βˆ’29 src/stdlib/ns/Rational/mod.es6
  71. +0 βˆ’28 src/stdlib/ns/Rational/mul.es6
  72. +0 βˆ’23 src/stdlib/ns/Rational/neg.es6
  73. +0 βˆ’25 src/stdlib/ns/Rational/num.es6
  74. +0 βˆ’20 src/stdlib/ns/Rational/of.es6
  75. +0 βˆ’28 src/stdlib/ns/Rational/pow.es6
  76. +0 βˆ’28 src/stdlib/ns/Rational/root.es6
  77. +0 βˆ’24 src/stdlib/ns/Rational/round.es6
  78. +0 βˆ’23 src/stdlib/ns/Rational/sgn.es6
  79. +0 βˆ’24 src/stdlib/ns/Rational/sqrt.es6
  80. +0 βˆ’28 src/stdlib/ns/Rational/sub.es6
  81. +0 βˆ’2 src/stdlib/ns/cheddar.es6
  82. +1 βˆ’1 src/stdlib/primitive/Array/lib.es6
  83. +1 βˆ’1 src/stdlib/primitive/Array/lib/{len.es6 β†’ length.es6}
  84. +2 βˆ’2 src/stdlib/primitive/Array/lib/sum.es6
  85. +1 βˆ’1 src/stdlib/primitive/Number/lib.es6
  86. +1 βˆ’1 src/stdlib/primitive/Number/lib/{tobase.es6 β†’ toBase.es6}
  87. +4 βˆ’4 src/stdlib/primitive/String/lib.es6
  88. +1 βˆ’1 src/stdlib/primitive/String/lib/{len.es6 β†’ length.es6}
  89. +1 βˆ’1 src/stdlib/primitive/String/lib/{match.es6 β†’ matches.es6}
  90. +1 βˆ’1 src/stdlib/primitive/String/lib/{sub.es6 β†’ replace.es6}
  91. +1 βˆ’1 src/stdlib/primitive/String/lib/{rev.es6 β†’ reverse.es6}
  92. +2 βˆ’2 src/stdlib/stdlib.es6
  93. +2 βˆ’2 test/tests/Primitives/FunctionalOp.js
  94. +3 βˆ’3 test/tests/Primitives/FunctionalProp.js
  95. +7 βˆ’0 test/tests/STL/Encoding.js
  96. +15 βˆ’15 test/tests/STL/IO.js
  97. +14 βˆ’2 test/tests/STL/Math.js
  98. +2 βˆ’2 test/tests/STL/Primitives/Array.js
  99. +5 βˆ’5 test/tests/STL/Primitives/Number.js
  100. +9 βˆ’9 test/tests/STL/Primitives/String.js
  101. +2 βˆ’1 test/tests/STL/Rational.js
@@ -1,5 +1,11 @@
{
"presets": ["features"],
"presets": [
["env", {
"targets": {
"node": 4
}
}]
],
"plugins": [
"babel-plugin-transform-class-properties",
"babel-plugin-add-module-exports",
@@ -1,3 +1,6 @@
# Build
build

# Cheddar debug logs
/benckmark/debug

@@ -0,0 +1,3 @@
[submodule "bindings/primes/primesieve"]
path = bindings/primes/primesieve
url = https://github.com/kimwalisch/primesieve.git
@@ -6,6 +6,11 @@ node_js:
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
codeclimate:
repo_token:
- secure: CODECLIMATE_REPO_TOKEN
@@ -1,3 +1,18 @@
################################################################################
# Cheddar Makefile
# Available Targets:
# default: Production build
# build : Development build
# %.node : Builds binding/%
# install: Installs to given path
#
# Phony targets:
# clean : Removed unecessary stuff from directory
# test : Performs tests
# bench : Performs benchmarks
#
################################################################################

PREFIX=./node_modules/.bin
SELF=$(lastword $(MAKEFILE_LIST))
## Compiler
@@ -21,18 +36,28 @@ TFLAGS=cover $(TEST)

BENCHMARK=benchmark/

# Bindings
BINDING_SRC = $(wildcard bindings/*/binding.gyp)
BINDING_TARGETS = $(foreach B,$(patsubst bindings/%/binding.gyp, %, $(BINDING_SRC)),bindings/$B/build/Release/$B.node)

## Rules
all: default

# The binding task
# Compiles all gyp bingings
# from bingings/foo/binding.gyp
%.node:
node-gyp rebuild -C ./bindings/$(shell echo $* | cut -d "/" -f2)/

# The default task
# The **production** build
default: $(JC)
default: $(BINDING_TARGETS) $(JC)
NODE_ENV=production $(JC) $(JCFLAGS) --minified --compact true
$(BIN_MAKE)

# Development build task
# This builds and includes source maps
build: $(JC)
build: $(BINDING_TARGETS) $(JC)
$(JC) $(JCFLAGS) --source-maps
$(BIN_MAKE)

@@ -52,10 +77,10 @@ install: ./bin/install
test: $(TESTRUNNER) $(COVERAGE) $(TEST)
$(TESTRUNNER) $(COVERAGE) $(TFLAGS)

benchmark: $(BENCHMARK) $(OUT)
bench: $(BENCHMARK) $(OUT)
node $(BENCHMARK)

clean: $(OUT)
rm -rf $(OUT)

.PHONY: test benchmark clean
.PHONY: test benchmark clean build default
@@ -119,8 +119,11 @@ Bench("Literal Parsing", [
]);

Bench("Prime Generation", [
[ "Built-in", "let i = 0; for ( let a = []; a.len < 1000; i += 1) { if (Math.prime(i)) { a.push(i) } }" ],
[ "Native Implementation", fs.readFileSync(__dirname + "/prime.cheddar", "utf-8") ]
[ ".primes (< 1000)", "Math.primes(1000);" ],
[ ".isprime (< 1000)", "let i = 0; for ( let a = []; a.len < 1000; i += 1) { if (Math.isprime(i)) { a.push(i) } }" ],
[ "Native (< 1000)", fs.readFileSync(__dirname + "/prime.cheddar", "utf-8") ],

[ ".primes (= 1000)", "Math.primes(1000, true);" ]
]);

process.stdout.write(log);

This file was deleted.

This file was deleted.

@@ -0,0 +1,16 @@
# Source: http://stackoverflow.com/a/16844327/1620622

RCol='\033[0m' # Text Reset

Bol='\033[1m'
Dim='\033[2m'

# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds
Bla='\033[0;30m'; BBla='\033[1;30m'; UBla='\033[4;30m'; IBla='\033[0;90m'; BIBla='\033[1;90m'; On_Bla='\033[40m'; On_IBla='\033[0;100m';
Red='\033[0;31m'; BRed='\033[1;31m'; URed='\033[4;31m'; IRed='\033[0;91m'; BIRed='\033[1;91m'; On_Red='\033[41m'; On_IRed='\033[0;101m';
Gre='\033[0;32m'; BGre='\033[1;32m'; UGre='\033[4;32m'; IGre='\033[0;92m'; BIGre='\033[1;92m'; On_Gre='\033[42m'; On_IGre='\033[0;102m';
Yel='\033[0;33m'; BYel='\033[1;33m'; UYel='\033[4;33m'; IYel='\033[0;93m'; BIYel='\033[1;93m'; On_Yel='\033[43m'; On_IYel='\033[0;103m';
Blu='\033[0;34m'; BBlu='\033[1;34m'; UBlu='\033[4;34m'; IBlu='\033[0;94m'; BIBlu='\033[1;94m'; On_Blu='\033[44m'; On_IBlu='\033[0;104m';
Pur='\033[0;35m'; BPur='\033[1;35m'; UPur='\033[4;35m'; IPur='\033[0;95m'; BIPur='\033[1;95m'; On_Pur='\033[45m'; On_IPur='\033[0;105m';
Cya='\033[0;36m'; BCya='\033[1;36m'; UCya='\033[4;36m'; ICya='\033[0;96m'; BICya='\033[1;96m'; On_Cya='\033[46m'; On_ICya='\033[0;106m';
Whi='\033[0;37m'; BWhi='\033[1;37m'; UWhi='\033[4;37m'; IWhi='\033[0;97m'; BIWhi='\033[1;97m'; On_Whi='\033[47m'; On_IWhi='\033[0;107m';
No changes.
@@ -0,0 +1,105 @@
source colors.sh

# Prompts
echo
echo -e " Verifying Dependencies..."
echo -e "${Dim}--------------------------------------------------------${RCol}"

# Dependency management
MISSING_DEPENDENCIES=()
report_error() {
echo -e " ${BRed}Missing${RCol}: ${Bol}$1"
}
report_found() {
echo -e " ${BGre}Found:${RCol} ${Bol}$1${RCol} $2"
}

prompt_install() {
echo -e " ${Bol}$1${RCol} not found."
while true; do
printf " is ${Bol}$1${RCol} installed (Yn): "
read -n 1 prompt_response
if [[ ! -z "$prompt_response" ]]; then
case "$prompt_response" in
Y)
should_install=true
break 2;;
n)
should_install=false
break 2;;
*) printf "\r\033[K"; ;;
esac
else
printf "\033[1A\033[K"
fi
done
echo

printf "\033[1A\033[K\033[1A\033[K"

if [ "$should_install" = true ]; then
should_rm_last=false
while true; do
printf " Path for ${Bol}$1${RCol}: "
read res_path

if [[ ! -z "$res_path" ]]; then
if [[ ! -e "$res_path" ]]; then
if [ $should_rm_last = true ]; then
printf "\033[1A\033[2K"
fi
printf "\033[1A\033[K"
echo -e " '$res_path' does not exist."
should_rm_last=true
else
if [ $should_rm_last = true ]; then
printf "\033[1A\033[K\033"
fi

printf "\033[1A\033[K"
report_found "$1" "at ${res_path}"
break
fi
fi
done
response="$res_path"
else
report_error "$1"
fi
}

# Make
if ! type "make" &> /dev/null; then
MISSING_DEPENDENCIES+="build-essential"
report_error "Make"
else
report_found "Make"
fi

# Python2
if ! type "python2-config" &> /dev/null; then
# Prompt for python
prompt_install "Python 2" "python2-config"
if [[ -z "$response" ]]; then
MISSING_DEPENDENCIES+="python2"
else
export PYTHON_PATH="$response"
fi
else
report_found "Python 2"
fi

# Insatll Dependencies
echo
for i in "${MISSING_DEPENDENCIES[@]}"; do
case "$i" in
python2)
echo -e "Installing ${Bol}Python 2.7-dev${RCol}"
if type "apt-get" &> /dev/null; then
apt-get install python2.7-dev 1> /dev/null
elif type "yum" &> /dev/null; then
yum install python-devel 1> /dev/null
fi
break;;
esac
done
@@ -0,0 +1,60 @@
source colors.sh

echo
echo -e " Configuration"
echo -e "${Dim}--------------------------------------------------------${RCol}"

do_prompt_yn() {
while true; do
printf " $1 (Yn)[${Bol}$2${RCol}]: "
read -n 1 prompt_response
if [[ ! -z "$prompt_response" ]]; then
case $prompt_response in
Y)
respond_with=true
break 2;;
n)
respond_with=false
break 2;;
*) printf "\r\033[K"; ;;
esac
else
respond_with="$2"
break
fi
done

RESULT="${respond_with}"
}

do_prompt_path() {
has_run=false
while true; do
printf " $1 [${Bol}$2${RCol}]: "
read RESULT

if [[ -z "$RESULT" ]]; then
RESULT="$2"
break
elif [[ ! -e "$RESULT" ]]; then
printf "\033[K\033[A\033[K"
if [ "$has_run" = true ]; then
printf "\033[A\033[K"
fi
echo " '${RESULT}' does not exist."
has_run=true
else
break
fi
done

printf "\033[A\033K"
}

# Installation Location
do_prompt_path "Installation Location" "/usr/local/bin"
CHEDDAR_TARGET="$RESULT"

# Python
do_prompt_yn "Install Python Bindings" "Y"
CHEDDAR_BINDINGS_PYTHON="$RESULT"
@@ -1,14 +1,25 @@
#!/usr/bin/env bash
echo "Downloading..."
npm install
echo "Installing..."
cpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

which realpath &> /dev/null
if [ $? -eq 0 ]; then
rp="realpath"
else
rp="readlink -f"
fi

"$($rp "$cpath/path")" /usr/local
CHEDDAR_FIG=' ________ __ __
/ ____/ /_ ___ ____/ /___/ /___ ______
/ / / __ \/ _ \/ __ / __ / __ `/ ___/
/ /___/ / / / __/ /_/ / /_/ / /_/ / /
\____/_/ /_/\___/\__,_/\__,_/\__,_/_/
'

# Colors
source colors.sh

# Print intro
echo -e "${Yel}${CHEDDAR_FIG}${RCol}"

echo -e " Welcome to the ${Bol}Cheddar${RCol} installer."
echo -e "${Dim}--------------------------------------------------------${RCol}"
echo -e "You will be prompted for various installation options"
echo -e "Press enter to specify the default value if available"
echo

# Handle Dependencies
source gendeps.sh

# Generate Script Configuration
source genopt.sh

0 comments on commit 179ffd9

Please sign in to comment.
You can’t perform that action at this time.