Пример #1
0
 public FunctionPointerClass(IOperationCodeFactory opFactory, IValueFactory factory) : base(SpecialVariables.Function, SpecialVariables.Global)
 {
     CtorForMembersWithValues.Write(opFactory.Pop()); // pop self instance used for 'me' variable
     CtorForMembersWithValues.Write(opFactory.Return());
     Functions.Add("call", new MemberFunction("call", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(opFactory.Reference(factory.String(SpecialVariables.Function))),
             new Bytecode(opFactory.Call(default)),
Пример #2
0
 public DisposableClass(IOperationCodeFactory factory, IValueFactory valueFactory) : base(
         SpecialVariables.Disposable, SpecialVariables.Global)
 {
     CtorForMembersWithValues.Write(factory.Pop()); // pop self instance used for 'me' variable
     CtorForMembersWithValues.Write(factory.Return());
     Functions.Add("dispose",
                   new MemberFunction("dispose", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.Reference(valueFactory.String(SpecialVariables.Disposable))),
             new Bytecode(factory.Dispose()),
             new Bytecode(factory.Return())
         }
     });
 }
Пример #3
0
 public DateTimeClass(IOperationCodeFactory factory) : base("datetime", SpecialVariables.Global)
 {
     CtorForMembersWithValues.Write(factory.Pop()); // pop self instance used for 'me' variable
     CtorForMembersWithValues.Write(factory.Return());
     // TODO: implement
 }
Пример #4
0
 public MapClass(IOperationCodeFactory factory) : base(SpecialVariables.Map, SpecialVariables.Global)
 {
     CtorForMembersWithValues.Write(factory.Return());
     Functions.Add("len", new MemberFunction("len", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapLength()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("add", new MemberFunction("add", Module, new List <string> {
         "key", "value"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapAdd()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("contains", new MemberFunction("contains", Module, new List <string> {
         "key"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapContains()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("items", new MemberFunction("items", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapGetItems()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("keys", new MemberFunction("keys", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapGetKeys()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("values", new MemberFunction("values", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapGetValues()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("remove", new MemberFunction("remove", Module, new List <string> {
         "key"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapRemove()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("clear", new MemberFunction("clear", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapClear()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("idx_get", new MemberFunction("idx_get", Module, new List <string> {
         "key"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapIndexerGet()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("idx_set", new MemberFunction("idx_set", Module, new List <string> {
         "key", "value"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.MapIndexerSet()),
             new Bytecode(factory.Return())
         }
     });
 }
Пример #5
0
 public StringClass(IOperationCodeFactory factory) : base(SpecialVariables.String, SpecialVariables.Global)
 {
     CtorForMembersWithValues.Write(factory.Return());
     Functions.Add("len", new MemberFunction("len", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()), // pops unused argument count
             new Bytecode(factory.StringLength()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("at", new MemberFunction("at", Module, new List <string> {
         "index"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringIndexerGet()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("idx_get", new MemberFunction("idx_get", Module, new List <string> {
         "index"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringIndexerGet()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("idx_set", new MemberFunction("idx_set", Module, new List <string> {
         "index", "item"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringIndexerSet()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("view", new MemberFunction("view", Module, new List <string> {
         "start", "end"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringView()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("index_of", new MemberFunction("index_of", Module, new List <string> {
         "lookup", "start"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringIndexOf()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("replace", new MemberFunction("replace", Module, new List <string> {
         "old", "new"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringReplace()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("split", new MemberFunction("split", Module, new List <string> {
         "char"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringSplit()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("lower", new MemberFunction("lower", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringToLower()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("upper", new MemberFunction("upper", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringToUpper()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("insert", new MemberFunction("insert", Module, new List <string> {
         "index", "item"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringInsert()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("int", new MemberFunction("int", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringToInt()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("long", new MemberFunction("long", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringToLong()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("double", new MemberFunction("double", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringToDouble()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("bool", new MemberFunction("bool", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.StringToBool()),
             new Bytecode(factory.Return())
         }
     });
 }
Пример #6
0
 public FileHandleClass(IOperationCodeFactory factory, IValueFactory valueFactory) : base(".file",
                                                                                          SpecialVariables.Global)
 {
     CtorForMembersWithValues.Write(factory.Pop()); // pop self instance used for 'me' variable
     CtorForMembersWithValues.Write(factory.Return());
     Functions.Add("close",
                   new MemberFunction("close", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.Reference(valueFactory.String(SpecialVariables.Disposable))),
             new Bytecode(factory.Dispose()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("clear",
                   new MemberFunction("clear", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.FileClear()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("writeln",
                   new MemberFunction("writeln", Module, new List <string> {
         "line"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.FileWrite(true)),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("write",
                   new MemberFunction("write", Module, new List <string> {
         "line"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.FileWrite()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("readln",
                   new MemberFunction("readln", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.FileRead(true)),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("read",
                   new MemberFunction("read", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.FileRead()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("is_eof",
                   new MemberFunction("is_eof", Module, new List <string> {
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),     // pops unused argument count
             new Bytecode(factory.FileEOF()),
             new Bytecode(factory.Return())
         }
     });
 }
Пример #7
0
 public ListClass(IOperationCodeFactory factory) : base(SpecialVariables.List, SpecialVariables.Global)
 {
     CtorForMembersWithValues.Write(factory.Return());
     Functions.Add("len", new MemberFunction("len", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()), // pops unused argument count
             new Bytecode(factory.ListLength()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("add", new MemberFunction("add", Module, new List <string> {
         "item"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListAdd()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("remove", new MemberFunction("remove", Module, new List <string> {
         "item"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListRemove()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("remove_at", new MemberFunction("remove_at", Module, new List <string> {
         "index"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListRemoveAt()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("idx_get", new MemberFunction("idx_get", Module, new List <string> {
         "index"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListIndexerGet()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("idx_set", new MemberFunction("idx_set", Module, new List <string> {
         "index", "item"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListIndexerSet()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("clear", new MemberFunction("clear", Module, new List <string>(), this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListClear()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("insert", new MemberFunction("insert", Module, new List <string> {
         "index", "item"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListInsert()),
             new Bytecode(factory.Return())
         }
     });
     Functions.Add("skip", new MemberFunction("skip", Module, new List <string> {
         "count"
     }, this)
     {
         Code =
         {
             new Bytecode(factory.Pop()),
             new Bytecode(factory.ListSkip()),
             new Bytecode(factory.Return())
         }
     });
 }