internal void AddMember(ScriptProcessor processor, PrototypeMember member) { if (_prototypeMembers.ContainsKey(member.Identifier)) { processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_CLASS_DUPLICATE_DEFINITION, member.Identifier, Name); } _prototypeMembers.Add(member.Identifier, member); }
// TODO: C# 7: put proper Tuple handling in place. private static Tuple <PrototypeMember, string> ParseVarStatement(ScriptProcessor processor, ScriptStatement statement) { var code = statement.Code; var signature = code.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); string identifier; var assignment = ""; var isReadOnly = false; var isStatic = false; // Read static: if (signature.Contains(VAR_SIGNATURE_STATIC)) { isStatic = true; signature.Remove(VAR_SIGNATURE_STATIC); } // Read readonly: if (signature.Contains(VAR_SIGNATURE_READONLY)) { isReadOnly = true; signature.Remove(VAR_SIGNATURE_READONLY); } if (signature[0] != "var" || signature.Count < 2) { processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_CLASS_INVALID_VAR_DECLARATION); } identifier = signature[1]; if (!ScriptProcessor.IsValidIdentifier(identifier)) { processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_MISSING_VAR_NAME); } if (signature.Count > 2) { if (signature[2].StartsWith("=")) { assignment = code.Remove(0, code.IndexOf("=") + 1).Trim(); } else { processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_CLASS_INVALID_VAR_DECLARATION); } } var member = new PrototypeMember(identifier, processor.Undefined, isStatic, isReadOnly, false, false); return(new Tuple <PrototypeMember, string>(member, assignment)); }
public StringPrototype(ScriptProcessor processor) : base("String") { Constructor = new PrototypeMember("constructor", new SFunction(constructor)); }
// TODO: C# 7: put proper Tuple handling in place. private static Tuple<PrototypeMember, string> ParseVarStatement(ScriptProcessor processor, ScriptStatement statement) { var code = statement.Code; var signature = code.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); string identifier; var assignment = ""; var isReadOnly = false; var isStatic = false; // Read static: if (signature.Contains(VAR_SIGNATURE_STATIC)) { isStatic = true; signature.Remove(VAR_SIGNATURE_STATIC); } // Read readonly: if (signature.Contains(VAR_SIGNATURE_READONLY)) { isReadOnly = true; signature.Remove(VAR_SIGNATURE_READONLY); } if (signature[0] != "var" || signature.Count < 2) processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_CLASS_INVALID_VAR_DECLARATION); identifier = signature[1]; if (!ScriptProcessor.IsValidIdentifier(identifier)) processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_MISSING_VAR_NAME); if (signature.Count > 2) { if (signature[2].StartsWith("=")) { assignment = code.Remove(0, code.IndexOf("=") + 1).Trim(); } else { processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_CLASS_INVALID_VAR_DECLARATION); } } var member = new PrototypeMember(identifier, processor.Undefined, isStatic, isReadOnly, false, false); return new Tuple<PrototypeMember, string>(member, assignment); }
internal void AddMember(ScriptProcessor processor, PrototypeMember member) { if (_prototypeMembers.ContainsKey(member.Identifier)) processor.ErrorHandler.ThrowError(ErrorType.SyntaxError, ErrorHandler.MESSAGE_SYNTAX_CLASS_DUPLICATE_DEFINITION, member.Identifier, Name); _prototypeMembers.Add(member.Identifier, member); }
public StringPrototype(ScriptProcessor processor) : base("String") { Constructor = new PrototypeMember("constructor", new SFunction(constructor)); }
public ArrayPrototype() : base("Array") { Constructor = new PrototypeMember("constructor", new SFunction(constructor)); }
public ArrayPrototype() : base("Array") { Constructor = new PrototypeMember("constructor", new SFunction(constructor)); }