public Type GetTypeByIdentifier(Identifier key) { if (!ContainsIdentifier(key)) return typeof(object); IStaticReturnType terminal = _identifierLookupTable[key] as IStaticReturnType; return terminal != null ? terminal.GetReturnType() : typeof(object); }
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); }
Type DetermineType(Identifier identifier) { if (ReferenceTables.ContainsIdentifier(identifier)) { return ReferenceTables.GetTypeByIdentifier(identifier); } throw new QLError("Undeclared variable: " + identifier.Value); }
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); }
public void Visit(Identifier node) { }
public StatementUnit(Identifier identifier, Expression expression, string unitText, IStaticReturnType dataType, SourceLocation sourceLocation) : base(identifier, dataType, unitText, sourceLocation) { Expression = expression; }
public bool Equals(Identifier obj) { return Value == obj.Value; }
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"); }
public void SetReference(Identifier key, IResolvable value) { _identifierLookupTable[key] = value; }
public QuestionUnit(Identifier identifier, IStaticReturnType dataType, string displayText) : base(identifier, dataType, displayText) { }
public bool ContainsIdentifier(Identifier key) { return _identifierLookupTable.ContainsKey(key); }
public QuestionUnit(Identifier identifier, IStaticReturnType dataType, string displayText, SourceLocation sourceLocation) : base(identifier, dataType, displayText, sourceLocation) { }
public override void ExitIdentifier(QLParser.IdentifierContext context) { Identifier literal = new Identifier(context.IDENTIFIER().GetText(), SourceLocation.CreateFor(context)); AppendToAST(literal); }
public Form(Identifier identifier, Block block, SourceLocation sourceLocation) : this(identifier, block) { SourceLocation = sourceLocation; }
public Form(Identifier identifier, ElementBase block) { throw new Exception(identifier + ": " + block + " is not a block"); }
public Form(Identifier identifier, Block block) { Identifier = identifier; Block = block; }