Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amber

Package Overview
Dependencies
Maintainers
4
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amber - npm Package Compare versions

Comparing version 0.15.1 to 0.16.0

CONTRIBUTORS

20

API-CHANGES.txt

@@ -0,1 +1,21 @@

0.16.0:
* Deprecate ClassBuilder >> setupClass:
* $core.initialize now returns a Promise
* $core.addClass now returns the class
+ amber/boot api >>
+ send2
+ traverseClassTree
+ Promise class >>
+ new
- amber/boot api >>
- wrapClassName
- send
- allSubclasses
- AbstractCodeGenerator
- classNameFor:
0.15.1:

@@ -2,0 +22,0 @@

2

bower.json
{
"name": "amber",
"version": "0.15.1",
"version": "0.16.0",
"main": "support/amber.js",

@@ -5,0 +5,0 @@ "ignore": [

@@ -20,7 +20,7 @@ TL;DR: Setup your Amber clone

1. Get your copy of Helios IDE into directory `my/helios`, choosing among using your own fork / using the stock version:
- ```git clone git@github.com:<your username>/helios.git my/helios``` to use your own fork, or
- ```git clone git@github.com:amber-smalltalk/helios.git my/helios``` to use stock version.
- ```git clone git@lolg.it:<your username>/helios.git my/helios``` to use your own fork, or
- ```git clone git@lolg.it:amber/helios.git my/helios``` to use stock version.
1. Install Helios' dependencies: ```cd my/helios && bower install && cd ../..```.
1. Get your copy of legacy IDE into directory `my/amber-contrib-legacy`:
```git clone git@github.com:amber-smalltalk/amber-contrib-legacy.git my/amber-contrib-legacy```.
```git clone git@lolg.it:amber/amber-contrib-legacy.git my/amber-contrib-legacy```.
1. Run ```grunt devel```. Prepares some transient files.

@@ -69,6 +69,6 @@ 1. Run ```amber serve```. Starts the integrated development server.

* [Amber Issues](https://github.com/amber-smalltalk/amber/issues)
* [Helios IDE Issues](https://github.com/amber-smalltalk/helios/issues)
* [Amber Examples Issues](https://github.com/amber-smalltalk/amber-examples/issues)
* [Amber Website Issues](https://github.com/amber-smalltalk/amber-website/issues)
* [Amber Issues](https://lolg.it/amber/amber/issues)
* [Helios IDE Issues](https://lolg.it/amber/helios/issues)
* [Amber Examples Issues](https://lolg.it/amber/amber-examples/issues)
* [Amber Website Issues](https://lolg.it/amber/amber-website/issues)

@@ -75,0 +75,0 @@

@@ -50,3 +50,3 @@ var path = require('path');

'src/Platform-Services.st', 'src/Platform-ImportExport.st', 'src/Platform-Browser.st', 'src/Platform-Node.st',
'src/Compiler-Exceptions.st', 'src/Compiler-Core.st', 'src/Compiler-AST.st',
'src/Compiler-Core.st', 'src/Compiler-AST.st',
'src/Compiler-IR.st', 'src/Compiler-Inlining.st', 'src/Compiler-Semantic.st', 'src/Compiler-Interpreter.st',

@@ -53,0 +53,0 @@ 'src/SUnit.st',

{
"name": "amber",
"version": "0.15.1",
"version": "0.16.0",
"description": "An implementation of the Smalltalk language that runs on top of the JS runtime.",

@@ -18,8 +18,6 @@ "homepage": "http://amber-lang.net",

},
"license": {
"type": "MIT"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/amber-smalltalk/amber.git#0.15.1"
"url": "git://lolg.it/amber/amber.git#0.16.0"
},

@@ -29,6 +27,10 @@ "engines": {

},
"strings": {
"buildParserBegin": "define(['./boot'], function($boot) {\nvar $globals = $boot.globals, nil = $boot.nil;\n",
"buildParserEnd": "});"
},
"scripts": {
"build:parser:begin": "node -e \"process.stdout.write('define([\\'./boot\\'], function($boot) {\\nvar $globals = $boot.globals, nil = $boot.nil;\\n');\"",
"build:parser": "(npm run -s build:parser:begin && pegjs --cache --export-var $globals.SmalltalkParser < support/parser.pegjs && npm run -s build:parser:end) > support/parser.js",
"build:parser:end": "node -e \"process.stdout.write('});');\"",
"build:parser:begin": "node -e \"process.stdout.write(require('./package.json').strings.buildParserBegin);\"",
"build:parser": "(npm run -s build:parser:begin && pegjs --cache --export-var \"$\"globals.SmalltalkParser < support/parser.pegjs && npm run -s build:parser:end) > support/parser.js",
"build:parser:end": "node -e \"process.stdout.write(require('./package.json').strings.buildParserEnd);\"",
"test": "npm run test:sunit && npm run test:e2e",

@@ -35,0 +37,0 @@ "test:sunit": "grunt test",

@@ -10,4 +10,6 @@ Amber

By Nicolas Petton <petton.nicolas@gmail.com> and [Amber contributors](https://github.com/amber-smalltalk/amber/contributors)
Copyright 2011-2015 Nicolas Petton
Copyright 2014-2016 Herbert Vojčík and [Amber contributors](CONTRIBUTORS)
Amber is an implementation of the Smalltalk language that runs on top of the JavaScript runtime. It is designed to make client-side development faster and easier.

@@ -62,3 +64,3 @@

# Install the CLI tool `amber-cli` and supporting tools
npm install -g grunt-cli grunt-init amber-cli
npm install -g grunt-cli@0 grunt-init bower amber-cli

@@ -86,7 +88,7 @@

- Report issues with the www.amber-lang.net website here: https://github.com/amber-smalltalk/amber-website/issues.
- Report issues with the docs.amber-lang.net website here: https://github.com/amber-smalltalk/documentation/issues.
- Report issues with `amber init` project template here: https://github.com/amber-smalltalk/grunt-init-amber/issues.
- Report issues with Amber engine, core library or `amber` / `amberc` cli tools here: https://github.com/amber-smalltalk/amber/issues.
- Report issues with the Helios IDE here: https://github.com/amber-smalltalk/helios/issues.
- Report issues with the www.amber-lang.net website here: https://lolg.it/amber/amber-website/issues.
- Report issues with the docs.amber-lang.net website here: https://lolg.it/amber/documentation/issues.
- Report issues with `amber init` project template here: https://lolg.it/amber/grunt-init-amber/issues.
- Report issues with Amber engine, core library or `amber` / `amberc` cli tools here: https://lolg.it/amber/amber/issues.
- Report issues with the Helios IDE here: https://lolg.it/amber/helios/issues.

@@ -93,0 +95,0 @@ Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) for further details.

@@ -13,41 +13,2 @@ define("amber_core/Compiler-Core", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Exceptions", "amber_core/Platform-Services", "amber_core/Kernel-Collections"], function($boot){"use strict";

$core.method({
selector: "classNameFor:",
protocol: 'accessing',
fn: function (aClass){
var self=this;
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
return $core.withContext(function($ctx1) {
//>>excludeEnd("ctx");
var $2,$3,$4,$1;
$2=$recv(aClass)._isMetaclass();
if($core.assert($2)){
$3=$recv($recv(aClass)._instanceClass())._name();
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
$ctx1.sendIdx["name"]=1;
//>>excludeEnd("ctx");
$1=$recv($3).__comma(".klass");
} else {
$4=$recv(aClass)._isNil();
if($core.assert($4)){
$1="nil";
} else {
$1=$recv(aClass)._name();
};
};
return $1;
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
}, function($ctx1) {$ctx1.fill(self,"classNameFor:",{aClass:aClass},$globals.AbstractCodeGenerator)});
//>>excludeEnd("ctx");
},
//>>excludeStart("ide", pragmas.excludeIdeData);
args: ["aClass"],
source: "classNameFor: aClass\x0a\x09^ aClass isMetaclass\x0a\x09\x09ifTrue: [ aClass instanceClass name, '.klass' ]\x0a\x09\x09ifFalse: [\x0a\x09\x09aClass isNil\x0a\x09\x09\x09ifTrue: [ 'nil' ]\x0a\x09\x09\x09ifFalse: [ aClass name ]]",
referencedClasses: [],
//>>excludeEnd("ide");
messageSends: ["ifTrue:ifFalse:", "isMetaclass", ",", "name", "instanceClass", "isNil"]
}),
$globals.AbstractCodeGenerator);
$core.addMethod(
$core.method({
selector: "compileNode:",

@@ -54,0 +15,0 @@ protocol: 'compiling',

@@ -260,4 +260,3 @@ define("amber_core/Kernel-Promises", ["amber/boot", "amber_core/Kernel-Objects", "amber_core/Kernel-Infrastructure"], function($boot){"use strict";

//>>excludeEnd("ctx");
return Promise.resolve().then(function () {return $core.seamless(function () {return $recv(aBlock)._value_()})});
return self;
return $recv(self._new())._then_(aBlock);
//>>excludeStart("ctx", pragmas.excludeDebugContexts);

@@ -269,5 +268,29 @@ }, function($ctx1) {$ctx1.fill(self,"forBlock:",{aBlock:aBlock},$globals.Promise.klass)});

args: ["aBlock"],
source: "forBlock: aBlock\x0a\x22Returns a Promise that is resolved with the value of aBlock,\x0aand rejected if error happens while evaluating aBlock.\x22\x0a<return Promise.resolve().then(function () {return $core.seamless(function () {return $recv(aBlock)._value_()})})>",
source: "forBlock: aBlock\x0a\x22Returns a Promise that is resolved with the value of aBlock,\x0aand rejected if error happens while evaluating aBlock.\x22\x0a\x09^ self new then: aBlock",
referencedClasses: [],
//>>excludeEnd("ide");
messageSends: ["then:", "new"]
}),
$globals.Promise.klass);
$core.addMethod(
$core.method({
selector: "new",
protocol: 'instance creation',
fn: function (){
var self=this;
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
return $core.withContext(function($ctx1) {
//>>excludeEnd("ctx");
return Promise.resolve();
return self;
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
}, function($ctx1) {$ctx1.fill(self,"new",{},$globals.Promise.klass)});
//>>excludeEnd("ctx");
},
//>>excludeStart("ide", pragmas.excludeIdeData);
args: [],
source: "new\x0a\x22Returns a dumb Promise resolved with nil.\x22\x0a<return Promise.resolve()>",
referencedClasses: [],
//>>excludeEnd("ide");
messageSends: []

@@ -274,0 +297,0 @@ }),

@@ -13,5 +13,5 @@ /* ====================================================================

|
| Copyright (c) 2012-2014
| The Amber team https://github.com/amber-smalltalk?tab=members
| Amber contributors https://github.com/amber-smalltalk/amber/graphs/contributors
| Copyright (c) 2012-2016
| The Amber team https://lolg.it/org/amber/members
| Amber contributors (see /CONTRIBUTORS)
|

@@ -43,70 +43,4 @@ | Amber is released under the MIT license

define(['require', './compatibility'], function (require) {
define(['require', './brikz', './compatibility'], function (require, Brikz) {
/* Reconfigurable micro composition system, https://github.com/amber-smalltalk/brikz */
function Brikz(api, apiKey, initKey) {
var brikz = this, backup = {};
apiKey = apiKey || 'exports';
initKey = initKey || '__init__';
function mixin(src, target, what) {
for (var keys = Object.keys(what || src), l = keys.length, i = 0; i < l; ++i) {
if (src == null) {
target[keys[i]] = undefined;
} else {
var value = src[keys[i]];
if (typeof value !== "undefined") {
target[keys[i]] = value;
}
}
}
return target;
}
var d = {value: null, enumerable: false, configurable: true, writable: true};
Object.defineProperties(this, {ensure: d, rebuild: d});
var exclude = mixin(this, {});
this.rebuild = function () {
Object.keys(backup).forEach(function (key) {
mixin(null, api, (backup[key] || 0)[apiKey] || {});
});
var oapi = mixin(api, {}), order = [], chk = {};
brikz.ensure = function (key) {
if (key in exclude) {
return null;
}
var b = brikz[key], bak = backup[key];
mixin(null, api, api);
while (typeof b === "function") {
b = new b(brikz, api, bak);
}
if (b && !chk[key]) {
chk[key] = true;
order.push(b);
}
if (b && !b[apiKey]) {
b[apiKey] = mixin(api, {});
}
brikz[key] = b;
return b;
};
Object.keys(brikz).forEach(function (key) {
brikz.ensure(key);
});
brikz.ensure = null;
mixin(oapi, mixin(null, api, api));
order.forEach(function (brik) {
mixin(brik[apiKey] || {}, api);
});
order.forEach(function (brik) {
if (brik[initKey]) brik[initKey]();
});
backup = mixin(brikz, {});
};
}
/* Brikz end */
function inherits(child, parent) {

@@ -122,10 +56,12 @@ child.prototype = Object.create(parent.prototype, {

var jsGlobals = new Function("return this")();
var globals = Object.create(jsGlobals);
globals.SmalltalkSettings = {};
var api = {};
var brikz = new Brikz(api);
function SmalltalkGlobalsBrik(brikz, st) {
// jshint evil:true
var jsGlobals = new Function("return this")();
var globals = Object.create(jsGlobals);
globals.SmalltalkSettings = {};
this.globals = globals;
}
function RootBrik(brikz, st) {
/* Smalltalk foundational objects */

@@ -141,10 +77,10 @@

inherits(SmalltalkProtoObject, SmalltalkRoot);
function SmalltalkObject() {
}
inherits(SmalltalkObject, SmalltalkProtoObject);
function SmalltalkNil() {
}
inherits(SmalltalkProtoObject, SmalltalkRoot);
inherits(SmalltalkObject, SmalltalkProtoObject);
inherits(SmalltalkNil, SmalltalkObject);

@@ -169,14 +105,16 @@

this.__init__ = function () {
var globals = brikz.smalltalkGlobals.globals;
var addCoupledClass = brikz.classes.addCoupledClass;
st.addPackage("Kernel-Objects");
st.wrapClassName("ProtoObject", "Kernel-Objects", SmalltalkProtoObject, undefined, false);
st.wrapClassName("Object", "Kernel-Objects", SmalltalkObject, globals.ProtoObject, false);
st.wrapClassName("UndefinedObject", "Kernel-Objects", SmalltalkNil, globals.Object, false);
addCoupledClass("ProtoObject", undefined, "Kernel-Objects", SmalltalkProtoObject);
addCoupledClass("Object", globals.ProtoObject, "Kernel-Objects", SmalltalkObject);
addCoupledClass("UndefinedObject", globals.Object, "Kernel-Objects", SmalltalkNil);
};
this.__init__.once = true;
}
OrganizeBrik.deps = ["augments", "root"];
function OrganizeBrik(brikz, st) {
var SmalltalkObject = brikz.root.Object;
brikz.ensure("augments");
var SmalltalkObject = brikz.ensure("root").Object;
function SmalltalkOrganizer() {

@@ -198,7 +136,10 @@ }

this.__init__ = function () {
var globals = brikz.smalltalkGlobals.globals;
var addCoupledClass = brikz.classes.addCoupledClass;
st.addPackage("Kernel-Infrastructure");
st.wrapClassName("Organizer", "Kernel-Infrastructure", SmalltalkOrganizer, globals.Object, false);
st.wrapClassName("PackageOrganizer", "Kernel-Infrastructure", SmalltalkPackageOrganizer, globals.Organizer, false);
st.wrapClassName("ClassOrganizer", "Kernel-Infrastructure", SmalltalkClassOrganizer, globals.Organizer, false);
addCoupledClass("Organizer", globals.Object, "Kernel-Infrastructure", SmalltalkOrganizer);
addCoupledClass("PackageOrganizer", globals.Organizer, "Kernel-Infrastructure", SmalltalkPackageOrganizer);
addCoupledClass("ClassOrganizer", globals.Organizer, "Kernel-Infrastructure", SmalltalkClassOrganizer);
};
this.__init__.once = true;

@@ -223,103 +164,30 @@ this.setupClassOrganization = function (klass) {

function DNUBrik(brikz, st) {
SelectorsBrik.deps = ["selectorConversion"];
function SelectorsBrik(brikz, st) {
var selectorSet = Object.create(null);
var selectors = this.selectors = [];
var selectorPairs = this.selectorPairs = [];
brikz.ensure("selectorConversion");
brikz.ensure("messageSend");
var manip = brikz.ensure("manipulation");
var rootAsClass = brikz.ensure("root").rootAsClass;
/* Method not implemented handlers */
var methods = [], methodDict = Object.create(null);
this.selectors = [];
this.jsSelectors = [];
this.make = function (stSelector, targetClasses) {
var method = methodDict[stSelector];
if (method) return;
this.registerSelector = function (stSelector) {
if (selectorSet[stSelector]) return null;
var jsSelector = st.st2js(stSelector);
this.selectors.push(stSelector);
this.jsSelectors.push(jsSelector);
method = {jsSelector: jsSelector, fn: createHandler(stSelector)};
methodDict[stSelector] = method;
methods.push(method);
manip.installMethod(method, rootAsClass);
targetClasses.forEach(function (target) {
manip.installMethod(method, target);
});
return method;
selectorSet[stSelector] = true;
selectors.push(stSelector);
var pair = {st: stSelector, js: jsSelector};
selectorPairs.push(pair);
return pair;
};
/* Dnu handler method */
/* Answer all method selectors based on dnu handlers */
function createHandler(stSelector) {
return function () {
return brikz.messageSend.messageNotUnderstood(this, stSelector, arguments);
};
}
}
function ClassInitBrik(brikz, st) {
var dnu = brikz.ensure("dnu");
var manip = brikz.ensure("manipulation");
/* Initialize a class in its class hierarchy. Handle both classes and
metaclasses. */
st.init = function (klass) {
initClass(klass);
if (klass.klass && !klass.meta) {
initClass(klass.klass);
}
st.allSelectors = function () {
return selectors;
};
function initClass(klass) {
if (klass.wrapped) {
copySuperclass(klass);
}
}
this.initClass = initClass;
function copySuperclass(klass) {
var superclass = klass.superclass,
localMethods = klass.methods,
localMethodsByJsSelector = {};
Object.keys(localMethods).forEach(function (each) {
var localMethod = localMethods[each];
localMethodsByJsSelector[localMethod.jsSelector] = localMethod;
});
var myproto = klass.fn.prototype,
superproto = superclass.fn.prototype;
dnu.jsSelectors.forEach(function (selector) {
if (!localMethodsByJsSelector[selector]) {
manip.installMethod({
jsSelector: selector,
fn: superproto[selector]
}, klass);
} else if (!myproto[selector]) {
manip.installMethod(localMethodsByJsSelector[selector], klass);
}
});
}
}
function ManipulationBrik(brikz, st) {
this.installMethod = function (method, klass) {
Object.defineProperty(klass.fn.prototype, method.jsSelector, {
value: method.fn,
enumerable: false, configurable: true, writable: true
});
};
}
PackagesBrik.deps = ["organize", "root"];
function PackagesBrik(brikz, st) {
var setupPackageOrganization = brikz.organize.setupPackageOrganization;
var SmalltalkObject = brikz.root.Object;
var org = brikz.ensure("organize");
var root = brikz.ensure("root");
var nil = root.nil;
var SmalltalkObject = root.Object;
function SmalltalkPackage() {

@@ -331,5 +199,8 @@ }

this.__init__ = function () {
var globals = brikz.smalltalkGlobals.globals;
var addCoupledClass = brikz.classes.addCoupledClass;
st.addPackage("Kernel-Infrastructure");
st.wrapClassName("Package", "Kernel-Infrastructure", SmalltalkPackage, globals.Object, false);
addCoupledClass("Package", globals.Object, "Kernel-Infrastructure", SmalltalkPackage);
};
this.__init__.once = true;

@@ -343,3 +214,3 @@ st.packages = {};

that.pkgName = spec.pkgName;
org.setupPackageOrganization(that);
setupPackageOrganization(that);
that.properties = spec.properties || {};

@@ -355,3 +226,3 @@ return that;

if (!pkgName) {
return nil;
return null;
}

@@ -372,10 +243,10 @@ if (!(st.packages[pkgName])) {

ClassesBrik.deps = ["organize", "root", "smalltalkGlobals"];
function ClassesBrik(brikz, st) {
var org = brikz.ensure("organize");
var root = brikz.ensure("root");
var classInit = brikz.ensure("classInit");
var nil = root.nil;
var rootAsClass = root.rootAsClass;
var SmalltalkObject = root.Object;
var setupClassOrganization = brikz.organize.setupClassOrganization;
var addOrganizationElement = brikz.organize.addOrganizationElement;
var removeOrganizationElement = brikz.organize.removeOrganizationElement;
var globals = brikz.smalltalkGlobals.globals;
var rootAsClass = brikz.root.rootAsClass;
var SmalltalkObject = brikz.root.Object;
rootAsClass.klass = {fn: SmalltalkClass};

@@ -396,9 +267,15 @@

SmalltalkBehavior.prototype.toString = function () {
return 'Smalltalk ' + this.className;
};
SmalltalkMetaclass.prototype.meta = true;
this.__init__ = function () {
var globals = brikz.smalltalkGlobals.globals;
var addCoupledClass = brikz.classes.addCoupledClass;
st.addPackage("Kernel-Classes");
st.wrapClassName("Behavior", "Kernel-Classes", SmalltalkBehavior, globals.Object, false);
st.wrapClassName("Metaclass", "Kernel-Classes", SmalltalkMetaclass, globals.Behavior, false);
st.wrapClassName("Class", "Kernel-Classes", SmalltalkClass, globals.Behavior, false);
addCoupledClass("Behavior", globals.Object, "Kernel-Classes", SmalltalkBehavior);
addCoupledClass("Metaclass", globals.Behavior, "Kernel-Classes", SmalltalkMetaclass);
addCoupledClass("Class", globals.Behavior, "Kernel-Classes", SmalltalkClass);

@@ -409,2 +286,3 @@ // Manually bootstrap the metaclass hierarchy

};
this.__init__.once = true;

@@ -414,3 +292,2 @@ /* Smalltalk classes */

var classes = [];
var wrappedClasses = [];

@@ -423,3 +300,2 @@ /* Smalltalk class creation. A class is an instance of an automatically

function klass(spec) {
spec = spec || {};
var setSuperClass = spec.superclass;

@@ -442,3 +318,2 @@ if (!spec.superclass) {

that.className = spec.className;
that.wrapped = spec.wrapped || false;
meta.className = spec.className + ' class';

@@ -450,15 +325,24 @@ meta.superclass = spec.superclass.klass;

function metaclass(spec) {
spec = spec || {};
var that = new SmalltalkMetaclass();
that.fn = inherits(function () {
}, spec.superclass.klass.fn);
wireKlass(that);
that.instanceClass = new that.fn();
setupClass(that);
setupClass(that, {});
return that;
}
SmalltalkBehavior.prototype.toString = function () {
return 'Smalltalk ' + this.className;
};
function setupClass(klass, spec) {
klass.iVarNames = spec.iVarNames || [];
if (spec.pkg) {
klass.pkg = spec.pkg;
}
setupClassOrganization(klass);
Object.defineProperty(klass, "methods", {
value: Object.create(null),
enumerable: false, configurable: true, writable: true
});
}
function wireKlass(klass) {

@@ -471,15 +355,4 @@ Object.defineProperty(klass.fn.prototype, "klass", {

function setupClass(klass, spec) {
spec = spec || {};
klass.iVarNames = spec.iVarNames || [];
klass.pkg = spec.pkg;
this.wireKlass = wireKlass;
org.setupClassOrganization(klass);
Object.defineProperty(klass, "methods", {
value: Object.create(null),
enumerable: false, configurable: true, writable: true
});
wireKlass(klass);
}
/* Add a class to the smalltalk object, creating a new one if needed.

@@ -491,9 +364,9 @@ A Package is lazily created if it does not exist with given name. */

// warn about it.
if (typeof superclass == 'undefined' || superclass == nil) {
if (typeof superclass == 'undefined' || superclass && superclass.isNil) {
console.warn('Compiling ' + className + ' as a subclass of `nil`. A dependency might be missing.');
}
rawAddClass(pkgName, className, superclass, iVarNames, false, null);
return rawAddClass(pkgName, className, superclass, iVarNames, null);
};
function rawAddClass(pkgName, className, superclass, iVarNames, wrapped, fn) {
function rawAddClass(pkgName, className, superclass, iVarNames, fn) {
var pkg = st.packages[pkgName];

@@ -505,17 +378,12 @@

if (!superclass || superclass == nil) {
if (superclass == null || superclass.isNil) {
superclass = null;
}
var theClass = globals.hasOwnProperty(className) && globals[className];
if (theClass && theClass.superclass == superclass) {
// theClass.superclass = superclass;
theClass.iVarNames = iVarNames || [];
if (theClass && theClass.superclass == superclass && !fn) {
if (iVarNames) theClass.iVarNames = iVarNames;
if (pkg) theClass.pkg = pkg;
if (fn) {
fn.prototype = theClass.fn.prototype;
theClass.fn = fn;
fn.prototype.constructor = fn;
}
} else {
if (theClass) {
iVarNames = iVarNames || theClass.iVarNames;
st.removeClass(theClass);

@@ -528,4 +396,3 @@ }

iVarNames: iVarNames,
fn: fn,
wrapped: wrapped
fn: fn
});

@@ -537,7 +404,9 @@

classes.addElement(theClass);
org.addOrganizationElement(pkg, theClass);
addOrganizationElement(pkg, theClass);
if (st._classAdded) st._classAdded(theClass);
return theClass;
}
st.removeClass = function (klass) {
org.removeOrganizationElement(klass.pkg, klass);
removeOrganizationElement(klass.pkg, klass);
classes.removeElement(klass);

@@ -560,26 +429,9 @@ removeSubclass(klass);

/* Create a new class wrapping a JavaScript constructor, and add it to the
global smalltalk object. Package is lazily created if it does not exist with given name. */
/* Create a new class coupling with a JavaScript constructor,
and add it to the global smalltalk object.*/
st.wrapClassName = function (className, pkgName, fn, superclass, wrapped) {
wrapped = wrapped !== false;
rawAddClass(pkgName, className, superclass, globals[className] && globals[className].iVarNames, wrapped, fn);
if (wrapped) {
wrappedClasses.addElement(globals[className]);
}
this.addCoupledClass = function (className, superclass, pkgName, fn) {
return rawAddClass(pkgName, className, superclass, null, fn);
};
/* Manually set the constructor of an existing Smalltalk klass, making it a wrapped class. */
st.setClassConstructor = function (klass, constructor) {
wrappedClasses.addElement(klass);
klass.wrapped = true;
klass.fn = constructor;
// The fn property changed. We need to add back the klass property to the prototype
wireKlass(klass);
classInit.initClass(klass);
};
/* Create an alias for an existing class */

@@ -594,28 +446,35 @@

st.classes = function () {
st.classes = this.classes = function () {
return classes;
};
st.wrappedClasses = function () {
return wrappedClasses;
};
function metaSubclasses(metaclass) {
return metaclass.instanceClass.subclasses
.filter(function (each) {
return !each.meta;
})
.map(function (each) {
return each.klass;
});
}
// Still used, but could go away now that subclasses are stored
// into classes directly.
st.allSubclasses = function (klass) {
return klass._allSubclasses();
st.metaSubclasses = metaSubclasses;
st.traverseClassTree = function (klass, fn) {
var queue = [klass];
for (var i = 0; i < queue.length; ++i) {
var item = queue[i];
fn(item);
var subclasses = item.meta ? metaSubclasses(item) : item.subclasses;
queue.push.apply(queue, subclasses);
}
};
}
MethodsBrik.deps = ["organize", "selectors", "root", "selectorConversion"];
function MethodsBrik(brikz, st) {
var addOrganizationElement = brikz.organize.addOrganizationElement;
var registerSelector = brikz.selectors.registerSelector;
var SmalltalkObject = brikz.root.Object;
var manip = brikz.ensure("manipulation");
var org = brikz.ensure("organize");
var stInit = brikz.ensure("stInit");
var dnu = brikz.ensure("dnu");
var SmalltalkObject = brikz.ensure("root").Object;
brikz.ensure("selectorConversion");
brikz.ensure("classes");
function SmalltalkMethod() {

@@ -627,5 +486,8 @@ }

this.__init__ = function () {
var globals = brikz.smalltalkGlobals.globals;
var addCoupledClass = brikz.classes.addCoupledClass;
st.addPackage("Kernel-Methods");
st.wrapClassName("CompiledMethod", "Kernel-Methods", SmalltalkMethod, globals.Object, false);
addCoupledClass("CompiledMethod", globals.Object, "Kernel-Methods", SmalltalkMethod);
};
this.__init__.once = true;

@@ -637,4 +499,5 @@ /* Smalltalk method object. To add a method to a class,

var that = new SmalltalkMethod();
that.selector = spec.selector;
that.jsSelector = spec.jsSelector;
var selector = spec.selector;
that.selector = selector;
that.jsSelector = st.st2js(selector);
that.args = spec.args || {};

@@ -649,13 +512,5 @@ that.protocol = spec.protocol;

function ensureJsSelector(method) {
if (!(method.jsSelector)) {
method.jsSelector = st.st2js(method.selector);
}
}
/* Add/remove a method to/from a class */
st.addMethod = function (method, klass) {
ensureJsSelector(method);
manip.installMethod(method, klass);
klass.methods[method.selector] = method;

@@ -666,39 +521,20 @@ method.methodClass = klass;

// Therefore we populate the organizer here too
org.addOrganizationElement(klass, method.protocol);
addOrganizationElement(klass, method.protocol);
propagateMethodChange(klass, method);
var newSelectors = [];
var usedSelectors = method.messageSends,
targetClasses = stInit.initialized() ? st.wrappedClasses() : [];
function selectorInUse(stSelector) {
var pair = registerSelector(stSelector);
if (pair) {
newSelectors.push(pair);
}
}
dnu.make(method.selector, targetClasses);
selectorInUse(method.selector);
method.messageSends.forEach(selectorInUse);
for (var i = 0; i < usedSelectors.length; i++) {
dnu.make(usedSelectors[i], targetClasses);
}
if (st._methodAdded) st._methodAdded(method, klass);
if (st._selectorsAdded) st._selectorsAdded(newSelectors);
};
function propagateMethodChange(klass, method) {
// If already initialized (else it will be done later anyway),
// re-initialize all subclasses to ensure the method change
// propagation (for wrapped classes, not using the prototype
// chain).
if (stInit.initialized()) {
st.allSubclasses(klass).forEach(function (subclass) {
initMethodInClass(subclass, method);
});
}
}
function initMethodInClass(klass, method) {
if (klass.wrapped && !klass.methods[method.selector]) {
var jsSelector = method.jsSelector;
manip.installMethod({
jsSelector: jsSelector,
fn: klass.superclass.fn.prototype[jsSelector]
}, klass);
}
}
st.removeMethod = function (method, klass) {

@@ -713,8 +549,5 @@ if (klass !== method.methodClass) {

ensureJsSelector(method);
delete klass.fn.prototype[method.jsSelector];
delete klass.methods[method.selector];
initMethodInClass(klass, method);
propagateMethodChange(klass, method);
if (st._methodRemoved) st._methodRemoved(method, klass);

@@ -724,13 +557,5 @@ // Do *not* delete protocols from here.

};
/* Answer all method selectors based on dnu handlers */
st.allSelectors = function () {
return dnu.selectors;
};
}
function AugmentsBrik(brikz, st) {
/* Array extensions */

@@ -755,389 +580,54 @@

SmalltalkInitBrik.deps = ["globals", "classes"];
function SmalltalkInitBrik(brikz, st) {
var globals = brikz.smalltalkGlobals.globals;
brikz.ensure("classInit");
brikz.ensure("classes");
var initialized = false;
var runtimeLoadedPromise = new Promise(function (resolve, reject) {
require(['./kernel-runtime'], resolve, reject);
});
/* Smalltalk initialization. Called on page load */
st.initialize = function () {
if (initialized) {
return;
}
st.classes().forEach(function (klass) {
st.init(klass);
});
runnable();
st.classes().forEach(function (klass) {
klass._initialize();
});
initialized = true;
};
this.initialized = function () {
return initialized;
};
this.__init__ = function () {
st.addPackage("Kernel-Methods");
st.wrapClassName("Number", "Kernel-Objects", Number, globals.Object);
st.wrapClassName("BlockClosure", "Kernel-Methods", Function, globals.Object);
st.wrapClassName("Boolean", "Kernel-Objects", Boolean, globals.Object);
st.wrapClassName("Date", "Kernel-Objects", Date, globals.Object);
st.addPackage("Kernel-Collections");
st.addClass("Collection", globals.Object, null, "Kernel-Collections");
st.addClass("IndexableCollection", globals.Collection, null, "Kernel-Collections");
st.addClass("SequenceableCollection", globals.IndexableCollection, null, "Kernel-Collections");
st.addClass("CharacterArray", globals.SequenceableCollection, null, "Kernel-Collections");
st.wrapClassName("String", "Kernel-Collections", String, globals.CharacterArray);
st.wrapClassName("Array", "Kernel-Collections", Array, globals.SequenceableCollection);
st.wrapClassName("RegularExpression", "Kernel-Collections", RegExp, globals.Object);
st.addPackage("Kernel-Exceptions");
st.wrapClassName("Error", "Kernel-Exceptions", Error, globals.Object);
st.addPackage("Kernel-Promises");
st.addClass("Thenable", globals.Object, null, "Kernel-Promises");
st.wrapClassName("Promise", "Kernel-Promises", Promise, globals.Thenable);
/* Alias definitions */
st.alias(globals.Array, "OrderedCollection");
st.alias(globals.Date, "Time");
};
}
function PrimitivesBrik(brikz, st) {
/* Unique ID number generator */
var oid = 0;
st.nextId = function () {
oid += 1;
return oid;
};
/* Converts a JavaScript object to valid Smalltalk Object */
st.readJSObject = function (js) {
if (js == null)
return null;
var readObject = js.constructor === Object;
var readArray = js.constructor === Array;
var object = readObject ? globals.Dictionary._new() : readArray ? [] : js;
for (var i in js) {
if (readObject) {
object._at_put_(i, st.readJSObject(js[i]));
return runtimeLoadedPromise.then(function (configureWithRuntime) {
if (initialized) {
return;
}
if (readArray) {
object[i] = st.readJSObject(js[i]);
}
}
return object;
};
/* Boolean assertion */
st.assert = function (shouldBeBoolean) {
if (typeof shouldBeBoolean === "boolean") return shouldBeBoolean;
else if (shouldBeBoolean != null && typeof shouldBeBoolean === "object") {
shouldBeBoolean = shouldBeBoolean.valueOf();
if (typeof shouldBeBoolean === "boolean") return shouldBeBoolean;
}
globals.NonBooleanReceiver._new()._object_(shouldBeBoolean)._signal();
};
configureWithRuntime(brikz);
/* List of all reserved words in JavaScript. They may not be used as variables
in Smalltalk. */
/* Alias definitions */
// list of reserved JavaScript keywords as of
// http://es5.github.com/#x7.6.1.1
// and
// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.6.1
st.reservedWords = ['break', 'case', 'catch', 'continue', 'debugger',
'default', 'delete', 'do', 'else', 'finally', 'for', 'function',
'if', 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw',
'try', 'typeof', 'var', 'void', 'while', 'with',
// Amber protected words: these should not be compiled as-is when in code
'arguments',
// ES5: future use: http://es5.github.com/#x7.6.1.2
'class', 'const', 'enum', 'export', 'extends', 'import', 'super',
// ES5: future use in strict mode
'implements', 'interface', 'let', 'package', 'private', 'protected',
'public', 'static', 'yield'];
st.alias(globals.Array, "OrderedCollection");
st.alias(globals.Date, "Time");
st.globalJsVariables = ['window', 'document', 'process', 'global'];
st.classes().forEach(function (klass) {
klass._initialize();
});
}
function RuntimeBrik(brikz, st) {
brikz.ensure("selectorConversion");
var root = brikz.ensure("root");
var nil = root.nil;
var SmalltalkObject = root.Object;
function SmalltalkMethodContext(home, setup) {
this.sendIdx = {};
this.homeContext = home;
this.setup = setup || function () {
};
this.supercall = false;
}
inherits(SmalltalkMethodContext, SmalltalkObject);
this.__init__ = function () {
st.addPackage("Kernel-Methods");
st.wrapClassName("MethodContext", "Kernel-Methods", SmalltalkMethodContext, globals.Object, false);
// Fallbacks
SmalltalkMethodContext.prototype.locals = {};
SmalltalkMethodContext.prototype.receiver = null;
SmalltalkMethodContext.prototype.selector = null;
SmalltalkMethodContext.prototype.lookupClass = null;
SmalltalkMethodContext.prototype.fill = function (receiver, selector, locals, lookupClass) {
this.receiver = receiver;
this.selector = selector;
this.locals = locals || {};
this.lookupClass = lookupClass;
if (this.homeContext) {
this.homeContext.evaluatedSelector = selector;
}
};
SmalltalkMethodContext.prototype.fillBlock = function (locals, ctx, index) {
this.locals = locals || {};
this.outerContext = ctx;
this.index = index || 0;
};
SmalltalkMethodContext.prototype.init = function () {
var home = this.homeContext;
if (home) {
home.init();
}
this.setup(this);
};
SmalltalkMethodContext.prototype.method = function () {
var method;
var lookup = this.lookupClass || this.receiver.klass;
while (!method && lookup) {
method = lookup.methods[st.js2st(this.selector)];
lookup = lookup.superclass;
}
return method;
};
};
/* This is the current call context object. While it is publicly available,
Use smalltalk.getThisContext() instead which will answer a safe copy of
the current context */
var thisContext = null;
st.withContext = function (worker, setup) {
if (thisContext) {
return inContext(worker, setup);
} else {
return inContextWithErrorHandling(worker, setup);
}
};
/*
Runs worker function so that error handler is not set up
if there isn't one. This is accomplished by unconditional
wrapping inside a context of a simulated `nil seamlessDoIt` call,
which then stops error handler setup (see st.withContext above).
The effect is, $core.seamless(fn)'s exceptions are not
handed into ST error handler and caller should process them.
*/
st.seamless = function (worker) {
return inContext(worker, function (ctx) {
ctx.fill(nil, "seamlessDoIt", {}, globals.UndefinedObject);
initialized = true;
});
};
function inContextWithErrorHandling(worker, setup) {
try {
return inContext(worker, setup);
} catch (error) {
handleError(error);
thisContext = null;
// Rethrow the error in any case.
error.amberHandled = true;
throw error;
}
}
function inContext(worker, setup) {
var oldContext = thisContext;
thisContext = new SmalltalkMethodContext(thisContext, setup);
var result = worker(thisContext);
thisContext = oldContext;
return result;
}
/* Wrap a JavaScript exception in a Smalltalk Exception.
In case of a RangeError, stub the stack after 100 contexts to
avoid another RangeError later when the stack is manipulated. */
function wrappedError(error) {
var errorWrapper = globals.JavaScriptException._on_(error);
// Add the error to the context, so it is visible in the stack
try {
errorWrapper._signal();
} catch (ex) {
}
var context = st.getThisContext();
if (isRangeError(error)) {
stubContextStack(context);
}
errorWrapper._context_(context);
return errorWrapper;
}
/* Stub the context stack after 100 contexts */
function stubContextStack(context) {
var currentContext = context;
var contexts = 0;
while (contexts < 100) {
if (currentContext) {
currentContext = currentContext.homeContext;
}
contexts++;
}
if (currentContext) {
currentContext.homeContext = undefined;
}
}
function isRangeError(error) {
return error instanceof RangeError;
}
/* Handles Smalltalk errors. Triggers the registered ErrorHandler
(See the Smalltalk class ErrorHandler and its subclasses */
function handleError(error) {
if (!error.smalltalkError) {
error = wrappedError(error);
}
globals.ErrorHandler._handleError_(error);
}
/* Handle thisContext pseudo variable */
st.getThisContext = function () {
if (thisContext) {
thisContext.init();
return thisContext;
} else {
return nil;
}
};
}
function MessageSendBrik(brikz, st) {
brikz.ensure("selectorConversion");
var nil = brikz.ensure("root").nil;
/* Handles unhandled errors during message sends */
// simply send the message and handle #dnu:
st.send = function (receiver, jsSelector, args, klass) {
var method;
if (receiver == null) {
receiver = nil;
}
method = klass ? klass.fn.prototype[jsSelector] : receiver.klass && receiver[jsSelector];
if (method) {
return method.apply(receiver, args || []);
} else {
return messageNotUnderstood(receiver, st.js2st(jsSelector), args);
}
};
function invokeDnuMethod(receiver, stSelector, args) {
return receiver._doesNotUnderstand_(
globals.Message._new()
._selector_(stSelector)
._arguments_([].slice.call(args))
);
}
/* Handles #dnu: *and* JavaScript method calls.
if the receiver has no klass, we consider it a JS object (outside of the
Amber system). Else assume that the receiver understands #doesNotUnderstand: */
function messageNotUnderstood(receiver, stSelector, args) {
if (receiver.klass != null && !receiver.allowJavaScriptCalls) {
return invokeDnuMethod(receiver, stSelector, args);
}
/* Call a method of a JS object, or answer a property if it exists.
Else try wrapping a JSObjectProxy around the receiver. */
var propertyName = st.st2prop(stSelector);
if (!(propertyName in receiver)) {
return invokeDnuMethod(globals.JSObjectProxy._on_(receiver), stSelector, args);
}
return accessJavaScript(receiver, propertyName, args);
}
/* If the object property is a function, then call it, except if it starts with
an uppercase character (we probably want to answer the function itself in this
case and send it #new from Amber).
Converts keyword-based selectors by using the first
keyword only, but keeping all message arguments.
Example:
"self do: aBlock with: anObject" -> "self.do(aBlock, anObject)" */
function accessJavaScript(receiver, propertyName, args) {
var propertyValue = receiver[propertyName];
if (typeof propertyValue === "function" && !/^[A-Z]/.test(propertyName)) {
return propertyValue.apply(receiver, args || []);
} else if (args.length > 0) {
receiver[propertyName] = args[0];
return nil;
} else {
return propertyValue;
}
}
st.accessJavaScript = accessJavaScript;
this.messageNotUnderstood = messageNotUnderstood;
}
function SelectorConversionBrik(brikz, st) {
/* Convert a Smalltalk selector into a JS selector */
st.st2js = function (string) {
var selector = '_' + string;
selector = selector.replace(/:/g, '_');
selector = selector.replace(/[\&]/g, '_and');
selector = selector.replace(/[\|]/g, '_or');
selector = selector.replace(/[+]/g, '_plus');
selector = selector.replace(/-/g, '_minus');
selector = selector.replace(/[*]/g, '_star');
selector = selector.replace(/[\/]/g, '_slash');
selector = selector.replace(/[\\]/g, '_backslash');
selector = selector.replace(/[\~]/g, '_tild');
selector = selector.replace(/>/g, '_gt');
selector = selector.replace(/</g, '_lt');
selector = selector.replace(/=/g, '_eq');
selector = selector.replace(/,/g, '_comma');
selector = selector.replace(/[@]/g, '_at');
return selector;
return '_' + string
.replace(/:/g, '_')
.replace(/[\&]/g, '_and')
.replace(/[\|]/g, '_or')
.replace(/[+]/g, '_plus')
.replace(/-/g, '_minus')
.replace(/[*]/g, '_star')
.replace(/[\/]/g, '_slash')
.replace(/[\\]/g, '_backslash')
.replace(/[\~]/g, '_tild')
.replace(/>/g, '_gt')
.replace(/</g, '_lt')
.replace(/=/g, '_eq')
.replace(/,/g, '_comma')
.replace(/[@]/g, '_at');
};

@@ -1186,7 +676,5 @@

function AMDBrik(brikz, st) {
this.__init__ = function () {
st.amdRequire = require;
st.defaultTransportType = st.defaultTransportType || "amd";
st.defaultAmdNamespace = st.defaultAmdNamespace || "amber_core";
};
st.amdRequire = require;
st.defaultTransportType = st.defaultTransportType || "amd";
st.defaultAmdNamespace = st.defaultAmdNamespace || "amber_core";
}

@@ -1196,6 +684,7 @@

/* (logically it belongs more to PrimitiveBrik) */
AsReceiverBrik.deps = ["smalltalkGlobals", "root"];
function AsReceiverBrik(brikz, st) {
var globals = brikz.smalltalkGlobals.globals;
var nil = brikz.root.nil;
var nil = brikz.ensure("root").nil;
/**

@@ -1216,5 +705,6 @@ * This function is used all over the compiled amber code.

// IMPORTANT: This optimization (return o if typeof !== "object")
// assumes all primitive types are wrapped by some Smalltalk class
// so they can be returned as-is, without boxing and looking for .klass.
// KEEP THE primitives-are-wrapped INVARIANT!
// assumes all primitive types are coupled with some
// (detached root) Smalltalk class so they can be returned as-is,
// without boxing and looking for .klass.
// KEEP THE primitives-are-coupled INVARIANT!
return o;

@@ -1224,11 +714,12 @@ };

var api = {};
var brikz = new Brikz(api);
/* Making smalltalk that can load */
brikz.smalltalkGlobals = SmalltalkGlobalsBrik;
brikz.root = RootBrik;
brikz.dnu = DNUBrik;
brikz.selectors = SelectorsBrik;
brikz.organize = OrganizeBrik;
brikz.selectorConversion = SelectorConversionBrik;
brikz.classInit = ClassInitBrik;
brikz.manipulation = ManipulationBrik;
brikz.packages = PackagesBrik;

@@ -1244,12 +735,2 @@ brikz.classes = ClassesBrik;

/* Making smalltalk that can run */
function runnable() {
brikz.messageSend = MessageSendBrik;
brikz.runtime = RuntimeBrik;
brikz.primitives = PrimitivesBrik;
brikz.rebuild();
}
return {

@@ -1259,5 +740,5 @@ api: api,

dnu: brikz.root.rootAsClass,
globals: globals,
globals: brikz.smalltalkGlobals.globals,
asReceiver: brikz.asReceiver.asReceiver
};
});
define([
'./helpers',
'./compatibility', // pre-fetch, dep of ./boot
'./boot', // pre-fetch, dep of ./helpers
// --- packages of the core Amber begin here ---

@@ -4,0 +6,0 @@ 'amber_core/Kernel-Objects',

define([
'./lang',
'./compatibility', // pre-fetch, dep of ./boot
'./boot', // pre-fetch, dep of ./helpers
'./helpers', // pre-fetch, dep of ./deploy
'./deploy', // pre-fetch, dep of ./lang
'./lang',
// --- packages of the development only Amber begin here ---

@@ -6,0 +8,0 @@ 'amber_core/SUnit',

@@ -71,3 +71,3 @@ define(["amber/boot", "require"], function (boot, require) {

return api.initialize();
})
});
};

@@ -74,0 +74,0 @@

define([
'./deploy',
'./compatibility', // pre-fetch, dep of ./boot
'./boot', // pre-fetch, dep of ./helpers
'./helpers', // pre-fetch, dep of ./deploy
'./deploy',
'./parser',

@@ -5,0 +7,0 @@ // --- packages for the Amber reflection begin here ---

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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