public StringPrototype(MelonEngine engine, MelonType type) : base(engine, type) { var properties = new PropertyDictionary { ["Length"] = new Property(new NativeFunctionInstance("Length", type, engine, Length)) }; SetProperties(properties); }
public LexicalEnvironment(MelonEngine engine, bool isRoot) { IsRoot = isRoot; _engine = engine; Children = new List <LexicalEnvironment>(); }
public LexicalEnvironment(LexicalEnvironment parent, bool isRoot) { IsRoot = isRoot; Parent = parent; Parent.AddChild(this); _engine = Parent._engine; Variables = new Dictionary <string, Variable>(); Children = new List <LexicalEnvironment>(); }
public NativeFunctionInstance(string name, MelonObject self, MelonEngine engine, NativeFunctionDelegate del) : base(name, engine) { Self = self; ReturnTypeAttribute returnTypeAttribute = del.Method.GetCustomAttribute <ReturnTypeAttribute>(); if (returnTypeAttribute != null) { ReturnType = new TypeReference(engine, engine.GetType(returnTypeAttribute.Type)); } ParameterAttribute[] parameterAttributes = del.Method.GetCustomAttributes <ParameterAttribute>().ToArray(); if (parameterAttributes?.Length > 0) { ParameterTypes = new FunctionParameter[parameterAttributes.Length]; bool hasVarargs = false; for (int i = 0; i < parameterAttributes.Length; i++) { if (parameterAttributes[i].IsGeneric) { ParameterTypes[i] = new FunctionParameter(parameterAttributes[i].Name, parameterAttributes[i].GenericIndex); } else { ParameterTypes[i] = new FunctionParameter(parameterAttributes[i].Name, new TypeReference(engine, engine.GetType(parameterAttributes[i].Type))); } if (parameterAttributes[i].IsVarargs) { if (hasVarargs || i < parameterAttributes.Length - 1) { throw new MelonException("Varargs parameter can only appear once and has to be the last parameter"); } ParameterTypes[i].IsVarargs = true; hasVarargs = true; } } } else { ParameterTypes = new[] { new FunctionParameter("", new TypeReference(engine, engine.anyType)) { IsVarargs = true } }; } Delegate = del; }
public static bool TryCreateFunction(MelonEngine engine, MethodInfo method, out NativeFunctionInstance function) { if (CheckSignature(method)) { var del = (NativeFunctionDelegate)method.CreateDelegate(typeof(NativeFunctionDelegate)); function = new NativeFunctionInstance(del.Method.Name, null, engine, del); return(true); } function = null; return(false); }
public BooleanType(MelonEngine engine) : base(engine) { }
public FunctionInstance(string name, MelonEngine engine) : base(engine) { Type = engine.functionType; Name = name; }
public FunctionType(MelonEngine engine) : base(engine) { Prototype = new FunctionPrototype(engine, this); }
public AnyType(MelonEngine engine) : base(engine) { }
public ParseContext(MelonEngine engine, LexicalEnvironment environment) { LexicalEnvironment = new LexicalEnvironment(environment, !environment.IsRoot); }
public MelonType(MelonEngine engine) : base(engine) { }
public MelonPrototype(MelonEngine engine, MelonType type) : base(engine) { Type = type; }
public MelonGenericType(MelonEngine engine) : base(engine) { }
public ByteCodePrinter(MelonEngine engine) { _engine = engine; }
public MelonInstance(MelonEngine engine) : base(engine) { }
public MelonVisitor(MelonEngine engine, ScriptFunctionInstance scriptFunction) : this(engine) { _scriptFunction = scriptFunction; }
public BooleanPrototype(MelonEngine engine, MelonType type) : base(engine, type) { }
public FunctionPrototype(MelonEngine engine, MelonType type) : base(engine, type) { }
public BooleanInstance(MelonEngine engine, bool val) : base(engine) { Type = engine.booleanType; value = val; }
public ExpressionSolver(MelonEngine engine) { _engine = engine; }
public FloatPrototype(MelonEngine engine, MelonType type) : base(engine, type) { }
public IntegerInstance(MelonEngine engine, int val) : base(engine) { Type = engine.integerType; value = val; }
public FloatType(MelonEngine engine) : base(engine) { }
public IntegerPrototype(MelonEngine engine, MelonType type) : base(engine, type) { }
public MelonInterpreter(MelonEngine engine) { _engine = engine; _expressionSolver = new ExpressionSolver(engine); }
public FloatInstance(MelonEngine engine, double val) : base(engine) { Type = engine.floatType; value = val; }
public ArrayInstance(MelonEngine engine, MelonObject[] vals) : base(engine) { Type = engine.arrayType; values = new List <MelonObject>(vals); }
public IntegerType(MelonEngine engine) : base(engine) { }
public MelonErrorObject(MelonEngine engine, string msg) : base(engine) { message = msg; }
public MelonVisitor(MelonEngine engine) { _engine = engine; _expressionSolver = new ExpressionSolver(engine); }