Skip to content

Commit

Permalink
[changed] test/extend
Browse files Browse the repository at this point in the history
  • Loading branch information
rainfore committed Sep 18, 2015
1 parent 5b33aa9 commit 66a13c8
Show file tree
Hide file tree
Showing 5 changed files with 11,730 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
*sublime*
.sourcemap
private/
npm-debug.log
20 changes: 15 additions & 5 deletions lib/interpreter/interpreter.js
Expand Up @@ -127,7 +127,10 @@ _.walk_ruleset = function(ast){
this.rulesets.pop();
var self = this;
rawSelector.list.forEach(function(complex){
self.define(complex.string, ast);
// list for @extend
var symbols = self.getSymbol(complex.string) || [];
symbols.push(ast);
self.define(complex.string, symbols);
});
if(ast.abstract){
rawSelector.list = [];
Expand Down Expand Up @@ -527,12 +530,15 @@ _.walk_extend = function(ast){
var selector = this.walk(ast.selector);
var self = this;
selector.list.forEach(function(item){
var extend = self.resolve(item.string);
if(extend){
extend.addRef(ruleset);
var extendz = self.resolve(item.string);

if(extendz) {
extendz.forEach(function(extend) {
extend && extend.addRef(ruleset);
});
}
// @MARK else prevent the error just ignored
})
});
}

_.walk_import = function(ast){
Expand Down Expand Up @@ -776,6 +782,10 @@ _.resolve = function(id){
return this.scope.resolve(id);
}

_.getSymbol = function(id){
return this.scope.getSymbol(id);
}

_.expect = function(ast, type){
if(!(this._inspect(ast) === type)){
this.error('interpreter error! expect node: "'+ type +'" got: "' + ast.type + '"', ast)
Expand Down
3 changes: 3 additions & 0 deletions lib/symtab.js
Expand Up @@ -36,6 +36,9 @@ Scope.prototype = {
this.symtable[name] = value;
return this;
},
getSymbol: function(name) {
return this.symtable[name];
},
getOuterScope: function(){
return this.parentScope;
},
Expand Down

0 comments on commit 66a13c8

Please sign in to comment.