Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
- fix $SC.Ref
- fix $SC.Function
- fix sc-mode
- fix ArrayedCollection#asString
- build v0.0.23
  • Loading branch information
mohayonao committed May 12, 2014
1 parent 10b60b1 commit 6b7a301
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 24 deletions.
29 changes: 17 additions & 12 deletions build/scscript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function(global) {
"use strict";

var sc = { VERSION: "0.0.22" };
var sc = { VERSION: "0.0.23" };

// src/sc/sc.js
(function(sc) {
Expand Down Expand Up @@ -4431,6 +4431,7 @@ var sc = { VERSION: "0.0.22" };
(function(sc) {

var $SC = sc.lang.$SC;
var fn = sc.lang.fn;
var klass = sc.lang.klass;

function SCNil() {
Expand Down Expand Up @@ -4560,6 +4561,12 @@ var sc = { VERSION: "0.0.22" };
__tag: 12
});

function SCRef(args) {
this.__initializeWith__("Object");
this._value = args[0] || /* istanbul ignore next */ $nil;
}
sc.lang.klass.define(SCRef, "Ref : AbstractFunction");

function SCInterpreter() {
this.__initializeWith__("Object");
}
Expand Down Expand Up @@ -4660,12 +4667,16 @@ var sc = { VERSION: "0.0.22" };
return instance;
};

$SC.Function = function(value) {
$SC.Function = function(value, def) {
var instance = new SCFunction();
instance._ = value;
instance._ = def ? fn(value, def) : value;
return instance;
};

$SC.Ref = function(value) {
return new SCRef([ value ]);
};

sc.lang.klass.$interpreter = new SCInterpreter();

})(sc);
Expand Down Expand Up @@ -8320,14 +8331,8 @@ var sc = { VERSION: "0.0.22" };
(function(sc) {

var fn = sc.lang.fn;
var $SC = sc.lang.$SC;

function SCRef(args) {
this.__initializeWith__("Object");
this._value = args[0] || $SC.Nil();
}

sc.lang.klass.define(SCRef, "Ref : AbstractFunction", function(spec, utils) {
sc.lang.klass.refine("Ref", function(spec, utils) {
spec.valueOf = function() {
return this._value.valueOf();
};
Expand Down Expand Up @@ -12352,8 +12357,8 @@ var sc = { VERSION: "0.0.22" };
};

spec.asString = function() {
return $SC.String("[ " + this._.map(function(elem) {
return elem.__str__();
return $SC.String("[ " + this._.map(function($elem) {
return $elem.asString().__str__();
}).join(", ") + " ]");
};
});
Expand Down
4 changes: 4 additions & 0 deletions demo/sc-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
return "keyword";
}

if (stream.match(/[a-z]\w*/)) {
return "atom";
}

if (stream.match(/[A-Z]\w*/)) {
return "class";
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scscript",
"version": "0.0.22",
"version": "0.0.23",
"author": "Nao Yonamine <mohayonao@gmail.com>",
"homepage": "http://mohayonao.github.io/SCScript/",
"bugs": "https://github.com/mohayonao/SCScript/issues",
Expand Down
4 changes: 2 additions & 2 deletions src/sc/lang/classlib/Collections/ArrayedCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@
};

spec.asString = function() {
return $SC.String("[ " + this._.map(function(elem) {
return elem.__str__();
return $SC.String("[ " + this._.map(function($elem) {
return $elem.asString().__str__();
}).join(", ") + " ]");
};
});
Expand Down
8 changes: 1 addition & 7 deletions src/sc/lang/classlib/Core/Ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@
require("./Object");

var fn = sc.lang.fn;
var $SC = sc.lang.$SC;

function SCRef(args) {
this.__initializeWith__("Object");
this._value = args[0] || $SC.Nil();
}

sc.lang.klass.define(SCRef, "Ref : AbstractFunction", function(spec, utils) {
sc.lang.klass.refine("Ref", function(spec, utils) {
spec.valueOf = function() {
return this._value.valueOf();
};
Expand Down
16 changes: 14 additions & 2 deletions src/sc/lang/klass/constructors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"use strict";

require("./klass");
require("../fn");

var $SC = sc.lang.$SC;
var fn = sc.lang.fn;
var klass = sc.lang.klass;

function SCNil() {
Expand Down Expand Up @@ -133,6 +135,12 @@
__tag: sc.C.TAG_FUNCTION
});

function SCRef(args) {
this.__initializeWith__("Object");
this._value = args[0] || /* istanbul ignore next */ $nil;
}
sc.lang.klass.define(SCRef, "Ref : AbstractFunction");

function SCInterpreter() {
this.__initializeWith__("Object");
}
Expand Down Expand Up @@ -234,12 +242,16 @@
return instance;
};

$SC.Function = function(value) {
$SC.Function = function(value, def) {
var instance = new SCFunction();
instance._ = value;
instance._ = def ? fn(value, def) : value;
return instance;
};

$SC.Ref = function(value) {
return new SCRef([ value ]);
};

sc.lang.klass.$interpreter = new SCInterpreter();

})(sc);
9 changes: 9 additions & 0 deletions src/sc/lang/klass/constructors_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,18 @@
});
it("Function should return an instance of SCFunction", function() {
var a;

a = $SC.Function(function() {}, "a");
expect(a).to.be.a("SCFunction");

a = $SC.Function(function() {});
expect(a).to.be.a("SCFunction");
});
it("Ref should return an instance of SCRef", function() {
var a;
a = $SC.Ref($SC.Integer(10));
expect(a._value).to.be.a("SCInteger").that.equals(10);
});
});

})();

0 comments on commit 6b7a301

Please sign in to comment.