private CVar p(EnegyData ed, VariabelDatabase db, Token token, bool name) { this.db = db; if (name) { if (token.next().type() != TokenType.Variabel) { ed.setError(new ScriptError("Missing class name after 'class'", token.getCache().posision()), db); return new NullVariabel(); } builder = new Class(token.getCache().ToString()); } else { builder = new Class(); } if(token.next().type() == TokenType.Extends) { if(token.next().type() != TokenType.Variabel) { ed.setError(new ScriptError("Missing variabel after extends", token.getCache().posision()), db); return new NullVariabel(); } //control if the variabel exteis in the variabel database if (!db.isExists(token.getCache().ToString())) { ed.setError(new ScriptError("Unknown variabel: " + token.getCache().ToString(), token.getCache().posision()), db); return new NullVariabel(); } CVar buffer = db.get(token.getCache().ToString(), ed); if(!(buffer is ClassVariabel)) { ed.setError(new ScriptError(token.getCache().ToString() + " is not a class", token.getCache().posision()), db); return new NullVariabel(); } builder.Extends((ClassVariabel)buffer); token.next(); } if(token.getCache().type() != TokenType.LeftTuborg) { ed.setError(new ScriptError("Missing { after class name", token.getCache().posision()), db); return new NullVariabel(); } token.next(); while (ed.State == RunningState.Normal && run(token.getCache().type())) build(token, ed); if(token.getCache().type() != TokenType.RightTuborg) { ed.setError(new ScriptError("Missing } in end of class building", token.getCache().posision()), db); return new NullVariabel(); } token.next(); if (name) { db.pushClass(builder, ed); if (db is FileVariabelDatabase) { builder.SetExtraVariabelDatabase(db); ((FileVariabelDatabase)db).VariabelDatabase.pushClass(builder, ed); } return null; } else { return new ClassVariabel(builder); } }
public override bool compare(CVar var, Posision pos, EnegyData data, VariabelDatabase db) { if (Types.instanceof((ClassVariabel)db.get("string", data), this)) { return toString(pos, data, db) == var.toString(pos, data, db); }else if (Types.instanceof((ClassVariabel)db.get("int", data), this)) { return toInt(pos, data, db) == var.toInt(pos, data, db); } return this == var; }
private static CVar Format_caller(CVar c, VariabelDatabase db, CVar[] stack, EnegyData data, Posision pos) { StringFormater format = new StringFormater(); ArrayVariabel array = (ArrayVariabel)stack[1]; foreach(string key in array.Keys()) { CVar context = array.get(key, pos, data, db); if (Types.instanceof((ClassVariabel)db.get("string", data), (ObjectVariabel)context)) { format.appendParam(context.toString(pos, data, db)); }else if(Types.instanceof((ClassVariabel)db.get("int", data), (ObjectVariabel)context)) { format.appendParam(Convert.ToInt32(context.toInt(pos, data, db))); } else { data.setError(new ScriptError("Cant convert '" + context.type() + "' to string", pos), db); } } return Types.toString(format.format(stack[0].toString(pos, data, db)), data, db, pos); }
public static ObjectVariabel toString(string context, EnegyData data, VariabelDatabase db, Posision pos) { ObjectVariabel obj = ((ClassVariabel)db.get("string", data)).createNew(db, data, new CVar[1] { new NullVariabel() }, pos); obj.systemItems["str"] = context; return obj; }
public static ObjectVariabel toInt(double ints, EnegyData data, VariabelDatabase db, Posision pos) { ObjectVariabel obj = ((ClassVariabel)db.get("int", data)).createNew(db, data, new CVar[1] { new NullVariabel() }, pos); obj.systemItems["int"] = ints; return obj; }
private void controlID(CVar key, Posision pos, EnegyData data, VariabelDatabase db) { double k; if(Types.instanceof((ClassVariabel)db.get("int", data), (ObjectVariabel)key)) { k = key.toInt(pos, data, db); }else if(key is NullVariabel) { k = 0; }else if(Types.instanceof((ClassVariabel)db.get("string", data), (ObjectVariabel)key) && System.Text.RegularExpressions.Regex.IsMatch(key.toString(pos, data, db), "^[0-9]*?$")) { k = Convert.ToDouble(key.toString(pos, data, db)); } else { return; } while (k >= nextID) getNextID(data, db, pos); }