public override void Accept (UseStatement useStmt) { string import = !useStmt.Relative ? useStmt.Module : Path.Combine ( Path.GetDirectoryName (useStmt.Location.File), useStmt.Module); /* * Implementation detail: The use statement in all reality is simply an * alias for the function require (); Here we translate the use statement * into a call to the require function */ if (useStmt.Wildcard) { module.Initializer.EmitInstruction (useStmt.Location, Opcode.LoadConst, module.DefineConstant (new IodineString (import))); module.Initializer.EmitInstruction (useStmt.Location, Opcode.BuildTuple, 0); module.Initializer.EmitInstruction (useStmt.Location, Opcode.LoadGlobal, module.DefineConstant (new IodineName ("require"))); module.Initializer.EmitInstruction (useStmt.Location, Opcode.Invoke, 2); module.Initializer.EmitInstruction (useStmt.Location, Opcode.Pop); } else { IodineObject[] items = new IodineObject [useStmt.Imports.Count]; module.Initializer.EmitInstruction (useStmt.Location, Opcode.LoadConst, module.DefineConstant (new IodineString (import))); if (items.Length > 0) { for (int i = 0; i < items.Length; i++) { items [i] = new IodineString (useStmt.Imports [i]); module.Initializer.EmitInstruction (useStmt.Location, Opcode.LoadConst, module.DefineConstant (new IodineString (useStmt.Imports [i]))); } module.Initializer.EmitInstruction (useStmt.Location, Opcode.BuildTuple, items.Length); } module.Initializer.EmitInstruction (useStmt.Location, Opcode.LoadGlobal, module.DefineConstant (new IodineName ("require"))); module.Initializer.EmitInstruction (useStmt.Location, Opcode.Invoke, items.Length == 0 ? 1 : 2); module.Initializer.EmitInstruction (useStmt.Location, Opcode.Pop); } }
public override void Accept (UseStatement useStmt) { }
public void Accept(UseStatement useStmt) { }
public void Accept(UseStatement useStmt) { module.Imports.Add (useStmt.Module); string import = !useStmt.Relative ? useStmt.Module : Path.Combine ( Path.GetDirectoryName (useStmt.Location.File), useStmt.Module); if (useStmt.Wildcard) { module.Initializer.EmitInstruction (Opcode.LoadConst, module.DefineConstant ( new IodineString (import))); module.Initializer.EmitInstruction (Opcode.BuildTuple, 0); module.Initializer.EmitInstruction (Opcode.LoadGlobal, module.DefineConstant ( new IodineName ("require"))); module.Initializer.EmitInstruction (Opcode.Invoke, 2); module.Initializer.EmitInstruction (Opcode.Pop); } else { IodineObject[] items = new IodineObject [useStmt.Imports.Count]; module.Initializer.EmitInstruction (Opcode.LoadConst, module.DefineConstant ( new IodineString (import))); if (items.Length > 0) { for (int i = 0; i < items.Length; i++) { items [i] = new IodineString (useStmt.Imports [i]); module.Initializer.EmitInstruction (Opcode.LoadConst, module.DefineConstant ( new IodineString (useStmt.Imports [i]))); } module.Initializer.EmitInstruction (Opcode.BuildTuple, items.Length); } module.Initializer.EmitInstruction (Opcode.LoadGlobal, module.DefineConstant ( new IodineName ("require"))); module.Initializer.EmitInstruction (Opcode.Invoke, items.Length == 0 ? 1 : 2); module.Initializer.EmitInstruction (Opcode.Pop); } }
public override void Accept (UseStatement useStmt) { errorLog.AddError (ErrorType.ParserError, useStmt.Location, "statement can not exist inside pattern!"); }
public virtual void Accept(UseStatement useStmt) { }
public void Accept(UseStatement useStmt) { errorLog.AddError (ErrorType.ParserError, useStmt.Location, "use statement not valid inside function body!"); }