Beispiel #1
0
 public static SNode getOutputNodeType_fromSourceQuery(SNode query) {
   if (query == null) {
     return _quotation_createNode_w9106s_a0a0a5();
   }
   SNode OutputType = TypeChecker.getInstance().getTypeOf(query);
   if (SNodeOperations.isInstanceOf(
       OutputType, "jetbrains.mps.lang.smodel.structure.SNodeListType")) {
     return _quotation_createNode_w9106s_a0a2a5(
         SLinkOperations.getTarget(
             SNodeOperations.cast(OutputType, "jetbrains.mps.lang.smodel.structure.SNodeListType"),
             "elementConcept",
             false));
   } else {
     SNode outputSNodeType =
         TypeChecker.getInstance()
             .getRuntimeSupport()
             .coerce_(
                 OutputType,
                 HUtil.createMatchingPatternByConceptFQName(
                     "jetbrains.mps.lang.smodel.structure.SNodeType"),
                 true);
     if (outputSNodeType != null) {
       return outputSNodeType;
     } else {
       SNode outputSequenceType =
           TypeChecker.getInstance()
               .getRuntimeSupport()
               .coerce_(
                   OutputType,
                   HUtil.createMatchingPatternByConceptFQName(
                       "jetbrains.mps.baseLanguage.collections.structure.SequenceType"),
                   true);
       if (outputSequenceType != null) {
         SNode elementType = SLinkOperations.getTarget(outputSequenceType, "elementType", true);
         SNode outputSNodeType2 =
             TypeChecker.getInstance()
                 .getRuntimeSupport()
                 .coerce_(
                     elementType,
                     HUtil.createMatchingPatternByConceptFQName(
                         "jetbrains.mps.lang.smodel.structure.SNodeType"),
                     true);
         if (outputSNodeType2 != null) {
           return outputSNodeType2;
         }
       }
     }
   }
   return _quotation_createNode_w9106s_a3a5();
 }
 public List<SNode> getSubOrSuperTypes(
     SNode listType, TypeCheckingContext typeCheckingContext, IsApplicableStatus status) {
   List<SNode> result = new ArrayList<SNode>();
   SNode classifierType =
       TypeChecker.getInstance()
           .getRuntimeSupport()
           .coerce_(
               SLinkOperations.getTarget(listType, "elementType", true),
               HUtil.createMatchingPatternByConceptFQName(
                   "jetbrains.mps.baseLanguage.structure.ClassifierType"),
               true,
               typeCheckingContext);
   if (SLinkOperations.getTarget(classifierType, "classifier", false)
       == SLinkOperations.getTarget(
           new supertypesOf_ListType_ListType_elementSNode_SubtypingRule
                   .QuotationClass_84rynv_a0a0c0a()
               .createNode(typeCheckingContext),
           "classifier",
           false)) {
     ListSequence.fromList(result)
         .addElement(
             new supertypesOf_ListType_ListType_elementSNode_SubtypingRule
                     .QuotationClass_84rynv_a0a0a0c0a()
                 .createNode(typeCheckingContext));
   }
   return result;
 }
Beispiel #3
0
 public static SNode getBinaryOperationType(SNode leftType, SNode rightType, boolean mayBeString) {
   List<SNode> leastCommonSupertypes =
       SubtypingUtil.leastCommonSuperTypes(Arrays.asList(leftType, rightType), null);
   if (mayBeString) {
     SModel javaLangJavaStubModelDescriptor =
         SModelRepository.getInstance()
             .getModelDescriptor(SModelReference.fromString("java.lang@java_stub"));
     assert javaLangJavaStubModelDescriptor != null;
     SModel javaLang = javaLangJavaStubModelDescriptor.getSModel();
     SNode stringClass = SModelOperations.getRootByName(javaLang, "String");
     if (SNodeOperations.isInstanceOf(
                 leftType, "jetbrains.mps.baseLanguage.structure.ClassifierType")
             && SLinkOperations.getTarget(
                     (SNodeOperations.cast(
                         leftType, "jetbrains.mps.baseLanguage.structure.ClassifierType")),
                     "classifier",
                     false)
                 == stringClass
         || SNodeOperations.isInstanceOf(
                 rightType, "jetbrains.mps.baseLanguage.structure.ClassifierType")
             && SLinkOperations.getTarget(
                     (SNodeOperations.cast(
                         rightType, "jetbrains.mps.baseLanguage.structure.ClassifierType")),
                     "classifier",
                     false)
                 == stringClass) {
       SNode classifierType =
           SConceptOperations.createNewNode(
               "jetbrains.mps.baseLanguage.structure.ClassifierType", null);
       SLinkOperations.setTarget(
           classifierType,
           "classifier",
           SNodeOperations.cast(stringClass, "jetbrains.mps.baseLanguage.structure.Classifier"),
           false);
       return classifierType;
     }
   }
   if (leastCommonSupertypes.isEmpty()) {
     SNode runtimeErrorType =
         SConceptOperations.createNewNode(
             "jetbrains.mps.lang.typesystem.structure.RuntimeErrorType", null);
     SPropertyOperations.set(runtimeErrorType, "errorText", "incompatible types");
     return runtimeErrorType;
   }
   SNode type = leastCommonSupertypes.iterator().next();
   {
     IMatchingPattern pattern_j6k1pf_e0c =
         HUtil.createMatchingPatternByConceptFQName(
             "jetbrains.mps.baseLanguage.structure.PrimitiveType");
     SNode coercedNode_j6k1pf_e0c =
         TypeChecker.getInstance().getRuntimeSupport().coerce_(type, pattern_j6k1pf_e0c);
     if (coercedNode_j6k1pf_e0c != null) {
       return coercedNode_j6k1pf_e0c;
     } else {
       return type;
     }
   }
 }
 public void applyRule(
     final SNode nodeToCheck,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   SNode operandType =
       TypeChecker.getInstance()
           .getTypeOf(IOperation_BehaviorDescriptor.getOperand_idhEwIP$m.invoke(nodeToCheck));
   {
     IMatchingPattern pattern_hm5x7h_b0 =
         HUtil.createMatchingPatternByConceptFQName(
             "jetbrains.mps.baseLanguage.classifiers.structure.BaseClassifierType");
     SNode coercedNode_hm5x7h_b0 =
         TypeChecker.getInstance().getRuntimeSupport().coerce_(operandType, pattern_hm5x7h_b0);
     if (coercedNode_hm5x7h_b0 != null) {
       if (!(ListSequence.fromList(
               BaseClassifierType_BehaviorDescriptor.getMembers_idhEwINC$.invoke(
                   coercedNode_hm5x7h_b0, nodeToCheck))
           .contains(
               SLinkOperations.getTarget(
                   nodeToCheck,
                   MetaAdapterFactory.getReferenceLink(
                       0x443f4c36fcf54eb6L,
                       0x95008d06ed259e3eL,
                       0x118bca97396L,
                       0x118bcb657ecL,
                       "member"))))) {
         {
           MessageTarget errorTarget = new NodeMessageTarget();
           IErrorReporter _reporter_2309309498 =
               typeCheckingContext.reportTypeError(
                   nodeToCheck,
                   "Declaration is out of scope",
                   "r:00000000-0000-4000-0000-011c89590371(jetbrains.mps.baseLanguage.classifiers.typesystem)",
                   "1205921883388",
                   null,
                   errorTarget);
         }
       }
     } else {
     }
   }
 }
 public static boolean static_canBeAChild(
     SNode node,
     SNode parentNode,
     SNode link,
     SNode childConcept,
     final IOperationContext operationContext) {
   return (TypeChecker.getInstance()
           .getRuntimeSupport()
           .coerce_(
               TypeChecker.getInstance()
                   .getTypeOf(
                       SLinkOperations.getTarget(
                           SNodeOperations.as(
                               parentNode, "jetbrains.mps.baseLanguage.structure.DotExpression"),
                           "operand",
                           true)),
               HUtil.createMatchingPatternByConceptFQName(
                   "jetbrains.mps.baseLanguage.collections.structure.MappingType"),
               false)
       != null);
 }
Beispiel #6
0
 @Deprecated
 public static SNode virtual_getClassExpression_1213877337357(SNode thisNode) {
   {
     IMatchingPattern pattern_smb55n_a0n =
         HUtil.createMatchingPatternByConceptFQName(
             "jetbrains.mps.baseLanguage.structure.ClassifierType");
     SNode coercedNode_smb55n_a0n =
         TypeChecker.getInstance().getRuntimeSupport().coerce_(thisNode, pattern_smb55n_a0n);
     if (coercedNode_smb55n_a0n != null) {
       return _quotation_createNode_smb55n_a0a2a0a31(
           SLinkOperations.getTarget(
               coercedNode_smb55n_a0n,
               MetaAdapterFactory.getReferenceLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x101de48bf9eL,
                   0x101de490babL,
                   "classifier")));
     } else {
       throw new UnsupportedOperationException();
     }
   }
 }