Inheritance: SObject
Esempio n. 1
0
 /// <summary>
 /// Adds a variable to the context.
 /// </summary>
 internal void AddVariable(SVariable variable)
 {
     if (_variables.ContainsKey(variable.Identifier))
     {
         _variables[variable.Identifier] = variable;
     }
     else
     {
         _variables.Add(variable.Identifier, variable);
     }
 }
Esempio n. 2
0
 internal void AddMember(SVariable member)
 {
     Members.Add(member.Identifier, member);
 }
Esempio n. 3
0
 internal void AddMember(SVariable member)
 {
     Members.Add(member.Identifier, member);
 }
        private SObject ExecuteVar(ScriptStatement statement)
        {
            var exp = statement.Code;

            var identifier = exp.Remove(0, "var ".Length).Trim();
            var data = Undefined;

            if (identifier.Contains("="))
            {
                var assignment = identifier.Remove(0, identifier.IndexOf("=") + 1).Trim();
                identifier = identifier.Remove(identifier.IndexOf("=")).Trim();

                data = SObject.Unbox(ExecuteStatement(new ScriptStatement(assignment)));
            }

            if (!IsValidIdentifier(identifier))
                return ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_MISSING_VAR_NAME);

            var variable = new SVariable(identifier, data);
            Context.AddVariable(variable);

            return variable;
        }