Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ometa: fix compatibility mode

  • Loading branch information...
commit d4dcdbb2ec11395056495ebc69af1f104526c607 1 parent 2682f90
@indutny indutny authored
Showing with 20 additions and 16 deletions.
  1. +20 −16 lib/xjst/ometa/xjst.ometajs
View
36 lib/xjst/ometa/xjst.ometajs
@@ -201,7 +201,7 @@ ometa XJSTTranslator <: XJSTIdentity {
es
},
- localAsmt = [#set [(#get :n | #getp trans:k :o)]:p :v]
+ localAsmt = [#set [(#get :n | #getp trans:k :o)]:p trans:v]
localProps(p):props -> {
var lv = XJSTTranslator._getLocalVar(this),
vars = [[#var].concat(props[1], [[lv[1], props[0]]])];
@@ -215,15 +215,15 @@ ometa XJSTTranslator <: XJSTIdentity {
localProps = [#getp const:k [#this]:r ] trans(r):tr -> [[#getp, k, tr], []]
| [#getp const:k [#get :o]]:expr -> [expr, []]
- | [#getp trans:k [#this]] -> {
+ | [#getp trans:k [#this]:r] trans(r):tr -> {
var v = XJSTTranslator._getLocalVar(this);
- [ [#getp, v, [#this]], [[v[1], k]] ]
- } | [#getp const:k :o] -> {
+ [ [#getp, v, tr], [[v[1], k]] ]
+ } | [#getp const:k trans:o] -> {
var v = XJSTTranslator._getLocalVar(this);
[ [#getp, k, v], [[v[1], o]] ]
- } | [#getp :k :o] -> {
+ } | [#getp trans:k trans:o] -> {
var v1 = XJSTTranslator._getLocalVar(this),
v2 = XJSTTranslator._getLocalVar(this);
@@ -277,28 +277,32 @@ XJSTTranslator._getLocalVar = function(p) {
};
XJSTTranslator._identify = function identify(identifier, node) {
- return identifier.identify(node);
+ return identifier.identify(this._replaceThis(node));
};
-XJSTTranslator._localToPred = function(identifier, as) {
- function replaceThis(as) {
- if (Array.isArray(as)) {
- if (as[0] === 'this') return ['get', '__$ctx'];
- return as.map(replaceThis);
- } else {
- return as;
- }
+XJSTTranslator._replaceThis = function replaceThis(as) {
+ if (Array.isArray(as)) {
+ if (as[0] === 'this') return ['get', '__$ctx'];
+ return as.map(replaceThis);
+ } else {
+ return as;
}
+};
+
+XJSTTranslator.prototype._replaceThis = function replaceThis(as) {
+ return this.scope ? XJSTTranslator._replaceThis(as) : as;
+};
+XJSTTranslator._localToPred = function(identifier, as) {
return as[2].map(function(as) {
- as[0] = replaceThis(as[0]);
+ as[0] = this._replaceThis(as[0]);
as = [XJSTTranslator._identify(identifier, as[0]), as[0], as[1]];
if (as[2][0] !== 'string' && as[2][0] !== 'number') {
return [as[0], as[1], 'reset'];
} else {
return as;
}
- });
+ }, this);
};
XJSTTranslator._splitTemplates = function(predicates, ts) {
Please sign in to comment.
Something went wrong with that request. Please try again.