Esempio n. 1
0
 public int GetVariable(VariableIdent ident)
 {
     if (variables.ContainsKey(ident))
     {
         return variables[ident];
     }
     return -1;
 }
Esempio n. 2
0
 public void InitVariable(string variable)
 {
     VariableIdent ident = new VariableIdent()
     {
         FrameId = frameStack.Peek().Id,
         VariableName = variable
     };
     if (!variables.ContainsKey(ident))
     {
         variables[ident] = new ObjectVariable(new Undefined());
     }
 }
Esempio n. 3
0
 public void AddVariable(VariableIdent ident, int id)
 {
     variables.Add(ident, id);
 }
Esempio n. 4
0
 public void SetVariableValue(string variable, Variable value)
 {
     Variable var = FindVariable(variable);
     if (var != null)
     {
         var.SetValue(value.Value);
     }
     else
     {
         VariableIdent ident = new VariableIdent()
         {
             FrameId = frameStack.Peek().Id,
             VariableName = variable
         };
         variables.Add(ident, value);
     }
 }
Esempio n. 5
0
 private Variable FindVariable(string variableName)
 {
     Frame currentFrame = frameStack.Peek();
     VariableIdent variableIdent = new VariableIdent()
     {
         FrameId = currentFrame.Id,
         VariableName = variableName
     };
     while (!(variables.ContainsKey(variableIdent)) && (currentFrame.Parent != null))
     {
         currentFrame = currentFrame.Parent;
         variableIdent.FrameId = currentFrame.Id;
     }
     if (variables.ContainsKey(variableIdent))
     {
         return variables[variableIdent];
     }
     return null;
 }