Skip to content

Commit

Permalink
smart references for goto statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Bernauer committed Sep 16, 2010
1 parent d2c6e1f commit 6504889
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 2 deletions.
54 changes: 54 additions & 0 deletions languages/c_core/languageModels/constraints.mps
Expand Up @@ -32,5 +32,59 @@
<devkit namespace="2677cb18-f558-4e33-bc38-a5139cee06dc(jetbrains.mps.devkit.language-design)" />
<maxImportIndex value="1" />
<import index="1" modelUID="r:e4808a16-19fc-4fb0-a91b-18aa0fbdd885(c_core.structure)" version="40" />
<visible index="2" modelUID="r:00000000-0000-4000-0000-011c89590288(jetbrains.mps.lang.core.structure)" />
<node type="jetbrains.mps.lang.constraints.structure.ConceptConstraints:8" id="6471839466106780924">
<property name="package:8" value="08-statements_and_blocks.01-labeled_statements" />
<link role="concept:8" targetNodeId="1.2342396778213291236:40" resolveInfo="LabelStatement" />
<node role="property:8" type="jetbrains.mps.lang.constraints.structure.NodePropertyConstraint:8" id="6471839466106780925">
<link role="applicableProperty:8" targetNodeId="2v.1169194664001:0" resolveInfo="name" />
<node role="propertyGetter:8" type="jetbrains.mps.lang.constraints.structure.ConstraintFunction_PropertyGetter:8" id="6471839466106780926">
<node role="body:8" type="jetbrains.mps.baseLanguage.structure.StatementList:3" id="6471839466106780927">
<node role="statement:3" type="jetbrains.mps.baseLanguage.structure.ExpressionStatement:3" id="6471839466106866598">
<node role="expression:3" type="jetbrains.mps.baseLanguage.structure.DotExpression:3" id="6471839466106887936">
<node role="operand:3" type="jetbrains.mps.baseLanguage.structure.DotExpression:3" id="6471839466106866600">
<node role="operand:3" type="jetbrains.mps.lang.constraints.structure.ConstraintsFunctionParameter_node:8" id="6471839466106866599" />
<node role="operation:3" type="jetbrains.mps.lang.smodel.structure.SLinkAccess:16" id="6471839466106887935">
<link role="link:16" targetNodeId="1.2342396778213291239:40" />
</node>
</node>
<node role="operation:3" type="jetbrains.mps.lang.smodel.structure.SPropertyAccess:16" id="6471839466106887940">
<link role="property:16" targetNodeId="1.6637026266040365579:40" resolveInfo="value" />
</node>
</node>
</node>
</node>
</node>
<node role="propertySetter:8" type="jetbrains.mps.lang.constraints.structure.ConstraintFunction_PropertySetter:8" id="6471839466106887941">
<node role="body:8" type="jetbrains.mps.baseLanguage.structure.StatementList:3" id="6471839466106887942">
<node role="statement:3" type="jetbrains.mps.baseLanguage.structure.ExpressionStatement:3" id="6471839466106887943">
<node role="expression:3" type="jetbrains.mps.baseLanguage.structure.AssignmentExpression:3" id="6471839466106887955">
<node role="rValue:3" type="jetbrains.mps.lang.constraints.structure.ConstraintsFunctionParameter_propertyValue:8" id="6471839466106887958" />
<node role="lValue:3" type="jetbrains.mps.baseLanguage.structure.DotExpression:3" id="6471839466106887950">
<node role="operand:3" type="jetbrains.mps.baseLanguage.structure.DotExpression:3" id="6471839466106887945">
<node role="operand:3" type="jetbrains.mps.lang.constraints.structure.ConstraintsFunctionParameter_node:8" id="6471839466106887944" />
<node role="operation:3" type="jetbrains.mps.lang.smodel.structure.SLinkAccess:16" id="6471839466106887949">
<link role="link:16" targetNodeId="1.2342396778213291239:40" />
</node>
</node>
<node role="operation:3" type="jetbrains.mps.lang.smodel.structure.SPropertyAccess:16" id="6471839466106887954">
<link role="property:16" targetNodeId="1.6637026266040365579:40" resolveInfo="value" />
</node>
</node>
</node>
</node>
</node>
</node>
<node role="propertyValidator:8" type="jetbrains.mps.lang.constraints.structure.ConstraintFunction_PropertyValidator:8" id="6471839466106887959">
<node role="body:8" type="jetbrains.mps.baseLanguage.structure.StatementList:3" id="6471839466106887960">
<node role="statement:3" type="jetbrains.mps.baseLanguage.structure.ExpressionStatement:3" id="6471839466106887961">
<node role="expression:3" type="jetbrains.mps.baseLanguage.structure.BooleanConstant:3" id="6471839466106887962">
<property name="value:3" value="true" />
</node>
</node>
</node>
</node>
</node>
</node>
</model>

13 changes: 13 additions & 0 deletions languages/c_core/languageModels/editor.mps
Expand Up @@ -2316,5 +2316,18 @@
<node role="cellLayout:32" type="jetbrains.mps.lang.editor.structure.CellLayout_Horizontal:32" id="4508896632269305651" />
</node>
</node>
<node type="jetbrains.mps.lang.editor.structure.ConceptEditorDeclaration:32" id="6471839466106887965">
<property name="package:32" value="08-statements_and_blocks.06-jump_statements" />
<link role="conceptDeclaration:32" targetNodeId="1.6471839466106887963:40" resolveInfo="LabelStatementRef" />
<node role="cellModel:32" type="jetbrains.mps.lang.editor.structure.CellModel_RefCell:32" id="6471839466106887967">
<link role="relationDeclaration:32" targetNodeId="1.6471839466106887964:40" />
<node role="editorComponent:32" type="jetbrains.mps.lang.editor.structure.InlineEditorComponent:32" id="6471839466106887968">
<node role="cellModel:32" type="jetbrains.mps.lang.editor.structure.CellModel_Property:32" id="6471839466106887970">
<property name="readOnly:32" value="true" />
<link role="relationDeclaration:32" targetNodeId="2v.1169194664001:0" resolveInfo="name" />
</node>
</node>
</node>
</node>
</model>

16 changes: 15 additions & 1 deletion languages/c_core/languageModels/structure.mps
Expand Up @@ -2426,6 +2426,9 @@
<node role="implements:0" type="jetbrains.mps.lang.structure.structure.InterfaceConceptReference:0" id="2342396778213291238">
<link role="intfc:0" targetNodeId="2342396778213284480:40" resolveInfo="LabeledStatement" />
</node>
<node role="implements:0" type="jetbrains.mps.lang.structure.structure.InterfaceConceptReference:0" id="6471839466106780923">
<link role="intfc:0" targetNodeId="2v.1169194658468:0" resolveInfo="INamedConcept" />
</node>
</node>
<node type="jetbrains.mps.lang.structure.structure.ConceptDeclaration:0" id="2342396778213291253">
<property name="package:0" value="08-statements_and_blocks.01-labeled_statements" />
Expand Down Expand Up @@ -2679,7 +2682,7 @@
<property name="metaClass:0" value="aggregation" />
<property name="role:0" value="target" />
<property name="sourceCardinality:0" value="1" />
<link role="target:0" targetNodeId="7030701406977737012:40" resolveInfo="Identifier" />
<link role="target:0" targetNodeId="6471839466106887963:40" resolveInfo="LabelStatementRef" />
</node>
<node role="implements:0" type="jetbrains.mps.lang.structure.structure.InterfaceConceptReference:0" id="6720416824786338314">
<link role="intfc:0" targetNodeId="2342396778213291233:40" resolveInfo="JumpStatement" />
Expand Down Expand Up @@ -2824,5 +2827,16 @@
<link role="target:0" targetNodeId="7030701406977737012:40" resolveInfo="Identifier" />
</node>
</node>
<node type="jetbrains.mps.lang.structure.structure.ConceptDeclaration:0" id="6471839466106887963">
<property name="package:0" value="08-statements_and_blocks.06-jump_statements" />
<property name="name:0" value="LabelStatementRef" />
<link role="extends:0" targetNodeId="2v.1133920641626:0" resolveInfo="BaseConcept" />
<node role="linkDeclaration:0" type="jetbrains.mps.lang.structure.structure.LinkDeclaration:0" id="6471839466106887964">
<property name="metaClass:0" value="reference" />
<property name="role:0" value="target" />
<property name="sourceCardinality:0" value="1" />
<link role="target:0" targetNodeId="2342396778213291236:40" resolveInfo="LabelStatement" />
</node>
</node>
</model>

26 changes: 25 additions & 1 deletion languages/c_core/languageModels/textGen.mps
Expand Up @@ -3382,7 +3382,7 @@
</node>
</node>
<node role="part:11" type="jetbrains.mps.lang.textGen.structure.ConstantStringAppendPart:11" id="4508896632269313773">
<property name="value:11" value=")" />
<property name="value:11" value=") " />
</node>
<node role="part:11" type="jetbrains.mps.lang.textGen.structure.NodeAppendPart:11" id="4508896632269313775">
<node role="value:11" type="jetbrains.mps.baseLanguage.structure.DotExpression:3" id="4508896632269313778">
Expand Down Expand Up @@ -3853,5 +3853,29 @@
</node>
</node>
</node>
<visible index="2" modelUID="r:00000000-0000-4000-0000-011c89590288(jetbrains.mps.lang.core.structure)" />
<node type="jetbrains.mps.lang.textGen.structure.ConceptTextGenDeclaration:11" id="6471839466107003799">
<property name="package:11" value="08-statements_and_blocks.06-jump_statements" />
<link role="conceptDeclaration:11" targetNodeId="1.6471839466106887963:40" resolveInfo="LabelStatementRef" />
<node role="textGenBlock:11" type="jetbrains.mps.lang.textGen.structure.GenerateTextDeclaration:11" id="6471839466107003800">
<node role="body:11" type="jetbrains.mps.baseLanguage.structure.StatementList:3" id="6471839466107003801">
<node role="statement:3" type="jetbrains.mps.lang.textGen.structure.AppendOperation:11" id="6471839466107003802">
<node role="part:11" type="jetbrains.mps.lang.textGen.structure.NodeAppendPart:11" id="6471839466107003804">
<node role="value:11" type="jetbrains.mps.baseLanguage.structure.DotExpression:3" id="6471839466107003812">
<node role="operand:3" type="jetbrains.mps.baseLanguage.structure.DotExpression:3" id="6471839466107003807">
<node role="operand:3" type="jetbrains.mps.lang.textGen.structure.NodeParameter:11" id="6471839466107003806" />
<node role="operation:3" type="jetbrains.mps.lang.smodel.structure.SLinkAccess:16" id="6471839466107003811">
<link role="link:16" targetNodeId="1.6471839466106887964:40" />
</node>
</node>
<node role="operation:3" type="jetbrains.mps.lang.smodel.structure.SPropertyAccess:16" id="6471839466107003816">
<link role="property:16" targetNodeId="2v.1169194664001:0" resolveInfo="name" />
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</model>

85 changes: 85 additions & 0 deletions solutions/c_core.sandbox/playground.mps
Expand Up @@ -586,5 +586,90 @@
</node>
</node>
</node>
<node type="c_core.structure.TranslationUnit:40" id="6471839466106981624">
<property name="name:40" value="goto" />
<node role="elements:40" type="c_core.structure.FunctionDefinition:40" id="6471839466106981626">
<node role="specifiers:40" type="c_core.structure.DeclarationSpecifiers:40" id="6471839466106981627">
<node role="elements:40" type="c_core.structure.Void:40" id="6471839466106981632" />
</node>
<node role="declaration:40" type="c_core.structure.Declarator:40" id="6471839466106981629">
<node role="directDeclarator:40" type="c_core.structure.FunctionDeclaration:40" id="6471839466106981633">
<node role="declarator:40" type="c_core.structure.Identifier:40" id="6471839466106981636">
<property name="value:40" value="foo" />
</node>
<node role="parameters:40" type="c_core.structure.ParameterList:40" id="6471839466106981637">
<node role="elements:40" type="c_core.structure.AbstractParameterDeclaration:40" id="6471839466106981639">
<node role="specifiers:40" type="c_core.structure.DeclarationSpecifiers:40" id="6471839466106981640">
<node role="elements:40" type="c_core.structure.Void:40" id="6471839466106981642" />
</node>
</node>
</node>
</node>
</node>
<node role="body:40" type="c_core.structure.CompoundStatement:40" id="6471839466106981631">
<node role="items:40" type="c_core.structure.BlockItemList:40" id="6471839466106981644">
<node role="elements:40" type="c_core.structure.Declaration:40" id="6471839466106981646">
<node role="specifiers:40" type="c_core.structure.DeclarationSpecifiers:40" id="6471839466106981647">
<node role="elements:40" type="c_core.structure.Int:40" id="6471839466106981649" />
</node>
<node role="init:40" type="c_core.structure.InitDeclaratorList:40" id="6471839466106981650">
<node role="elements:40" type="c_core.structure.InitializedDeclarator:40" id="6471839466106981652">
<node role="declarator:40" type="c_core.structure.Declarator:40" id="6471839466106981653">
<node role="directDeclarator:40" type="c_core.structure.Identifier:40" id="6471839466106981656">
<property name="value:40" value="i" />
</node>
</node>
<node role="initializer:40" type="c_core.structure.Constant:40" id="6471839466106981675">
<property name="value:40" value="10" />
</node>
</node>
</node>
</node>
<node role="elements:40" type="c_core.structure.LabelStatement:40" id="6471839466106981659">
<node role="label:40" type="c_core.structure.Identifier:40" id="6471839466106981662">
<property name="value:40" value="start" />
</node>
<node role="statement:40" type="c_core.structure.IfStatement:40" id="6471839466106981672">
<node role="condition:40" type="c_core.structure.Equals:40" id="6471839466106981676">
<node role="lhs:40" type="c_core.structure.Identifier:40" id="6471839466106981679">
<property name="value:40" value="i" />
</node>
<node role="rhs:40" type="c_core.structure.Constant:40" id="6471839466106981680">
<property name="value:40" value="0" />
</node>
</node>
<node role="then:40" type="c_core.structure.Goto:40" id="6471839466106981681">
<node role="target:40" type="c_core.structure.LabelStatementRef:40" id="6471839466107003789">
<link role="target:40" targetNodeId="6471839466106981665" resolveInfo="end" />
</node>
</node>
</node>
</node>
<node role="elements:40" type="c_core.structure.ExpressionStatement:40" id="6471839466107003790">
<node role="expression:40" type="c_core.structure.PrefixDecrement:40" id="6471839466107003792">
<node role="operand:40" type="c_core.structure.Identifier:40" id="6471839466107003794">
<property name="value:40" value="i" />
</node>
</node>
</node>
<node role="elements:40" type="c_core.structure.Goto:40" id="6471839466107003796">
<node role="target:40" type="c_core.structure.LabelStatementRef:40" id="6471839466107003798">
<link role="target:40" targetNodeId="6471839466106981659" resolveInfo="start" />
</node>
</node>
<node role="elements:40" type="c_core.structure.LabelStatement:40" id="6471839466106981665">
<node role="label:40" type="c_core.structure.Identifier:40" id="6471839466106981668">
<property name="value:40" value="end" />
</node>
<node role="statement:40" type="c_core.structure.Return:40" id="6471839466106981669">
<node role="returnValue:40" type="c_core.structure.Identifier:40" id="6471839466106981671">
<property name="value:40" value="i" />
</node>
</node>
</node>
</node>
</node>
</node>
</node>
</model>

0 comments on commit 6504889

Please sign in to comment.