//public static explicit operator int(Block block) //{ // if (block.FinalType == FinalReturnType.Int) // { // return block.intValue; // } // throw new RuntimeException(""); //} #endregion #region as callable internal Block SetValue(List <Stmt> stmts) { if (stmts.Any()) { FinalType = FinalReturnType.Stmts; this.stmts = stmts; foreach (var stmt in stmts) { stmt.parent = this; } } else { throw new RuntimeException("不能创建没有语句的block"); } return(this); }
internal Block SetValue(bool value) { FinalType = FinalReturnType.Bool; boolValue = value; return(this); }
internal Block SetValue(string value) { FinalType = FinalReturnType.String; strValue = value; return(this); }
internal Block SetValue(int value) { FinalType = FinalReturnType.Int; intValue = value; return(this); }
internal Block SetValue(IOJMethod method) { FinalType = FinalReturnType.OJMethod; this.method = method; return(this); }