DirectedGraph whose Nodes may be compound {@link Subgraph}s,
15 | * which may contain other nodes. Any node in the graph may be parented by one
16 | * subgraph. Since subgraphs are nodes, the source or target end of an
17 | * {@link Edge} may be a subgraph. For additional restrictions, refer to the
18 | * JavaDoc for the layout algorithm being used.
19 | *
20 | * A CompoundDirectedGraph is passed to a graph layout, which will position all
21 | * of the nodes, subgraphs, and edges in that graph. This class serves as the
22 | * data structure for a layout algorithm.
23 | *
24 | * @author Randy Hudson
25 | * @since 2.1.2
26 | */
27 | class CompoundDirectedGraph extends DirectedGraph {
28 | NodeList subgraphs = new NodeList();
29 | EdgeList containment = new EdgeList();
30 | }
31 |
--------------------------------------------------------------------------------
/irhydra/web/demos/webrebels2014/5-prototype/prototype.js:
--------------------------------------------------------------------------------
1 | //
2 | // Is it faster to load something from the prototype multiple times or cache it?
3 | //
4 | // What happens if we run the same benchmark several times on a newer V8?
5 | //
6 | // (the second run is 3x slower! huh?)
7 | //
8 |
9 | var obj =
10 | Object.create(
11 | Object.create(
12 | Object.create(
13 | Object.create(
14 | Object.create({prop: 10})))));
15 |
16 |
17 | function doManyLookups() {
18 | var counter = 0;
19 | for(var i = 0; i < 1000; i++) {
20 | for(var j = 0; j < 1000; j++) {
21 | for(var k = 0; k < 1000; k++) {
22 | counter += obj.prop;
23 | }
24 | }
25 | }
26 | print('In total: ' + counter);
27 | }
28 |
29 | function lookupAndCache() {
30 | var counter = 0;
31 | var value = obj.prop;
32 | for(var i = 0; i < 1000; i++)
33 | for(var j = 0; j < 1000; j++)
34 | for(var k = 0; k < 1000; k++)
35 | counter += value;
36 | print('In total: ' + counter);
37 | }
38 |
39 | function measure(f) {
40 | var start = Date.now();
41 | f();
42 | var end = Date.now();
43 | print(f.name + ' took ' + (end - start) + ' ms.');
44 | }
45 |
46 | measure(doManyLookups);
47 | measure(doManyLookups);
48 | measure(lookupAndCache);
49 | measure(lookupAndCache);
50 |
51 |
52 |
--------------------------------------------------------------------------------
/irhydra/web/demos/webrebels2014/1-concat/concat.js:
--------------------------------------------------------------------------------
1 | //
2 | // Is it faster two add two string constants or two variables containing the
3 | // very same constants?
4 | //
5 | // (benchmarking shows it's faster to add variables, but in fact there is a
6 | // bug in V8)
7 | //
8 |
9 | load("../jsperf.js");
10 |
11 | Benchmark.prototype.setup = function() {
12 | var test1 = 'owijfiojwefiojewijewoijewoijofiejioejffwiejijiefwiowefjoiwejiewjfiewfoiwejewifjwefijewfiojoewfjwefiowejfiewfjiewfjiewfjieowfjewfijewiiewfjweiojewfiojewfioejfiewfjiewfo';
13 | var test2 = 'owijfiojwefiojewijewoijewoijofiejioejffwiejijiefwiowefjoiwejiewjfiewfoiwejewifjwefijewfiojoewfjwefiowejfiewfjiewfjiewfjieowfjewfijewiiewfjweiojewfiojewfioejfiewfjiewfo';
14 | function outsideScope() {
15 | return test1 + test2;
16 | }
17 | function insideScope() {
18 | return 'owijfiojwefiojewijewoijewoijofiejioejffwiejijiefwiowefjoiwejiewjfiewfoiwejewifjwefijewfiojoewfjwefiowejfiewfjiewfjiewfjieowfjewfijewiiewfjweiojewfiojewfioejfiewfjiewfo' +
19 | 'owijfiojwefiojewijewoijewoijofiejioejffwiejijiefwiowefjoiwejiewjfiewfoiwejewifjwefijewfiojoewfjwefiowejfiewfjiewfjiewfjieowfjewfijewiiewfjweiojewfiojewfioejfiewfjiewfo';
20 | }
21 | };
22 |
23 | measure({
24 | 'Inside': function() {
25 | insideScope();
26 | },
27 | 'Outside': function() {
28 | outsideScope();
29 | }
30 | });
31 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/NodeList.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2003, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * A list containing nodes.
15 | * @author hudsonr
16 | * @since 2.1.2
17 | */
18 | class NodeList extends ListBase
18 | * Ranks are populated using a pre-order depth-first traversal of the spanning
19 | * tree. For each node, all edges requiring virtual nodes are added to the
20 | * ranks.
21 | * @author Randy Hudson
22 | * @since 2.1.2
23 | */
24 | class PopulateRanks extends GraphVisitor {
25 | final List
4 | Garbage collector forced deoptimization of this code because it contained a weak reference to a map (hidden class) that died during this GC cycle.
5 |
8 | Garbage collector forced deoptimization of this code because it contained a weak reference to a map (hidden class) that died during this GC cycle.
9 |
12 | This optimized code depended on a transition between maps (hidden classes) that was replaced by a new version.
13 |
16 | This optimized code was generated in the assumption that certain prototype never changes hidden class.
17 | It was deoptimized because that prototype transitioned to a new hidden class.
18 |
21 | This optimized code was generated in the assumption that certain object has no elements (indexed properties
26 | This optimized code was generated in the assumption that certain global variable stays contant. It was deoptimized because value of that variable changed.
27 |
30 | This optimized code was generated in the assumption that certain properties have specific type in all instances of the given hidden class.
31 | It was deoptimized because this assumption was violated.
32 |
35 | This optimized code was generated in the assumption that initial map associated with the given constructor stays the same.
36 | This assumption was violated.
37 |
40 | This optimized code embeds tenuring decisions that were invalidated by allocation site profiling.
41 |
44 | This optimized code embeds elements transition decisions that were invalidated by allocation site profiling.
45 |
19 | * The requirements for this algorithm are the same as those of
20 | *
21 | * A Subgraph may contain another Subgraph.
22 | *
23 | * A Subgraph has additional geometric properties which describe the containing
24 | * box. They are:
25 | * Edges.
15 | * @author hudsonr
16 | * @since 2.1.2
17 | */
18 | class EdgeList extends ListBasetrue if the Object is a Dimension and its width and height
27 | * are equal to this Dimension's width and height, false
28 | * otherwise.
29 | * @param othe Object being tested for equality
30 | * @return true if the given object is equal to this dimension
31 | * @since 2.0
32 | */
33 |
34 | bool operator == (Object o) {
35 | if (o is Dimension) {
36 | return (o.width == width && o.height == height);
37 | }
38 |
39 | return false;
40 | }
41 |
42 | /**
43 | * @see java.lang.Object#hashCode()
44 | */
45 | int get hashCode {
46 | return (width * height) ^ (width + height);
47 | }
48 |
49 | /**
50 | * @see Object#toString()
51 | */
52 | String toString() {
53 | return "Dimension(${width}, ${height})";
54 | }
55 |
56 | /**
57 | * Swaps the width and height of this Dimension, and returns this for
58 | * convenience. Can be useful in orientation changes.
59 | * @return this for convenience
60 | * @since 2.0
61 | */
62 | Dimension transpose() {
63 | int temp = width;
64 | width = height;
65 | height = temp;
66 | return this;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/irhydra/lib/src/spinner.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /** Simple wrapper around spin.js that creates spinner at navbar. */
16 | library spinner;
17 |
18 | import "dart:html" as html;
19 | import "dart:js" as js;
20 |
21 | /** Current instance of spinner. */
22 | js.JsObject _spinner;
23 |
24 | /** Start spinner. */
25 | start() {
26 | stop(); // Ensure that spinner is stopped.
27 |
28 | final target = html.document.querySelector(".navbar-inner > .container");
29 | final opts = new js.JsObject.jsify({
30 | "lines": 13, // The number of lines to draw
31 | "length": 7, // The length of each line
32 | "width": 4, // The line thickness
33 | "radius": 8, // The radius of the inner circle
34 | "corners": 1, // Corner roundness (0..1)
35 | "rotate": 0, // The rotation offset
36 | "color": '#000', // #rgb or #rrggbb
37 | "speed": 1, // Rounds per second
38 | "trail": 60, // Afterglow percentage
39 | "shadow": false, // Whether to render a shadow
40 | "hwaccel": false, // Whether to use hardware acceleration
41 | "className": 'spinner', // The CSS class to assign to the spinner
42 | "zIndex": 2e9, // The z-index (defaults to 2000000000)
43 | "top": 'auto', // Top position relative to parent in px
44 | "left": 'auto' // Left position relative to parent in px
45 | });
46 | _spinner = new js.JsObject(js.context['Spinner'], [opts]).callMethod('spin', [target]);
47 | }
48 |
49 | /** Stop spinner. */
50 | stop() {
51 | if (_spinner != null) {
52 | _spinner.callMethod('stop');
53 | _spinner = null;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/TransposeMetrics.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2005, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | class TransposeMetrics extends GraphVisitor {
14 | void visit(DirectedGraph g) {
15 | if (g.getDirection() == PositionConstants.SOUTH) return;
16 | int temp;
17 | g.setDefaultPadding(g.getDefaultPadding().getTransposed());
18 | for (int i = 0; i < g.nodes.length; i++) {
19 | Node node = g.nodes[i];
20 | temp = node.width;
21 | node.width = node.height;
22 | node.height = temp;
23 | if (node.padding != null) {
24 | node.padding = node.padding.getTransposed();
25 | }
26 | }
27 | }
28 | void revisit(DirectedGraph g) {
29 | if (g.getDirection() == PositionConstants.SOUTH) return;
30 | int temp;
31 | g.setDefaultPadding(g.getDefaultPadding().getTransposed());
32 | for (int i = 0; i < g.nodes.length; i++) {
33 | Node node = g.nodes[i];
34 | temp = node.width;
35 | node.width = node.height;
36 | node.height = temp;
37 | temp = node.y;
38 | node.y = node.x;
39 | node.x = temp;
40 | if (node.padding != null) {
41 | node.padding = node.padding.getTransposed();
42 | }
43 | }
44 | for (int i = 0; i < g.edges.length; i++) {
45 | Edge edge = g.edges[i];
46 | edge.start.transpose();
47 | edge.end.transpose();
48 | edge.points.transpose();
49 | List bends = edge.vNodes.list;
50 | if (bends == null) continue;
51 | for (int b = 0; b < bends.length; b++) {
52 | Node vnode = bends[b];
53 | temp = vnode.y;
54 | vnode.y = vnode.x;
55 | vnode.x = temp;
56 | temp = vnode.width;
57 | vnode.width = vnode.height;
58 | vnode.height = temp;
59 | }
60 | }
61 | g.size.transpose();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/irhydra/lib/src/modes/art/art.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2015 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /** Mode for parsing ART's art.cfg */
16 | library modes.art;
17 |
18 | import 'dart:html' as html;
19 |
20 | import 'package:irhydra/src/modes/ir.dart' as ir;
21 | import 'package:irhydra/src/modes/code.dart' show Code;
22 | import 'package:irhydra/src/modes/mode.dart';
23 | import 'package:irhydra/src/modes/art/cfg_parser.dart' as cfg_parser;
24 |
25 | class _ARTHIRDescriptor extends HIRDescriptor {
26 | const _ARTHIRDescriptor() : super();
27 |
28 | codeOf(instr, {skipComment: false}) => instr.code;
29 | }
30 |
31 | /**
32 | * Mode for viewing of ART's compilation artifacts.
33 | *
34 | * Data arrives in the form of a single C1Visualizer CFG file.
35 | *
36 | */
37 | class Mode extends BaseMode {
38 | final irs = const [const _ARTHIRDescriptor()];
39 |
40 | load(text) {
41 | if (cfg_parser.canRecognize(text)) {
42 | methods = cfg_parser.preparse(text);
43 | return true;
44 | } else {
45 | return false;
46 | }
47 | }
48 |
49 | toIr(method, phase, statusObject) {
50 | final blocks = cfg_parser.parse(method, phase.ir, statusObject);
51 | final code = hasCode(blocks) ? new Code.empty() : null;
52 | return new ir.ParsedIr(method, this, blocks, code, method.deopts);
53 | }
54 |
55 | static bool hasCode(blocks) {
56 | for (var block in blocks.values) {
57 | for (var instr in block.hir) {
58 | if (instr.code != null && !instr.code.isEmpty) {
59 | return true;
60 | }
61 | }
62 | }
63 | return false;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/irhydra/lib/src/ui/deopt-links.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | library deopt_links;
16 |
17 | import 'package:polymer/polymer.dart';
18 |
19 | /**
20 | * Primitive tabbed pane WebComponent.
21 | */
22 | @CustomTag('deopt-links')
23 | class DeoptLinksElement extends PolymerElement {
24 | @published var deopts;
25 | @observable var deoptInfo;
26 |
27 | DeoptLinksElement.created() : super.created();
28 |
29 | deoptsChanged() {
30 | deoptInfo = deopts.map((deopt) {
31 | var targetId = null;
32 | if (deopt.hir != null) {
33 | targetId = deopt.hir.id;
34 | } else if (deopt.lir != null) {
35 | targetId = deopt.lir.id;
36 | }
37 |
38 | return new _DeoptInfo(targetId, deopt.type);
39 | }).toList();
40 | }
41 |
42 | jumpToDeoptAction(event, detail, target) {
43 | final index = int.parse(target.attributes["data-target"]);
44 | fire("deopt-click", detail: deopts[index]);
45 | }
46 |
47 | enterDeoptAction(event, detail, target) {
48 | final index = int.parse(target.attributes["data-target"]);
49 | fire("deopt-enter", detail: new _DeoptHoverDetail(deopts[index], target));
50 | }
51 |
52 | leaveDeoptAction(event, detail, target) {
53 | final index = int.parse(target.attributes["data-target"]);
54 | fire("deopt-leave", detail: new _DeoptHoverDetail(deopts[index], target));
55 | }
56 | }
57 |
58 | class _DeoptHoverDetail {
59 | final deopt;
60 | final target;
61 | _DeoptHoverDetail(this.deopt, this.target);
62 | }
63 |
64 | class _DeoptInfo {
65 | @observable final id;
66 | @observable final type;
67 |
68 | _DeoptInfo(this.id, this.type);
69 | }
--------------------------------------------------------------------------------
/irhydra/lib/src/ui/dropdown-element.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2014 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | library dropdown_element;
16 |
17 | import 'dart:html' as html;
18 | import 'dart:js' as js;
19 | import 'package:ui_utils/task.dart';
20 | import 'package:polymer/polymer.dart';
21 |
22 | @CustomTag('dropdown-element')
23 | class DropdownElement extends PolymerElement {
24 | @published var selected;
25 | @observable var valueText;
26 |
27 | var _texts;
28 | var renderTask;
29 |
30 | selectedChanged(from, to) => renderTask.schedule();
31 |
32 | DropdownElement.created() : super.created() {
33 | renderTask = new Task(render, frozen: true, type: MICROTASK);
34 | }
35 |
36 | attached() {
37 | super.attached();
38 | js.context['jQuery']['fn']['dropdown'].callMethod('install', [shadowRoot]);
39 |
40 | _texts = new Map.fromIterable(
41 | (shadowRoot.querySelector("content") as html.ContentElement)
42 | .getDistributedNodes()
43 | .where((node) => (node is html.Element && node.attributes.containsKey("data-value"))),
44 | key: (node) => node.attributes["data-value"],
45 | value: (node) => node.text
46 | );
47 |
48 | renderTask.unfreeze();
49 | }
50 |
51 | selectAction(event, detail, target) {
52 | final attrs = event.target.attributes;
53 | if (attrs.containsKey('data-value')) {
54 | selected = attrs['data-value'];
55 | }
56 | event.preventDefault();
57 | }
58 |
59 | render() {
60 | valueText = _texts[selected];
61 | }
62 |
63 | detached() {
64 | js.context['jQuery']['fn']['dropdown'].callMethod('remove', [shadowRoot]);
65 | super.detached();
66 | }
67 | }
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/PopulateRanks.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2003, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * This class takes a DirectedGraph with an optimal rank assignment and a
15 | * spanning tree, and populates the ranks of the DirectedGraph. Virtual nodes
16 | * are inserted for edges that span 1 or more ranks.
17 | * "0", "1", ...).
22 | It was deoptimized because elements were added to that object.
23 | CompoundDirectedGraph. The input
15 | * format is the same as for {@link DirectedGraphLayout}. All nodes, including
16 | * subgraphs and their children, should be added to the
17 | * {@link DirectedGraph#nodes} field.
18 | * DirectedGraphLayout, with the following exceptions:
21 | *
22 | *
36 | *
37 | * @author Randy Hudson
38 | * @since 2.1.2
39 | */
40 | class CompoundDirectedGraphLayout extends DirectedGraphLayout {
41 |
42 | void init() {
43 | steps.add(new CompoundTransposeMetrics());
44 | steps.add(new CompoundBreakCycles());
45 | steps.add(new RouteEdges());
46 | steps.add(new ConvertCompoundGraph());
47 | steps.add(new InitialRankSolver());
48 | steps.add(new TightSpanningTreeSolver());
49 | steps.add(new RankAssignmentSolver());
50 | steps.add(new CompoundPopulateRanks());
51 | steps.add(new CompoundVerticalPlacement());
52 | steps.add(new MinCross(new CompoundRankSorter()));
53 | steps.add(new SortSubgraphs());
54 | steps.add(new CompoundHorizontalPlacement());
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/irhydra/lib/src/ui/source-pane.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | this for convenience
84 | * @param factorscale factor
85 | * @since 2.0
86 | */
87 | Point scale(double factor) {
88 | x = Math.floor(x * factor);
89 | y = Math.floor(y * factor);
90 | return this;
91 | }
92 |
93 | /**
94 | * Transposes this object. X and Y values are exchanged.
95 | * @return this for convenience
96 | * @since 2.0
97 | */
98 | Point transpose() {
99 | var t = x;
100 | x = y;
101 | y = t;
102 | return this;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/RouteEdges.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2003, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * @author Randy Hudson
15 | */
16 | class RouteEdges extends GraphVisitor {
17 | /**
18 | * @see GraphVisitor#visit(DirectedGraph)
19 | */
20 | void revisit(DirectedGraph g) {
21 | for (int i = 0; i < g.edges.length; i++) {
22 | Edge edge = g.edges[i];
23 | edge.start = new Point(edge.sourceOffset + edge.source.x, edge.source.y + edge.source.height);
24 | if (edge.source is SubgraphBoundary) {
25 | SubgraphBoundary boundary = edge.source;
26 | if (boundary.parent.head == boundary)
27 | edge.start.y = boundary.parent.y
28 | + boundary.parent.insets.top;
29 | }
30 | edge.end = new Point(edge.targetOffset + edge.target.x, edge.target.y);
31 | if (edge.vNodes != null) {
32 | routeLongEdge(edge, g);
33 | } else {
34 | PointList list = new PointList();
35 | list.addPoint(edge.start);
36 | list.addPoint(edge.end);
37 | edge.setPoints(list);
38 | }
39 | }
40 | }
41 |
42 | static void routeLongEdge(Edge edge, DirectedGraph g) {
43 | ShortestPathRouter router = new ShortestPathRouter();
44 | Path path = new Path(start: edge.start, end: edge.end);
45 | router.addPath(path);
46 | Rectangle o;
47 | Insets padding;
48 | final P1 = new Point(-100000, 2);
49 | final P2 = new Point(100000, 2);
50 | for (int i = 0; i < edge.vNodes.length; i++) {
51 | Node node = edge.vNodes[i];
52 | Node neighbor;
53 | if (node.left != null) {
54 | neighbor = node.left;
55 | o = new Rectangle(neighbor.x, neighbor.y, neighbor.width, neighbor.height);
56 | padding = g.getPadding(neighbor);
57 | o.width += padding.right + edge.padding - 1;
58 | o.x -= padding.left;
59 | o.unionPoint(o.getLocation().translate(P1));
60 | router.addObstacle(o);
61 | }
62 | if (node.right != null) {
63 | neighbor = node.right;
64 | o = new Rectangle(neighbor.x, neighbor.y, neighbor.width, neighbor.height);
65 | padding = g.getPadding(neighbor);
66 | o.width += padding.right;
67 | o.x -= padding.left + edge.padding - 1;
68 | o.unionPoint(o.getLocation().translate(P2));
69 | router.addObstacle(o);
70 | }
71 | }
72 | router.setSpacing(0);
73 | router.solve();
74 | edge.setPoints(path.getPoints());
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/saga/web/post.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2015 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | library saga.post;
16 |
17 | import 'dart:html';
18 |
19 | import 'package:liquid/liquid.dart';
20 | import 'package:liquid/vdom.dart' as v;
21 | import 'package:observe/observe.dart';
22 |
23 | import 'package:saga/src/parser.dart' as parser;
24 | import 'package:saga/src/flow/flow.dart' as flow;
25 | import 'package:saga/src/ui/ir_pane.dart' as ir_pane;
26 | import 'package:saga/src/ui/code_pane.dart' as code_pane;
27 | import 'package:saga/src/util.dart' show timeAndReport;
28 |
29 | class SagaApp extends Observable {
30 | @observable var flowData;
31 |
32 | render(code) {
33 | flowData = timeAndReport(() => flow.build(code), "flow analysis");
34 | }
35 |
36 | display(text) {
37 | final code = timeAndReport(() => parser.parse(text), "parsing");
38 | render(code);
39 |
40 | code.changes.listen((_) => render(code));
41 | }
42 | }
43 |
44 | class SagaAppComponent extends Component {
45 | var app;
46 |
47 | final showOnly;
48 | final showIr;
49 |
50 | SagaAppComponent(showOnly, {this.showIr: false}) : showOnly = new Set.from(showOnly);
51 |
52 | init() {
53 | app.changes.listen((_) => invalidate());
54 | }
55 |
56 | build() =>
57 | v.root(classes: const ["saga-root"])(app.flowData == null ? const [] : [
58 | showIr ? ir_pane.vIrPane(flowData: app.flowData, showOnly: showOnly)
59 | : code_pane.vCodePane(flowData: app.flowData, showOnly: showOnly, showIr: false)
60 | ]);
61 | }
62 |
63 | injectStylesheets(hrefs) {
64 | document.head.children.addAll(hrefs.map((href) => new LinkElement()
65 | ..rel = 'stylesheet'
66 | ..href = href));
67 | }
68 |
69 | main() {
70 | injectStylesheets(['/saga/packages/ui_utils/assets/tooltip.css',
71 | '/saga/packages/ui_utils/assets/xref.css',
72 | '/saga/styles.css']);
73 |
74 | final app = new SagaApp();
75 |
76 | for (var codeEl in document.querySelectorAll(".code0")) {
77 | injectComponent(new SagaAppComponent([2])..app = app, codeEl);
78 | }
79 |
80 | for (var codeEl in document.querySelectorAll(".code4")) {
81 | injectComponent(new SagaAppComponent([4])..app = app, codeEl);
82 | }
83 |
84 | for (var codeEl in document.querySelectorAll(".ir0")) {
85 | injectComponent(new SagaAppComponent([2], showIr: true)..app = app, codeEl);
86 | }
87 |
88 | HttpRequest.getString("/saga/code.asm").then(app.display);
89 | }
--------------------------------------------------------------------------------
/saga/lib/src/ui/graph_pane.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2015 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | library saga.ui.graph_pane;
16 |
17 | import 'dart:html';
18 | import 'dart:js' as js;
19 |
20 | import 'package:liquid/liquid.dart';
21 | import 'package:liquid/vdom.dart' as v;
22 | import 'package:ui_utils/delayed_reaction.dart';
23 | import 'package:ui_utils/graph_layout.dart' as graph_layout;
24 |
25 | import 'package:saga/src/ui/code_pane.dart' as code_pane;
26 | import 'package:saga/src/ui/ir_pane.dart' as ir_pane;
27 | import 'package:saga/src/ui/tooltip.dart';
28 |
29 | class BlockTooltip extends Tooltip {
30 | final flowData;
31 |
32 | final _delayed = new DelayedReaction(delay: const Duration(milliseconds: 100));
33 |
34 | BlockTooltip(this.flowData);
35 |
36 |
37 | var block;
38 | show(el, id) {
39 | _delayed.schedule(() {
40 | block = flowData.blocks[id];
41 | target = el;
42 | isVisible = true;
43 | });
44 | }
45 |
46 | hide() {
47 | _delayed.cancel();
48 | isVisible = false;
49 | }
50 |
51 | get content =>
52 | v.pre()(block != null ? [
53 | code_pane.vBlock(block: block, flowData: flowData),
54 | v.text('\n'),
55 | ir_pane.vBlock(block: block)
56 | ] : const []);
57 | }
58 |
59 |
60 | final vGraphPane = v.componentFactory(GraphPaneComponent);
61 | class GraphPaneComponent extends Component {
62 | @property() var flowData;
63 |
64 | var graphPane;
65 | var tooltip;
66 |
67 | build() =>
68 | v.root()([
69 | graphPane = v.div(classes: const ['graph-pane']),
70 | (tooltip = new BlockTooltip(flowData)).build()
71 | ]);
72 |
73 | update() async {
74 | await writeDOM();
75 | displayGraph(graphPane.ref, flowData.blocks, tooltip);
76 | }
77 |
78 | static displayGraph(pane, blocks, ref) {
79 | final stopwatch = new Stopwatch()..start();
80 | graph_layout.display(pane, blocks, (label, blockId) {
81 | label.onMouseOver.listen((e) => ref.show(e.target, blockId));
82 | label.onMouseOut.listen((_) => ref.hide());
83 | label.onClick.listen((e) {
84 | for (var el in document.querySelectorAll('[data-block=${blockId}]')) {
85 | el.scrollIntoView();
86 | js.context.callMethod('jQuery', [el]).callMethod('effect', ['highlight', new js.JsObject.jsify({ 'color': 'rgba(203, 75, 22, 0.5)' }), 500]);
87 | }
88 | e.stopPropagation();
89 | e.preventDefault();
90 | });
91 | });
92 | print("graph_layout took ${stopwatch.elapsedMilliseconds}");
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/PointList.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2000, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | * Alexander Shatalin (Borland) - Contribution for Bug 238874
10 | */
11 |
12 |
13 | part of draw2d.graph;
14 |
15 | /**
16 | * Represents a List of Points.
17 | */
18 | class PointList {
19 | final Listtrue if adding an edge between the 2 given nodes
78 | * will introduce a cycle in the containing graph.
79 | * @param sourcethe potential source node
80 | * @param targetthe potential target node
81 | * @return whether an edge between the 2 given nodes will introduce a cycle
82 | */
83 | static bool willCauseCycle(Node source, Node target) {
84 | NodeList nodes = search(target, new NodeList());
85 | nodes.resetFlags();
86 | return nodes.contains(source);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/saga/lib/src/flow/locals.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2015 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /// Forward loads/stores through RSP relative slots.
16 | /// Assumes stack operations are well-behaved and all stack operations are
17 | /// implicit in the IR.
18 | library saga.flow.locals;
19 |
20 | import 'package:saga/src/flow/node.dart';
21 | import 'package:saga/src/flow/cpu_register.dart';
22 | import 'package:saga/src/flow/ssa.dart';
23 | import 'package:saga/src/util.dart';
24 |
25 | findLocals(state, blocks) {
26 | final entrySp = state.entryState[CpuRegister.RSP];
27 |
28 | final offsets = new Map
26 | *
33 | *
34 | * @author hudsonr
35 | * @since 2.1.2
36 | */
37 | class Subgraph extends Node {
38 |
39 | /**
40 | * The children of this subgraph. Nodes may not belong to more than one
41 | * subgraph.
42 | */
43 | NodeList members = new NodeList();
44 |
45 | Node head;
46 | Node tail;
47 | Node left;
48 | Node right;
49 | int nestingTreeMin;
50 |
51 | /**
52 | * The space required for this subgraph's border. The default value is
53 | * undefined.
54 | */
55 | Insets insets = new Insets.round(1);
56 |
57 | /**
58 | * The minimum space between this subgraph's border and it's children.
59 | */
60 | Insets innerPadding = NO_INSETS;
61 |
62 | static final Insets NO_INSETS = new Insets.round(0);
63 |
64 | /**
65 | * Constructs a new subgraph with the given data object and parent subgraph.
66 | *
67 | * @see Node#Node(Object, Subgraph)
68 | * @param data
69 | * an arbitrary data object
70 | * @param parent
71 | * the parent
72 | */
73 | Subgraph(Object data, [Subgraph parent]) : super(data: data, parent: parent);
74 |
75 | /**
76 | * Adds the given node to this subgraph.
77 | *
78 | * @param n
79 | * the node to add
80 | */
81 | void addMember(Node n) {
82 | members.add(n);
83 | }
84 |
85 | /**
86 | * Returns true if the given node is contained inside the
87 | * branch represented by this subgraph.
88 | *
89 | * @param n
90 | * the node in question
91 | * @return true if nested
92 | */
93 | bool isNested(Node n) {
94 | return n.nestingIndex >= nestingTreeMin
95 | && n.nestingIndex <= nestingIndex;
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/Geometry.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2005, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | * Alexander Shatalin (Borland) - Contribution for Bug 238874
10 | */
11 |
12 |
13 | part of draw2d.graph;
14 |
15 | /**
16 | * A Utilities class for geometry operations.
17 | * @author Pratik Shah
18 | * @author Alexander Nyssen
19 | * @since 3.1
20 | */
21 | class Geometry {
22 | /**
23 | * Determines whether the two line segments p1->p2 and p3->p4, given by
24 | * p1=(x1, y1), p2=(x2,y2), p3=(x3,y3), p4=(x4,y4) intersect. Two line
25 | * segments are regarded to be intersecting in case they share at least one
26 | * common point, i.e if one of the two line segments starts or ends on the
27 | * other line segment or the line segments are collinear and overlapping,
28 | * then they are as well considered to be intersecting.
29 | * @param x1x coordinate of starting point of line segment 1
30 | * @param y1y coordinate of starting point of line segment 1
31 | * @param x2x coordinate of ending point of line segment 1
32 | * @param y2y coordinate of ending point of line segment 1
33 | * @param x3x coordinate of the starting point of line segment 2
34 | * @param y3y coordinate of the starting point of line segment 2
35 | * @param x4x coordinate of the ending point of line segment 2
36 | * @param y4y coordinate of the ending point of line segment 2
37 | * @return true if the two line segments formed by the given
38 | * coordinates share at least one common point.
39 | * @since 3.1
40 | */
41 | static bool linesIntersect(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
42 | int bb1_x = Math.min(x1, x2);
43 | int bb1_y = Math.min(y1, y2);
44 | int bb2_x = Math.max(x1, x2);
45 | int bb2_y = Math.max(y1, y2);
46 | int bb3_x = Math.min(x3, x4);
47 | int bb3_y = Math.min(y3, y4);
48 | int bb4_x = Math.max(x3, x4);
49 | int bb4_y = Math.max(y3, y4);
50 | if (!(bb2_x >= bb3_x && bb4_x >= bb1_x && bb2_y >= bb3_y && bb4_y >= bb1_y)) {
51 | return false;
52 | }
53 | int p1p3_x = x1 - x3;
54 | int p1p3_y = y1 - y3;
55 | int p2p3_x = x2 - x3;
56 | int p2p3_y = y2 - y3;
57 | int p3p4_x = x3 - x4;
58 | int p3p4_y = y3 - y4;
59 | if (productSign(crossProduct(p2p3_x, p2p3_y, p3p4_x, p3p4_y), crossProduct(p3p4_x, p3p4_y, p1p3_x, p1p3_y)) >= 0) {
60 | int p2p1_x = x2 - x1;
61 | int p2p1_y = y2 - y1;
62 | int p1p4_x = x1 - x4;
63 | int p1p4_y = y1 - y4;
64 | return productSign(crossProduct(-p1p3_x, -p1p3_y, p2p1_x, p2p1_y), crossProduct(p2p1_x, p2p1_y, p1p4_x, p1p4_y)) <= 0;
65 | }
66 | return false;
67 | }
68 | static int productSign(int x, int y) {
69 | if (x == 0 || y == 0) {
70 | return 0;
71 | } else if ((x < 0) != (y < 0)) {
72 | return -1;
73 | }
74 | return 1;
75 | }
76 | static int crossProduct(int x1, int y1, int x2, int y2) {
77 | return x1 * y2 - x2 * y1;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/LocalOptimizer.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2003, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * This graph visitor examines all adjacent pairs of nodes and determines if
15 | * swapping the two nodes provides improved graph aesthetics.
16 | * @author Daniel Lee
17 | * @since 2.1.2
18 | */
19 | class LocalOptimizer extends GraphVisitor {
20 | bool shouldSwap(Node current, Node next) {
21 | int crossCount = 0;
22 | int invertedCrossCount = 0;
23 | EdgeList currentEdges = current.incoming;
24 | EdgeList nextEdges = next.incoming;
25 | int rank = current.rank - 1;
26 | int iCurrent, iNext;
27 | for (int i = 0; i < currentEdges.length; i++) {
28 | Edge currentEdge = currentEdges[i];
29 | iCurrent = currentEdge.getIndexForRank(rank);
30 | for (int j = 0; j < nextEdges.length; j++) {
31 | iNext = nextEdges[j].getIndexForRank(rank);
32 | if (iNext < iCurrent) crossCount++; else if (iNext > iCurrent) invertedCrossCount++; else {
33 | int offsetDiff = nextEdges[j].sourceOffset - currentEdge.sourceOffset;
34 | if (offsetDiff < 0) crossCount++; else if (offsetDiff > 0) invertedCrossCount++;
35 | }
36 | }
37 | }
38 | currentEdges = current.outgoing;
39 | nextEdges = next.outgoing;
40 | rank = current.rank + 1;
41 | for (int i = 0; i < currentEdges.length; i++) {
42 | Edge currentEdge = currentEdges[i];
43 | iCurrent = currentEdge.getIndexForRank(rank);
44 | for (int j = 0; j < nextEdges.length; j++) {
45 | iNext = nextEdges[j].getIndexForRank(rank);
46 | if (iNext < iCurrent) crossCount++; else if (iNext > iCurrent) invertedCrossCount++; else {
47 | int offsetDiff = nextEdges[j].targetOffset - currentEdge.targetOffset;
48 | if (offsetDiff < 0) crossCount++; else if (offsetDiff > 0) invertedCrossCount++;
49 | }
50 | }
51 | }
52 | if (invertedCrossCount < crossCount) return true;
53 | return false;
54 | }
55 | void swapNodes(Node current, Node next, Rank rank) {
56 | int index = rank.indexOf(current);
57 | rank[index + 1] = current;
58 | rank[index] = next;
59 | index = current.index;
60 | current.index = next.index;
61 | next.index = index;
62 | }
63 | /**
64 | * @see GraphVisitor#visit(org.eclipse.draw2d.graph.DirectedGraph)
65 | */
66 | void visit(DirectedGraph g) {
67 | bool flag;
68 | do {
69 | flag = false;
70 | for (int r = 0; r < g.ranks.length; r++) {
71 | Rank rank = g.ranks[r];
72 | for (int n = 0; n < rank.count() - 1; n++) {
73 | Node currentNode = rank[n];
74 | Node nextNode = rank[n + 1];
75 | if (shouldSwap(currentNode, nextNode)) {
76 | swapNodes(currentNode, nextNode, rank);
77 | flag = true;
78 | n = Math.max(0, n - 2);
79 | }
80 | }
81 | }
82 | } while (flag);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/ui_utils/lib/assets/tooltip.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap v3.0.2 by @fat and @mdo
3 | * Copyright 2014 Twitter, Inc.
4 | * Licensed under http://www.apache.org/licenses/LICENSE-2.0
5 | *
6 | * Designed and built with all the love in the world by @mdo and @fat.
7 | */
8 |
9 | .popover {
10 | position: absolute;
11 | top: 0;
12 | left: 0;
13 | z-index: 1010;
14 | display: none;
15 | max-width: 276px;
16 | padding: 1px;
17 | text-align: left;
18 | white-space: normal;
19 | background-color: #ffffff;
20 | border: 1px solid #cccccc;
21 | border: 1px solid rgba(0, 0, 0, 0.2);
22 | border-radius: 6px;
23 | -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
24 | box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
25 | background-clip: padding-box;
26 | }
27 |
28 | .popover.top {
29 | margin-top: -10px;
30 | }
31 |
32 | .popover.right {
33 | margin-left: 10px;
34 | }
35 |
36 | .popover.bottom {
37 | margin-top: 10px;
38 | }
39 |
40 | .popover.left {
41 | margin-left: -10px;
42 | }
43 |
44 | .popover-title {
45 | padding: 8px 14px;
46 | margin: 0;
47 | font-size: 14px;
48 | font-weight: normal;
49 | line-height: 18px;
50 | background-color: #f7f7f7;
51 | border-bottom: 1px solid #ebebeb;
52 | border-radius: 5px 5px 0 0;
53 | }
54 |
55 | .popover-content {
56 | padding: 9px 14px;
57 | }
58 |
59 | .popover .arrow,
60 | .popover .arrow:after {
61 | position: absolute;
62 | display: block;
63 | width: 0;
64 | height: 0;
65 | border-color: transparent;
66 | border-style: solid;
67 | }
68 |
69 | .popover .arrow {
70 | border-width: 11px;
71 | }
72 |
73 | .popover .arrow:after {
74 | border-width: 10px;
75 | content: "";
76 | }
77 |
78 | .popover.top .arrow {
79 | bottom: -11px;
80 | left: 50%;
81 | margin-left: -11px;
82 | border-top-color: #999999;
83 | border-top-color: rgba(0, 0, 0, 0.25);
84 | border-bottom-width: 0;
85 | }
86 |
87 | .popover.top .arrow:after {
88 | bottom: 1px;
89 | margin-left: -10px;
90 | border-top-color: #ffffff;
91 | border-bottom-width: 0;
92 | content: " ";
93 | }
94 |
95 | .popover.right .arrow {
96 | top: 50%;
97 | left: -11px;
98 | margin-top: -11px;
99 | border-right-color: #999999;
100 | border-right-color: rgba(0, 0, 0, 0.25);
101 | border-left-width: 0;
102 | }
103 |
104 | .popover.right .arrow:after {
105 | bottom: -10px;
106 | left: 1px;
107 | border-right-color: #ffffff;
108 | border-left-width: 0;
109 | content: " ";
110 | }
111 |
112 | .popover.bottom .arrow {
113 | top: -11px;
114 | left: 50%;
115 | margin-left: -11px;
116 | border-bottom-color: #999999;
117 | border-bottom-color: rgba(0, 0, 0, 0.25);
118 | border-top-width: 0;
119 | }
120 |
121 | .popover.bottom .arrow:after {
122 | top: 1px;
123 | margin-left: -10px;
124 | border-bottom-color: #ffffff;
125 | border-top-width: 0;
126 | content: " ";
127 | }
128 |
129 | .popover.left .arrow {
130 | top: 50%;
131 | right: -11px;
132 | margin-top: -11px;
133 | border-left-color: #999999;
134 | border-left-color: rgba(0, 0, 0, 0.25);
135 | border-right-width: 0;
136 | }
137 |
138 | .popover.left .arrow:after {
139 | right: 1px;
140 | bottom: -10px;
141 | border-left-color: #ffffff;
142 | border-right-width: 0;
143 | content: " ";
144 | }
--------------------------------------------------------------------------------
/saga/web/styles.css:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Google Inc. All Rights Reserved.
2 | **
3 | ** Licensed under the Apache License, Version 2.0 (the "License");
4 | ** you may not use this file except in compliance with the License.
5 | ** You may obtain a copy of the License at
6 | **
7 | ** http://www.apache.org/licenses/LICENSE-2.0
8 | **
9 | ** Unless required by applicable law or agreed to in writing, software
10 | ** distributed under the License is distributed on an "AS IS" BASIS,
11 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | ** See the License for the specific language governing permissions and
13 | ** limitations under the License.
14 | */
15 |
16 | .saga-root pre {
17 | font-family: 'Inconsolata', monospace;
18 | font-size: 14pt;
19 | background: #fdf6e3;
20 | color: #657b83 !important;
21 | line-height: 1.428571429;
22 | cursor: default;
23 | }
24 |
25 | .saga-flex {
26 | display: -ms-flex;
27 | display: -webkit-flex;
28 | display: flex;
29 | background: #fdf6e3;
30 | }
31 |
32 | .saga-app {
33 | display: -ms-flex;
34 | display: -webkit-flex;
35 | display: flex;
36 | width: 100%;
37 | max-height: 100%;
38 | position: fixed;
39 | display: flex;
40 | top: 0px;
41 | left: 0px;
42 | right: 0px;
43 | bottom: 0px;
44 | }
45 |
46 | .saga-flex > * {
47 | width: 100%;
48 | padding: 10px;
49 | margin: 0px;
50 | }
51 |
52 | .saga-app > * {
53 | width: 100%;
54 | padding: 10px;
55 | overflow-y: scroll;
56 | margin: 0px;
57 | position: relative;
58 | }
59 |
60 | .asm-immediate,
61 | .ir-node-konstant {
62 | color: #2aa198;
63 | }
64 |
65 | .asm-call-target {
66 | color: #d33682;
67 | cursor: pointer;
68 | }
69 |
70 | .asm-opcode {
71 | color: #859900;
72 | }
73 |
74 | .asm-register {
75 | color: #657b83;
76 | cursor: pointer;
77 | }
78 |
79 | .asm-label,
80 | .ir-block-name {
81 | color: #268bd2;
82 | }
83 |
84 | .asm-call-target .popover {
85 | background: #002b36;
86 | }
87 |
88 | .asm-call-target .popover.top .arrow:after {
89 | border-top-color: #002b36;
90 | }
91 |
92 | .asm-call-target button[data-attr] {
93 | background: none !important;
94 | border: none;
95 | padding: 0 !important;
96 | font-family: 'Inconsolata', monospace;
97 | cursor: pointer;
98 | color: #839496;
99 | font-size: 13pt;
100 | }
101 |
102 | .asm-call-target button[data-attr]:not(.set) {
103 | text-decoration: line-through;
104 | }
105 |
106 | .inline-marker, .outline-marker {
107 | display: none;
108 | cursor: pointer;
109 | }
110 |
111 | .inline-marker:hover, .ir-use:hover > .inline-marker {
112 | display: inline-block;
113 | }
114 |
115 | .node-body-hover {
116 | text-decoration: underline;
117 | }
118 |
119 | .node-body-hover > .outline-marker {
120 | display: inline-block;
121 | }
122 |
123 | .single-use {
124 | color: #859900;
125 | }
126 |
127 | .ir-node-keyword {
128 | color: #859900;
129 | }
130 |
131 | .ir-node-op {
132 | color: #268bd2;
133 | }
134 |
135 | .ir-block-body {
136 | padding-left: 10px;
137 | }
138 |
139 | .ir-node-name {
140 | cursor: pointer;
141 | }
142 |
143 | .graph-pane {
144 | margin-left: auto;
145 | margin-right: auto;
146 | }
147 |
148 | .invalid-name {
149 | color: #dc322f;
150 | font-weight: bold;
151 | }
152 |
153 | .tooltip-def {
154 | font-size: 0.95em;
155 | font-style: italic;
156 | }
--------------------------------------------------------------------------------
/ui_utils/lib/src/draw2d/Obstacle.dart:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2004, 2010 IBM Corporation and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | * Contributors:
8 | * IBM Corporation - initial API and implementation
9 | */
10 |
11 | part of draw2d.graph;
12 |
13 | /**
14 | * An obstacle representation for the ShortestPathRouting. This is a subclass of
15 | * Rectangle.
16 | * This class is for internal use only.
17 | * @author Whitney Sorenson
18 | * @since 3.0
19 | */
20 | class Obstacle extends Rectangle {
21 | bool exclude = false;
22 | Vertex topLeft, topRight, bottomLeft, bottomRight, center;
23 | ShortestPathRouter router;
24 |
25 | Obstacle(Rectangle rect, ShortestPathRouter router) : super(0, 0, 0, 0) {
26 | init(rect);
27 | this.router = router;
28 | }
29 | /**
30 | * Returns true if the given point is contained but not on the
31 | * boundary of this obstacle.
32 | * @param pa point
33 | * @return true if properly contained
34 | */
35 | bool containsProper(Point p) {
36 | return p.x > this.x && p.x < this.x + this.width - 1 && p.y > this.y && p.y < this.y + this.height - 1;
37 | }
38 | int getSpacing() {
39 | return router.getSpacing();
40 | }
41 | void growVertex(Vertex vertex) {
42 | if (vertex.totalCount > 0) vertex.grow();
43 | }
44 | /**
45 | * Grows all vertices on this obstacle.
46 | */
47 | void growVertices() {
48 | growVertex(topLeft);
49 | growVertex(topRight);
50 | growVertex(bottomLeft);
51 | growVertex(bottomRight);
52 | }
53 | /**
54 | * Initializes this obstacle to the values of the given rectangle
55 | * @param rectbounds of this obstacle
56 | */
57 | void init(Rectangle rect) {
58 | this.x = rect.x;
59 | this.y = rect.y;
60 | this.width = rect.width;
61 | this.height = rect.height;
62 | exclude = false;
63 | topLeft = new Vertex(x, y, this);
64 | topLeft.positionOnObstacle = PositionConstants.NORTH_WEST;
65 | topRight = new Vertex(x + width - 1, y, this);
66 | topRight.positionOnObstacle = PositionConstants.NORTH_EAST;
67 | bottomLeft = new Vertex(x, y + height - 1, this);
68 | bottomLeft.positionOnObstacle = PositionConstants.SOUTH_WEST;
69 | bottomRight = new Vertex(x + width - 1, y + height - 1, this);
70 | bottomRight.positionOnObstacle = PositionConstants.SOUTH_EAST;
71 | center = new Vertex.fromPoint(getCenter(), this);
72 | }
73 | /**
74 | * Requests a full reset on all four vertices of this obstacle.
75 | */
76 | void reset() {
77 | topLeft.fullReset();
78 | bottomLeft.fullReset();
79 | bottomRight.fullReset();
80 | topRight.fullReset();
81 | }
82 | void shrinkVertex(Vertex vertex) {
83 | if (vertex.totalCount > 0) vertex.shrink();
84 | }
85 | /**
86 | * Shrinks all four vertices of this obstacle.
87 | */
88 | void shrinkVertices() {
89 | shrinkVertex(topLeft);
90 | shrinkVertex(topRight);
91 | shrinkVertex(bottomLeft);
92 | shrinkVertex(bottomRight);
93 | }
94 | /**
95 | * @see org.eclipse.draw2d.geometry.Rectangle#toString()
96 | */
97 | String toString() {
98 | return "Obstacle($x"; // TODO(vegorov)
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/saga/lib/src/flow/compact_likely.dart:
--------------------------------------------------------------------------------
1 | // Copyright 2015 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | /// Merge blocks together assuming that branches leading to NORETURN calls
16 | /// are "unlikely" and are almost never taken.
17 | library saga.flow.compact_likely;
18 |
19 | import 'package:saga/src/flow/node.dart' as node;
20 | import 'package:saga/src/parser.dart' as parser;
21 |
22 | compact(blocks) {
23 | final throws = new Set
18 | *
19 | *
36 | */
37 | class PositionConstants {
38 | /**
39 | * None
40 | */
41 | static const int NONE = 0;
42 | /**
43 | * Left
44 | */
45 | static const int LEFT = 1;
46 | /**
47 | * Center (Horizontal)
48 | */
49 | static const int CENTER = 2;
50 | /**
51 | * Right
52 | */
53 | static const int RIGHT = 4;
54 | /**
55 | * Bit-wise OR of LEFT, CENTER, and RIGHT
56 | */
57 | static const int LEFT_CENTER_RIGHT = LEFT | CENTER;
58 | /**
59 | * Used to signify left alignment regardless of orientation (i.e., LTR or
60 | * RTL)
61 | */
62 | static const int ALWAYS_LEFT = 64;
63 | /**
64 | * Used to signify right alignment regardless of orientation (i.e., LTR or
65 | * RTL)
66 | */
67 | static const int ALWAYS_RIGHT = 128;
68 | /**
69 | * Top
70 | */
71 | static const int TOP = 8;
72 | /**
73 | * Middle (Vertical)
74 | */
75 | static const int MIDDLE = 16;
76 | /**
77 | * Bottom
78 | */
79 | static const int BOTTOM = 32;
80 | /**
81 | * Bit-wise OR of TOP, MIDDLE, and BOTTOM
82 | */
83 | static const int TOP_MIDDLE_BOTTOM = TOP | MIDDLE;
84 | /**
85 | * North
86 | */
87 | static const int NORTH = 1;
88 | /**
89 | * South
90 | */
91 | static const int SOUTH = 4;
92 | /**
93 | * West
94 | */
95 | static const int WEST = 8;
96 | /**
97 | * East
98 | */
99 | static const int EAST = 16;
100 | /**
101 | * A constant indicating horizontal direction
102 | */
103 | static const int HORIZONTAL = 64;
104 | /**
105 | * A constant indicating vertical direction
106 | */
107 | static const int VERTICAL = 128;
108 | /**
109 | * North-East: a bit-wise OR of {@link #NORTH} and {@link #EAST}
110 | */
111 | static const int NORTH_EAST = NORTH | EAST;
112 | /**
113 | * North-West: a bit-wise OR of {@link #NORTH} and {@link #WEST}
114 | */
115 | static const int NORTH_WEST = NORTH | WEST;
116 | /**
117 | * South-East: a bit-wise OR of {@link #SOUTH} and {@link #EAST}
118 | */
119 | static const int SOUTH_EAST = SOUTH | EAST;
120 | /**
121 | * South-West: a bit-wise OR of {@link #SOUTH} and {@link #WEST}
122 | */
123 | static const int SOUTH_WEST = SOUTH | WEST;
124 | /**
125 | * North-South: a bit-wise OR of {@link #NORTH} and {@link #SOUTH}
126 | */
127 | static const int NORTH_SOUTH = NORTH | SOUTH;
128 | /**
129 | * East-West: a bit-wise OR of {@link #EAST} and {@link #WEST}
130 | */
131 | static const int EAST_WEST = EAST | WEST;
132 | /**
133 | * North-South-East-West: a bit-wise OR of all 4 directions.
134 | */
135 | static const int NSEW = NORTH_SOUTH | EAST_WEST;
136 | }
137 |
--------------------------------------------------------------------------------
20 | *
23 | * LEFT, CENTER, RIGHT
21 | * Used to describe horizontal position.
22 | *
24 | *
27 | * TOP, MIDDLE, BOTTOM
25 | * Used to describe vertical position.
26 | *
28 | *
34 | *
35 | * NORTH, SOUTH, EAST, WEST
29 | * Used to describe the four positions relative to an object's center point.
30 | * May also be used when describing which direction an object is facing.
33 | *
31 | * NOTE: If you have a use for all four of these possibilities, do not use TOP,
32 | * BOTTOM, RIGHT, LEFT in place of NORTH, SOUTH, EAST, WEST.