Source Code Cross Referenced for TypeConstructor.java in  » Scripting » Nice » mlsub » typing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » Nice » mlsub.typing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************/
002:        /*                           B O S S A                                    */
003:        /*        A simple imperative object-oriented research language           */
004:        /*                   (c)  Daniel Bonniot 1999                             */
005:        /*                                                                        */
006:        /*  This program is free software; you can redistribute it and/or modify  */
007:        /*  it under the terms of the GNU General Public License as published by  */
008:        /*  the Free Software Foundation; either version 2 of the License, or     */
009:        /*  (at your option) any later version.                                   */
010:        /*                                                                        */
011:        /**************************************************************************/package mlsub.typing;
012:
013:        import java.util.*;
014:        import mlsub.typing.lowlevel.*;
015:
016:        /**
017:         * A class. It "needs" type parameters to become a Monotype
018:         */
019:        public class TypeConstructor implements  mlsub.typing.lowlevel.Element,
020:                TypeSymbol {
021:            /**
022:             * Creates a TypeConstructor.
023:             *
024:             * A concrete TC is a TC that can tag runtime objects.
025:             */
026:            public TypeConstructor(String name, AtomicKind v, boolean concrete,
027:                    boolean rigid) {
028:                this .name = name;
029:                this .concrete = concrete;
030:                this .rigid = rigid;
031:
032:                if (v != null)
033:                    setVariance(v);
034:            }
035:
036:            /**
037:               Creates a non rigid type constructor.
038:             */
039:            public TypeConstructor(String name) {
040:                this (name, null, false, false);
041:            }
042:
043:            /**
044:               Creates an anonymous non-concrete TypeConstructor with a known variance.
045:             */
046:            public TypeConstructor(AtomicKind v) {
047:                this (null, v, false, false);
048:            }
049:
050:            public void setMinimal() {
051:                variance.getConstraint().assertMinimal(this );
052:            }
053:
054:            public boolean isMinimal() {
055:                return variance.getConstraint().isMinimal(this );
056:            }
057:
058:            public TypeSymbol cloneTypeSymbol() {
059:                return new TypeConstructor(name, variance, concrete, rigid);
060:            }
061:
062:            /**
063:               @return s if it is a type constructor, null otherwise
064:             */
065:            public static TypeConstructor fromTypeSymbol(TypeSymbol s) {
066:                if (s instanceof  TypeConstructor)
067:                    return (TypeConstructor) s;
068:                else
069:                    return null;
070:            }
071:
072:            /**
073:             * Tell which variance this TypeConstructor has.
074:             * Can be called from ImplementsCst.
075:             */
076:            public void setVariance(AtomicKind v) {
077:                setKind(v.getConstraint());
078:            }
079:
080:            public void discard() {
081:                variance.getConstraint().discard(this );
082:            }
083:
084:            public int arity() {
085:                if (variance == null)
086:                    throw new InternalError("Variance of " + this 
087:                            + " not known in arity()");
088:
089:                return variance.arity();
090:            }
091:
092:            public boolean isConcrete() {
093:                return concrete;
094:            }
095:
096:            public boolean isExistential() {
097:                // Only MonotypeVars need to be marked as existential.
098:                return false;
099:            }
100:
101:            /****************************************************************
102:             * Kinding
103:             ****************************************************************/
104:
105:            private int id = -1;
106:
107:            public int getId() {
108:                return id;
109:            }
110:
111:            public void setId(int value) {
112:                id = value;
113:            }
114:
115:            private Kind kind;
116:
117:            public Kind getKind() {
118:                return kind;
119:            }
120:
121:            public void setKind(Kind value) {
122:                if (kind != null)
123:                    if (kind == value)
124:                        return;
125:                    else
126:                        throw new InternalError(
127:                                "Variance already set in type constructor "
128:                                        + this );
129:
130:                variance = (AtomicKind) ((Engine.Constraint) value).associatedKind;
131:                kind = value;
132:            }
133:
134:            /****************************************************************
135:             * Misc
136:             ****************************************************************/
137:
138:            public String toString() {
139:                if (name != null)
140:                    return name;
141:                else
142:                    return super .toString();
143:            }
144:
145:            /**
146:               Create a string representing the monotype build by application
147:               of this type constructor to the given parameters.
148:
149:               This default implementation returns "tc<p1, ..., pn>".
150:
151:               It should be overriden by type constructors that print differently.
152:               For instance, the array tape constructor could return "p1[]".
153:
154:               @param parameters the type parameters
155:               @return the representation of the monotype
156:             */
157:            public String toString(Monotype[] parameters) {
158:                return toString(parameters, false, null);
159:            }
160:
161:            /**
162:               Print the monotype when it can be null.
163:             */
164:            public String toString(Monotype[] parameters, boolean isNull,
165:                    String suffix) {
166:                String res = this .toString()
167:                        + bossa.util.Util.map("<", ", ", ">", parameters);
168:                if (isNull)
169:                    res = "?" + res;
170:                if (suffix != null)
171:                    res = res + suffix;
172:                return res;
173:            }
174:
175:            /****************************************************************
176:             * Fields
177:             ****************************************************************/
178:
179:            public AtomicKind variance;
180:            private boolean concrete;
181:            private boolean rigid;
182:
183:            public final boolean isRigid() {
184:                return rigid;
185:            };
186:
187:            String name;
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.