Socket
Socket
Sign inDemoInstall

cwise

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cwise - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

LICENSE

108

cwise.js
"use strict"
var parse = require("cwise-parser")
var createThunk = require("./lib/thunk.js")
var parse = require("cwise-parser")
var compile = require("cwise-compiler")

@@ -9,18 +9,3 @@ var REQUIRED_FIELDS = [ "args", "body" ]

function Procedure() {
this.argTypes = []
this.shimArgs = []
this.arrayArgs = []
this.scalarArgs = []
this.indexArgs = []
this.shapeArgs = []
this.funcName = ""
this.pre = null
this.body = null
this.post = null
this.debug = false
}
function createCWise(user_args) {
//Check parameters

@@ -39,85 +24,14 @@ for(var id in user_args) {

//Create procedure
var proc = new Procedure()
//Parse blocks
proc.pre = parse(user_args.pre || function(){})
proc.body = parse(user_args.body)
proc.post = parse(user_args.post || function(){})
//Parse arguments
var proc_args = user_args.args.slice(0)
proc.argTypes = proc_args
for(var i=0; i<proc_args.length; ++i) {
switch(proc_args[i]) {
case "array":
proc.arrayArgs.push(i)
proc.shimArgs.push("array" + i)
if(i < proc.pre.args.length && proc.pre.args[i].count>0) {
throw new Error("cwise: pre() block may not reference array args")
}
if(i < proc.post.args.length && proc.post.args[i].count>0) {
throw new Error("cwise: post() block may not reference array args")
}
break
case "scalar":
proc.scalarArgs.push(i)
proc.shimArgs.push("scalar" + i)
break
case "index":
proc.indexArgs.push(i)
if(i < proc.pre.args.length && proc.pre.args[i].count > 0) {
throw new Error("cwise: pre() block may not reference array index")
}
if(i < proc.body.args.length && proc.body.args[i].lvalue) {
throw new Error("cwise: body() block may not write to array index")
}
if(i < proc.post.args.length && proc.post.args[i].count > 0) {
throw new Error("cwise: post() block may not reference array index")
}
break
case "shape":
proc.shapeArgs.push(i)
if(i < proc.pre.args.length && proc.pre.args[i].lvalue) {
throw new Error("cwise: pre() block may not write to array shape")
}
if(i < proc.body.args.length && proc.body.args[i].lvalue) {
throw new Error("cwise: body() block may not write to array shape")
}
if(i < proc.post.args.length && proc.post.args[i].lvalue) {
throw new Error("cwise: post() block may not write to array shape")
}
break
default:
throw new Error("cwise: Unknown argument type " + proc_args[i])
}
}
//Make sure at least one array argument was specified
if(proc.arrayArgs.length <= 0) {
throw new Error("cwise: No array arguments specified")
}
//Make sure arguments are correct
if(proc.pre.args.length > proc_args.length) {
throw new Error("cwise: Too many arguments in pre() block")
}
if(proc.body.args.length > proc_args.length) {
throw new Error("cwise: Too many arguments in body() block")
}
if(proc.post.args.length > proc_args.length) {
throw new Error("cwise: Too many arguments in post() block")
}
//Check debug flag
proc.debug = !!user_args.printCode
//Retrieve name
proc.funcName = user_args.funcName || user_args.body.name || "cwise"
//Read in block size
proc.blockSize = user_args.blockSize || 64
//Assemble thunk
return createThunk(proc)
return compile({
args: user_args.args,
pre: parse(user_args.pre || function(){}),
body: parse(user_args.body),
post: parse(user_args.post || function(){}),
debug: !!user_args.printCode,
funcName: user_args.funcName || user_args.body.name || "cwise",
blockSize: user_args.blockSize || 64
})
}
module.exports = createCWise
{
"name": "cwise",
"version": "0.3.3",
"version": "0.3.4",
"description": "Component-wise map/reduce for ndarrays",

@@ -11,3 +11,3 @@ "main": "cwise.js",

"cwise-parser": "~0.0.1",
"uniq": "~0.0.2"
"cwise-compiler": "~0.0.0"
},

@@ -41,5 +41,5 @@ "devDependencies": {

"author": "Mikola Lysenko",
"license": "BSD",
"license": "MIT",
"gitHead": "1dd03e72f1b0fbec4186e497b3956d87aec6fc15",
"readmeFilename": "README.md"
}

@@ -214,2 +214,2 @@ cwise

=======
(c) 2013 Mikola Lysenko. BSD License
(c) 2013 Mikola Lysenko. MIT License
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc