design: added record interface
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -2,8 +2,15 @@ function same(a, b) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
function notSame(a, b) {
|
||||
if ((a !== a) && (b !== b)) return true;
|
||||
return a !== b;
|
||||
}
|
||||
|
||||
function main() {
|
||||
var obj = {};
|
||||
assert(same({}, {}) == false);
|
||||
assert(same(obj, obj) == true);
|
||||
assert(notSame({}, {}) == true);
|
||||
assert(notSame(obj, obj) == false);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ function namedObjectType({a,b}:{a:A,b:B<C>}) {
|
||||
}
|
||||
|
||||
class Bar {
|
||||
@CONST constructor({
|
||||
constructor({
|
||||
selector,
|
||||
lightDomServices,
|
||||
implementsTypes
|
||||
@ -47,6 +47,7 @@ function main() {
|
||||
// TODO(vojta): test this better.
|
||||
var f = new Foo(1, 2);
|
||||
assert(f.sum() == 3);
|
||||
assert(f instanceof Foo);
|
||||
|
||||
f.typedVariables();
|
||||
}
|
@ -5,7 +5,7 @@ import {createVariableStatement, createCallExpression, createIdentifierExpressio
|
||||
// var CONSTRUCTOR = token.CONSTRUCTOR;
|
||||
|
||||
import {PROPERTY_METHOD_ASSIGNMENT, MEMBER_EXPRESSION, THIS_EXPRESSION, BINARY_EXPRESSION} from 'traceur/src/syntax/trees/ParseTreeType';
|
||||
import {EQUAL_EQUAL_EQUAL} from 'traceur/src/syntax/TokenType';
|
||||
import {EQUAL_EQUAL_EQUAL, NOT_EQUAL_EQUAL} from 'traceur/src/syntax/TokenType';
|
||||
import {CONSTRUCTOR} from 'traceur/src/syntax/PredefinedName';
|
||||
|
||||
import {VariableStatement, VariableDeclarationList} from 'traceur/src/syntax/trees/ParseTrees';
|
||||
@ -61,12 +61,23 @@ export class ClassTransformer extends ParseTreeTransformer {
|
||||
// Transform triple equals into identical() call.
|
||||
// TODO(vojta): move to a separate transformer
|
||||
transformBinaryExpression(tree) {
|
||||
if (tree.operator.type === EQUAL_EQUAL_EQUAL) {
|
||||
tree.left = this.transformAny(tree.left);
|
||||
tree.right = this.transformAny(tree.right);
|
||||
if (tree.operator.type === 'instanceof') {
|
||||
// a instanceof b -> a is b
|
||||
// TODO(vojta): do this in a cleaner way.
|
||||
tree.operator.type = 'is';
|
||||
return tree;
|
||||
} else if (tree.operator.type === EQUAL_EQUAL_EQUAL) {
|
||||
// a === b -> identical(a, b)
|
||||
return createCallExpression(createIdentifierExpression('identical'), createArgumentList([tree.left, tree.right]));
|
||||
} else if (tree.operator.type === NOT_EQUAL_EQUAL) {
|
||||
// a !== b -> !identical(a, b)
|
||||
// TODO(vojta): do this in a cleaner way.
|
||||
return createCallExpression(createIdentifierExpression('!identical'), createArgumentList([tree.left, tree.right]));
|
||||
} else {
|
||||
return tree;
|
||||
}
|
||||
|
||||
return tree;
|
||||
};
|
||||
|
||||
transformClassDeclaration(tree) {
|
||||
|
Reference in New Issue
Block a user