Skip to content

Commit

Permalink
review comments + a few fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
shans committed Mar 15, 2017
1 parent cf5dcfd commit 63c20c1
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
8 changes: 4 additions & 4 deletions runtime/arc.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ class ViewParticleSlot extends ParticleSlotBase {

}

function particleSlot(name, type, spec) {
function particleSlot(name, type, scope) {
if (type.isView)
return new ViewParticleSlot(name, type.primitiveType);
return new ViewParticleSlot(name, type.primitiveType(scope));
return new SingletonParticleSlot(name, type);
}

Expand All @@ -154,9 +154,9 @@ class ArcParticle {
this.arc = arc;
particle.arcParticle = this;
this.inputs = new Map();
particle.inputs().map(a => this.inputs.set(a.name, particleSlot(a.name, a.type, a.typeName)));
particle.inputs().map(a => this.inputs.set(a.name, particleSlot(a.name, a.type, arc.scope)));
this.outputs = new Map();
particle.outputs().map(a => this.outputs.set(a.name, particleSlot(a.name, a.type, a.typeName)));
particle.outputs().map(a => this.outputs.set(a.name, particleSlot(a.name, a.type, arc.scope)));
}

checkpoint() {
Expand Down
4 changes: 2 additions & 2 deletions runtime/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion runtime/particle-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

var runtime = require("./runtime.js");
var recipe = require("./recipe.js");
var typeString = require("./type-string.js");

class ConnectionSpec {
constructor(rawData) {
Expand Down
4 changes: 2 additions & 2 deletions runtime/particle.peg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* http://polymer.github.io/PATENTS.txt
*/
{
var typeString = require("./type-string.js");
var typeLiteral = require("./type-literal.js");
}


Expand All @@ -23,7 +23,7 @@ Particle

Type = (PrimitiveType / ListType)

ListType = "[" pt:PrimitiveType "]" { return typeString.viewOf(pt); }
ListType = "[" pt:PrimitiveType "]" { return typeLiteral.viewOf(pt); }

PrimitiveType = [A-Z][a-zA-Z]* { return text() }

Expand Down
5 changes: 4 additions & 1 deletion runtime/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class Scope {
}

viewExists(type) {
if (type.isView)
type = type.primitiveType(this);
console.log("viewExists", type, this._views.keys());
return this._views.get(type) !== undefined;
}

Expand All @@ -39,7 +42,7 @@ class Scope {
_viewFor(type) {
assert(type instanceof Type);
if (type.isView)
type = type.primitiveType;
type = type.primitiveType(this);
var result = this._views.get(type);
if (!result) {
console.log("constructing new view for", type);
Expand Down
1 change: 1 addition & 0 deletions runtime/test/demo-flow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ describe('demo flow', function() {
suggestinator._getSuggestions = a => recipes;
var results = suggestinator.suggestinate(arc);
console.log(results);
console.log(results.map(a => a.components))
});
});
File renamed without changes.
17 changes: 9 additions & 8 deletions runtime/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'use strict';

const assert = require('assert');
const typeString = require('./type-string.js');
const typeLiteral = require('./type-literal.js');

class Type {
constructor(key, scope) {
Expand All @@ -22,16 +22,17 @@ class Type {
scope._types.set(normalized, this);
}
get isRelation() {
return typeString.isRelation(this.key);
return typeLiteral.isRelation(this.key);
}
get isView() {
return typeString.isView(this.key);
return typeLiteral.isView(this.key);
}
get isVariable() {
return typeString.isVariable(this.key);
return typeLiteral.isVariable(this.key);
}
get primitiveType() {
return typeString.primitiveType(this.key);
primitiveType(scope) {
assert(scope);
return new Type(typeLiteral.primitiveType(this.key), scope);
}
toLiteral() {
return this.key;
Expand All @@ -42,11 +43,11 @@ class Type {
}

viewOf(scope) {
return new Type(typeString.viewOf(this.key), scope);
return new Type(typeLiteral.viewOf(this.key), scope);
}

static typeVariable() {
return typeString.typeVariable();
return typeLiteral.typeVariable();
}
}

Expand Down

0 comments on commit 63c20c1

Please sign in to comment.