Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Started working on new typesystem

  • Loading branch information...
commit 6543f495a6103f031cb1277ef74ac9cfda54d838 1 parent 194128d
Ilya Lintsbah authored
View
8 .idea/dictionaries/Ilya_Lintsbakh.xml
@@ -0,0 +1,8 @@
+<component name="ProjectDictionaryState">
+ <dictionary name="Ilya.Lintsbakh">
+ <words>
+ <w>ilya</w>
+ <w>lintsbakh</w>
+ </words>
+ </dictionary>
+</component>
View
36 core/typesystemEngine/source/jetbrains/mps/newTypesystem/Difference.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2003-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jetbrains.mps.newTypesystem;
+
+import jetbrains.mps.smodel.SNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ilya.Lintsbakh
+ * Date: Sep 10, 2010
+ * Time: 6:11:49 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Difference {
+ private Map<SNode, SNode> myNodeToTypes = new HashMap<SNode, SNode>();
+
+ public Map<SNode, SNode> getNodeToTypes() {
+ return myNodeToTypes;
+ }
+}
View
63 core/typesystemEngine/source/jetbrains/mps/newTypesystem/Equations.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2003-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jetbrains.mps.newTypesystem;
+
+import jetbrains.mps.typesystem.inference.IWrapper;
+
+import java.util.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ilya.Lintsbah
+ * Date: Sep 10, 2010
+ * Time: 4:33:42 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Equations {
+ Map<IWrapper, IWrapper> myRepresentatives = new HashMap<IWrapper, IWrapper>();
+
+ public IWrapper getRepresentative(IWrapper wrapper) {
+ IWrapper parent = myRepresentatives.get(wrapper);
+ IWrapper current = wrapper;
+ if (parent != null) {
+ List<IWrapper> path = new LinkedList<IWrapper>();
+ while (parent != null) {
+ path.add(current);
+ current = parent;
+ parent = myRepresentatives.get(parent);
+ }
+ if (path.size() > 1) {
+ for (IWrapper elem : path) {
+ myRepresentatives.put(elem, current);
+ }
+ }
+ }
+ return current;
+ }
+
+ public void addEquation(IWrapper left, IWrapper right) {
+ IWrapper lRepresentative = getRepresentative(left);
+ IWrapper rRepresentative = getRepresentative(right);
+ if (lRepresentative == null || rRepresentative == null || lRepresentative.equals(rRepresentative)) {
+ return; // We don't need such equations
+ }
+
+ }
+
+ public void rollBack() {
+
+ }
+}
View
26 core/typesystemEngine/source/jetbrains/mps/newTypesystem/Inequalities.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2003-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jetbrains.mps.newTypesystem;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ilya.Lintsbakh
+ * Date: Sep 10, 2010
+ * Time: 5:26:43 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class Inequalities {
+}
View
38 core/typesystemEngine/source/jetbrains/mps/newTypesystem/NodesToTypes.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2003-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jetbrains.mps.newTypesystem;
+
+import jetbrains.mps.smodel.SNode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ilya.Lintsbakh
+ * Date: Sep 10, 2010
+ * Time: 6:38:28 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class NodesToTypes {
+ private Map<SNode, SNode> myNodeToTypes = new HashMap<SNode, SNode>();
+
+ public void rollBack(Map<SNode, SNode> difference) {
+ for (SNode node :difference.keySet()) {
+ myNodeToTypes.remove(node);
+ }
+ }
+}
View
51 core/typesystemEngine/source/jetbrains/mps/newTypesystem/State.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2003-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jetbrains.mps.newTypesystem;
+
+
+import jetbrains.mps.smodel.SNode;
+import jetbrains.mps.typesystem.inference.EquationInfo;
+import jetbrains.mps.typesystem.inference.IWrapper;
+
+import java.util.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ilya.Lintsbakh
+ * Date: Sep 10, 2010
+ * Time: 6:09:38 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class State {
+ private Equations myEquations = new Equations();
+ private Inequalities myInequalities = new Inequalities();
+ private NodesToTypes myNodesToTypes = new NodesToTypes();
+
+ public void rollBack(Difference difference) {
+ myEquations.rollBack();
+
+ myNodesToTypes.rollBack(difference.getNodeToTypes());
+ }
+
+ public Equations getEquations() {
+ return myEquations;
+ }
+
+ public Difference addEquation(IWrapper left, IWrapper right, EquationInfo info) {
+ return null;
+ }
+
+}
View
49 core/typesystemEngine/source/jetbrains/mps/newTypesystem/TypeCheckingContextNew.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2003-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jetbrains.mps.newTypesystem;
+
+import jetbrains.mps.smodel.SNode;
+import jetbrains.mps.typesystem.inference.EquationInfo;
+import jetbrains.mps.typesystem.inference.IWrapper;
+import jetbrains.mps.typesystem.inference.TypeChecker;
+import jetbrains.mps.typesystem.inference.TypeCheckingContext;
+
+import java.util.Stack;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ilya.Lintsbakh
+ * Date: Sep 10, 2010
+ * Time: 4:32:55 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TypeCheckingContextNew extends TypeCheckingContext {
+
+ private Equations myEquations = new Equations();
+ private State myState = new State();
+ private Stack<Difference> myDifferenceStack = new Stack<Difference>();
+
+ public TypeCheckingContextNew(SNode rootNode, TypeChecker typeChecker) {
+ super(rootNode, typeChecker);
+ }
+
+ @Override
+ public void createEquation(IWrapper left, IWrapper right, EquationInfo equationInfo) {
+ myDifferenceStack.add(myState.addEquation(left, right, equationInfo));
+ }
+
+
+}
View
29 core/typesystemEngine/source/jetbrains/mps/newTypesystem/test/TestEq.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2003-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package jetbrains.mps.newTypesystem.test;
+
+import junit.framework.TestCase;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ilya.Lintsbakh
+ * Date: Sep 10, 2010
+ * Time: 6:13:49 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestEq extends TestCase{
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.