Package org.openquark.cal.internal.javamodel

Examples of org.openquark.cal.internal.javamodel.JavaMethod.addStatement()


                   javaMethod.addStatement(ifThen);
                   javaMethod.addStatement(new ReturnStatement (localVariable));

               } else {
                   // The field is strict and therefore already in WHNF.
                   javaMethod.addStatement(new ReturnStatement(jf));
               }

            }

            // If the field type is primitive and strict we want to generate
View Full Code Here


                } else {
                    // This is an error.  We should only get to this point if all
                    // instances of this field/type are strict across all DCs.
                    throw new CodeGenerationException ("Attempt to generate unboxed accessor on lazy field " + javaFieldNames[i] + " for DC " + dc.getName());
                }
                javaMethod.addStatement(new ReturnStatement(jf));

            }
        }

        /**
 
View Full Code Here

                            LiteralWrapper.make(fieldName),
                            JavaTypeName.STRING,
                            JavaTypeNames.RTVALUE,
                            MethodInvocation.InvocationType.VIRTUAL);

                javaMethod.addStatement (new ReturnStatement (mi));
            }
        }


        /**
 
View Full Code Here

            javaClassRep.addMethod(javaMethod);

            if (implementAtThisLevel && isStrict) {
                JavaField field = new JavaField.Instance (null, fieldName, fieldType);
                javaMethod.addStatement(new ReturnStatement (field));
            } else {
                // This class should throw an error for any access.  The methods will
                // be overridden by derived classes for each data constructor.
                // We want to call the RTCons method badFieldAccessor_...
                // that matches the type of the field.
View Full Code Here

                        JavaTypeName.STRING,
                        fieldType,
                        MethodInvocation.InvocationType.VIRTUAL);

                if (castTypeString != null) {
                    javaMethod.addStatement(new ReturnStatement(new JavaExpression.CastExpression(fieldType, mi)));
                } else {
                    javaMethod.addStatement (new ReturnStatement (mi));
                }
            }
        }
View Full Code Here

                        MethodInvocation.InvocationType.VIRTUAL);

                if (castTypeString != null) {
                    javaMethod.addStatement(new ReturnStatement(new JavaExpression.CastExpression(fieldType, mi)));
                } else {
                    javaMethod.addStatement (new ReturnStatement (mi));
                }
            }
        }

        /**
 
View Full Code Here

            // public final int getArity() {return 0;}
            int modifiers = Modifier.PUBLIC | Modifier.FINAL;
            JavaTypeName returnType = JavaTypeName.INT;
            JavaMethod javaMethod = new JavaMethod(modifiers, returnType, "getArity");
            tagDCClassRep.addMethod(javaMethod);
            javaMethod.addStatement(new ReturnStatement(LiteralWrapper.make(Integer.valueOf(0))));

            // public final int getOrdinalValue(){return tag;}
            modifiers = Modifier.PUBLIC | Modifier.FINAL;
            returnType = JavaTypeName.INT;
            javaMethod = new JavaMethod(modifiers, returnType, "getOrdinalValue");
View Full Code Here

            // public final int getOrdinalValue(){return tag;}
            modifiers = Modifier.PUBLIC | Modifier.FINAL;
            returnType = JavaTypeName.INT;
            javaMethod = new JavaMethod(modifiers, returnType, "getOrdinalValue");
            tagDCClassRep.addMethod(javaMethod);
            javaMethod.addStatement(new ReturnStatement(new JavaField.Instance(null, "tag", JavaTypeName.INT)));

            // public final String getModuleName() ...
            modifiers = Modifier.PUBLIC | Modifier.FINAL;
            returnType = JavaTypeName.STRING;
            javaMethod = new JavaMethod(modifiers, returnType, "getModuleName");
View Full Code Here

            // public final String getModuleName() ...
            modifiers = Modifier.PUBLIC | Modifier.FINAL;
            returnType = JavaTypeName.STRING;
            javaMethod = new JavaMethod(modifiers, returnType, "getModuleName");
            tagDCClassRep.addMethod(javaMethod);
            javaMethod.addStatement(new ReturnStatement(LiteralWrapper.make (typeConstructor.getName().getModuleName().toSourceText())));

            // public final String getUnqualifiedName() ...
            modifiers = Modifier.PUBLIC | Modifier.FINAL;
            returnType = JavaTypeName.STRING;
            javaMethod = new JavaMethod(modifiers, returnType, "getUnqualifiedName");
View Full Code Here

            SwitchStatement sw = new SwitchStatement (new JavaField.Instance(null, "tag", JavaTypeName.INT));
            for (int i = 0, nDCs = dataConsList.size(); i < nDCs; ++i) {
                DataConstructor dc = dataConsList.get (i);
                sw.addCase(new SwitchStatement.IntCaseGroup(dc.getOrdinal(), new ReturnStatement (LiteralWrapper.make(dc.getName().getUnqualifiedName()))));
            }
            javaMethod.addStatement (sw);
            javaMethod.addStatement(new ReturnStatement(LiteralWrapper.make ("Unknown data constructor")));

            // public final String getQualfiedName() ...
            modifiers = Modifier.PUBLIC | Modifier.FINAL;
            returnType = JavaTypeName.STRING;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.