/Runtime/Dreaming/Codex.cs
C# | 113 lines | 82 code | 9 blank | 22 comment | 2 complexity | 82dc669c1159430cfee3f435a7afc484 MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Reflection;
- using System.CodeDom.Compiler;
-
- namespace Refl.Dreaming
- {
- /// <summary>
- /// Codex Class. Used to Store Code.
- /// </summary>
- public class Codex
- {
- #region Globals
-
- internal Delegate _Del_Code;
- internal String _Str_Code;
- internal Language _Language;
- internal bool _isString = false;
- internal bool _isCompiled = false;
-
- #endregion
- /// <summary>
- /// Constructor which receives code in delegate form.
- /// </summary>
- /// <param name="code">The code delegate.</param>
- public Codex(Delegate code)
- {
- //Since we are receiving a delegate, we can only expect it in compiled form (IL).
- _Language = Language.IL;
- _Del_Code = code;
- _isString = false;
- }
- /// <summary>
- /// Constructor which receives code in string form.
- /// </summary>
- /// <param name="code">The code string.</param>
- /// <param name="language">The language in which the code was written</param>
- public Codex(String code, Language language = Language.ReflectiveSharp)
- {
- _Language = language;
- _Str_Code = code;
- _isString = true;
- }
-
- public override string ToString()
- {
- if (_isString) { return _Str_Code; }
- else { return _Del_Code.ToString(); }
- }
-
- #region 'Overloads'
-
- public static implicit operator Codex(string str)
- {
- return new Codex(str, Language.ReflectiveSharp);
- }
- public static implicit operator Codex(Delegate mi)
- {
- return new Codex(mi);
- }
-
- #endregion
-
- }
- /// <summary>
- /// Enum that defines the available languages in the ReflectiveCS.Dreaming namespace, that may be used in the Dream Class.
- /// </summary>
- public enum DreamLanguage
- {
- Brainfuck = 0,
- CPlusPlus = 1,
- CSharp = 2,
- FSharp = 3,
- IL = 4,
- IronPython = 5,
- IronRuby = 6,
- JScript = 8,
- ReflectiveSharp = 10,
- VisualBasic = 11,
- }
- /// <summary>
- /// Enum that defines the available languages in the ReflectiveCS.Dreaming namespace, that may be used in the Script Class.
- /// </summary>
- public enum ScriptLanguage
- {
- Brainfuck = 0,
- IronPython = 5,
- IronRuby = 6,
- JavaScript = 8,
- Lua = 9,
- }
- /// <summary>
- /// Enum that defines the available languages in the ReflectiveCS.Dreaming namespace.
- /// </summary>
- public enum Language
- {
- Brainfuck = 0,
- CPlusPlus = 1,
- CSharp = 2,
- FSharp = 3,
- IL = 4,
- IronPython = 5,
- IronRuby = 6,
- JavaScript = 7,
- JScript = 8,
- Lua = 9,
- ReflectiveSharp = 10,
- VisualBasic = 11,
-
- }
- }