예제 #1
0
        public Type GetTypeByIdentifier(Identifier key)
        {
            if (!ContainsIdentifier(key)) return typeof(object);

            IStaticReturnType terminal = _identifierLookupTable[key] as IStaticReturnType;
            return terminal != null ? terminal.GetReturnType() : typeof(object);
        }
예제 #2
0
        public void EvaluationAssignmentOfVariable()
        {
            Initialize(@"form ExampleBlock {
                question Q1 (number) ""Give me a number"";

                if (Q1==2){
                   statement S1 (number, Q1) ""you wrote 2"";
                    }
                else {
                        statement S2 (number, Q1) ""you didnt write 2"";
                     };

                }
            ");
            Assert.IsTrue(Builder.RunEvaluators());
            Identifier i = new Identifier("Q1");

            NumberWrapper nw = (NumberWrapper)Builder.DataContext.ValueReferenceTable.GetValue(i);
            nw.Value = 2;
            Assert.IsTrue(Builder.RunEvaluators());

            Identifier S1 = new Identifier("S1");
            NumberWrapper S1_value = (NumberWrapper)Builder.DataContext.ValueReferenceTable.GetValue(S1);
            Assert.AreEqual(nw.Value,S1_value.Value);
        }
예제 #3
0
 Type DetermineType(Identifier identifier)
 {
     if (ReferenceTables.ContainsIdentifier(identifier))
     {
         return ReferenceTables.GetTypeByIdentifier(identifier);
     }
     throw new QLError("Undeclared variable: " + identifier.Value);
 }
예제 #4
0
 private void DeclareNewVariable(Identifier key, IResolvable value)
 {
     if (ReferenceTables.ContainsIdentifier(key))
     {
         Exceptions.Add(new RedeclaredVariableWarning("Redeclared variable detected: " + key, key.SourceLocation));
     }
     ReferenceTables.SetReference(key, value);
 }
예제 #5
0
 public void Visit(Identifier node)
 {
 }
예제 #6
0
 public StatementUnit(Identifier identifier, Expression expression, string unitText, IStaticReturnType dataType, SourceLocation sourceLocation)
     : base(identifier, dataType, unitText, sourceLocation)
 {
     Expression = expression;
 }
예제 #7
0
 public bool Equals(Identifier obj)
 {
     return Value == obj.Value;
 }
예제 #8
0
 private ITerminalWrapper GetValue(Identifier key)
 {
     if (_identifierLookupTable.ContainsKey(key) && _referenceLookupTable.ContainsKey(_identifierLookupTable[key]))
     {
         return _referenceLookupTable[_identifierLookupTable[key]];
     }
     if (_identifierLookupTable.ContainsKey(key))
     {
         throw new QLError("Reference not initialised");
     }
     throw new QLError("Usage of variable " + key.Value + " before declaration");
 }
예제 #9
0
 public void SetReference(Identifier key, IResolvable value)
 {
     _identifierLookupTable[key] = value;
 }
예제 #10
0
 public QuestionUnit(Identifier identifier, IStaticReturnType dataType, string displayText)
     : base(identifier, dataType, displayText)
 {
 }
예제 #11
0
 public bool ContainsIdentifier(Identifier key)
 {
     return _identifierLookupTable.ContainsKey(key);
 }
예제 #12
0
 public QuestionUnit(Identifier identifier, IStaticReturnType dataType, string displayText, SourceLocation sourceLocation)
     : base(identifier, dataType, displayText, sourceLocation)
 {
 }
예제 #13
0
 public override void ExitIdentifier(QLParser.IdentifierContext context)
 {
     Identifier literal = new Identifier(context.IDENTIFIER().GetText(), SourceLocation.CreateFor(context));
     AppendToAST(literal);
 }
예제 #14
0
파일: Form.cs 프로젝트: javachengwc/many-ql
 public Form(Identifier identifier, Block block, SourceLocation sourceLocation)
     : this(identifier, block)
 {
     SourceLocation = sourceLocation;
 }
예제 #15
0
파일: Form.cs 프로젝트: javachengwc/many-ql
 public Form(Identifier identifier, ElementBase block)
 {
     throw new Exception(identifier + ": " + block + " is not a block");
 }
예제 #16
0
파일: Form.cs 프로젝트: javachengwc/many-ql
 public Form(Identifier identifier, Block block)
 {
     Identifier = identifier;
     Block = block;
 }