public HassiumObject Execute(HassiumModule module, HassiumList args, Dictionary <int, HassiumObject> frame = null) { CallStack = new LinkedStack <string>(); CurrentModule = module; ExceptionReturns = new Dictionary <HassiumMethod, int>(); Globals = module.BoundAttributes["__global__"].BoundAttributes; Handlers = new Stack <HassiumExceptionHandler>(); Stack = new LinkedStack <HassiumObject>(); StackFrame = new StackFrame(); ImportGlobals(); var globalClass = module.GetAttribute(this, "__global__"); (globalClass.GetAttribute(this, "__init__") as HassiumMethod).Invoke(this, new SourceLocation("", 0, 0)); GlobalFrame = StackFrame.Frames.Peek(); if (globalClass.ContainsAttribute("main")) { var mainMethod = (globalClass.GetAttribute(this, "main") as HassiumMethod); if (mainMethod.Parameters.Count > 0) { mainMethod.Invoke(this, mainMethod.SourceLocation, args); } else { mainMethod.Invoke(this, mainMethod.SourceLocation); } } return(lastValuePopped); }
public VirtualMachine(HassiumModule module) { CallStack = new LinkedStack <string>(); CurrentModule = module; ExceptionReturns = new Dictionary <HassiumMethod, int>(); Globals = module.BoundAttributes["__global__"].BoundAttributes; Handlers = new Stack <HassiumExceptionHandler>(); Stack = new LinkedStack <HassiumObject>(); StackFrame = new StackFrame(); ImportGlobals(); }
public HassiumMethod(HassiumModule module, string name) { BreakLabels = new Stack <int>(); ContinueLabels = new Stack <int>(); Instructions = new List <HassiumInstruction>(); Labels = new Dictionary <int, int>(); Parameters = new Dictionary <FunctionParameter, int>(); Module = module; Name = name; SourceRepresentation = string.Empty; AddType(TypeDefinition); }